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 54, Wed Sep 13 09:08:20 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            c("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("attachData",  setMethod("append_elem",
11            c("TextRepository","TextDocCol"),            signature(object = "TextRepository", data = "TextDocCol"),
12            function(object, data) {            function(object, data, meta = NULL) {
13                object@.Data <- as(c(object@.Data, data), "TextRepository")                object[[length(object)+1]] <- data
14                  object@RepoMetaData <- c(object@RepoMetaData, meta)
15                return(object)                return(object)
16            })            })
17    
18  setMethod("attachMetaData",  setMethod("append_meta",
19            c("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)
22                names(object@RepresentationMetaData)[length(names(object@RepresentationMetaData))] <- name                return(object)
23              })
24    
25    setMethod("remove_meta",
26              signature(object = "TextRepository"),
27              function(object, dcname = NULL, dname = NULL) {
28                  if (!is.null(dcname))
29                      object@RepoMetaData <- RepoMetaData(object)[names(RepoMetaData(object)) != dcname]
30                return(object)                return(object)
31            })            })
32    
# Line 33  Line 39 
39  setMethod("show",  setMethod("show",
40            signature(object = "TextRepository"),            signature(object = "TextRepository"),
41            function(object){            function(object){
42                cat("A text repository with", length(object), "text document collection")                 cat(sprintf(ngettext(length(object),
43                if (length(object) == 1)                                      "A text repository with %d text document collection\n",
44                    cat("\n")                                      "A text repository with %d text document collections\n"),
45                else                             length(object)))
                   cat("s\n")  
46      })      })
47    
48  setMethod("summary",  setMethod("summary",
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("\nThe representation metadata consists of", length(RepresentationMetaData(object)), "tag-value pair")                    cat(sprintf(ngettext(length(RepoMetaData(object)),
54                    if (length(RepresentationMetaData(object)) == 1)                                                "\nThe repository metadata consists of %d tag-value pair\n",
55                        cat(".\n")                                                "\nThe repository metadata consists of %d tag-value pairs\n"),
56                    else                                         length(RepoMetaData(object))))
                       cat("s.\n")  
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.54  
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