SCM

SCM Repository

[tm] Diff of /trunk/tm/R/textrepo.R
ViewVC logotype

Diff of /trunk/tm/R/textrepo.R

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

trunk/R/textmin/R/textrepo.R revision 70, Tue Nov 7 18:18:51 2006 UTC trunk/tm/R/textrepo.R revision 693, Fri Dec 22 13:21:30 2006 UTC
# Line 1  Line 1 
1  # Author: Ingo Feinerer  # Author: Ingo Feinerer
2    
3  setGeneric("TextRepository", function(object, metaname = "created", meta = date()) standardGeneric("TextRepository"))  setGeneric("TextRepository", function(object, meta = list(created = Sys.time())) standardGeneric("TextRepository"))
4  setMethod("TextRepository",  setMethod("TextRepository",
5            signature(object = "TextDocCol"),            signature(object = "TextDocCol"),
6            function(object, metaname, meta) {            function(object, meta) {
7                tr <- new("TextRepository", .Data = list(object), RepresentationMetaData = list(created = meta))                return(new("TextRepository", .Data = list(object), RepoMetaData = meta))
               names(tr@RepresentationMetaData) <- metaname  
               return(tr)  
8            })            })
9    
10  setMethod("attach_data",  setMethod("append_elem",
11            signature(object = "TextRepository", data = "TextDocCol"),            signature(object = "TextRepository", data = "TextDocCol"),
12            function(object, data) {            function(object, data, meta = NULL) {
13                object[[length(object)+1]] <- data                object[[length(object)+1]] <- data
14                  object@RepoMetaData <- c(object@RepoMetaData, meta)
15                return(object)                return(object)
16            })            })
17    
18  setMethod("attach_metadata",  setMethod("append_meta",
19            signature(object = "TextRepository"),            signature(object = "TextRepository"),
20            function(object, name, metadata) {            function(object, dcmeta = NULL, dmeta = NULL) {
21                object@RepresentationMetaData <- c(object@RepresentationMetaData, new = list(metadata))                object@RepoMetaData <- c(object@RepoMetaData, dcmeta)
               names(object@RepresentationMetaData)[length(names(object@RepresentationMetaData))] <- name  
22                return(object)                return(object)
23            })            })
24    
25  setMethod("remove_metadata",  setMethod("remove_meta",
26            signature(object = "TextRepository"),            signature(object = "TextRepository"),
27            function(object, name) {            function(object, dcname = NULL, dname = NULL) {
28                object@RepresentationMetaData <- RepresentationMetaData(object)[names(RepresentationMetaData(object)) != name]                if (!is.null(dcname))
29                return(object)                    object@RepoMetaData <- RepoMetaData(object)[names(RepoMetaData(object)) != dcname]
           })  
   
 setMethod("modify_metadata",  
           signature(object = "TextRepository"),  
           function(object, name, metadata) {  
               object@RepresentationMetaData[[name]] <- metadata  
30                return(object)                return(object)
31            })            })
32    
# Line 57  Line 49 
49            signature(object = "TextRepository"),            signature(object = "TextRepository"),
50            function(object){            function(object){
51                show(object)                show(object)
52                if (length(RepresentationMetaData(object)) > 0) {                if (length(RepoMetaData(object)) > 0) {
53                    cat(sprintf(ngettext(length(RepresentationMetaData(object)),                    cat(sprintf(ngettext(length(RepoMetaData(object)),
54                                                "\nThe representation metadata consists of %d tag-value pair\n",                                                "\nThe repository metadata consists of %d tag-value pair\n",
55                                                "\nThe representation metadata consists of %d tag-value pairs\n"),                                                "\nThe repository metadata consists of %d tag-value pairs\n"),
56                                         length(RepresentationMetaData(object))))                                         length(RepoMetaData(object))))
57                    cat("Available tags are:\n")                    cat("Available tags are:\n")
58                    cat(names(RepresentationMetaData(object)), "\n")                    cat(names(RepoMetaData(object)), "\n")
59                }                }
60      })      })

Legend:
Removed from v.70  
changed lines
  Added in v.693

root@r-forge.r-project.org
ViewVC Help
Powered by ViewVC 1.0.0  
Thanks to:
Vienna University of Economics and Business Powered By FusionForge