SCM

SCM Repository

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

View of /trunk/tm/R/textrepo.R

Parent Directory Parent Directory | Revision Log Revision Log


Revision 693 - (download) (annotate)
Fri Dec 22 13:21:30 2006 UTC (12 years, 7 months ago) by feinerer
File size: 2384 byte(s)
Renamed textmin to tm directory since the package name changed.
# Author: Ingo Feinerer

setGeneric("TextRepository", function(object, meta = list(created = Sys.time())) standardGeneric("TextRepository"))
setMethod("TextRepository",
          signature(object = "TextDocCol"),
          function(object, meta) {
              return(new("TextRepository", .Data = list(object), RepoMetaData = meta))
          })

setMethod("append_elem",
          signature(object = "TextRepository", data = "TextDocCol"),
          function(object, data, meta = NULL) {
              object[[length(object)+1]] <- data
              object@RepoMetaData <- c(object@RepoMetaData, meta)
              return(object)
          })

setMethod("append_meta",
          signature(object = "TextRepository"),
          function(object, dcmeta = NULL, dmeta = NULL) {
              object@RepoMetaData <- c(object@RepoMetaData, dcmeta)
              return(object)
          })

setMethod("remove_meta",
          signature(object = "TextRepository"),
          function(object, dcname = NULL, dname = NULL) {
              if (!is.null(dcname))
                  object@RepoMetaData <- RepoMetaData(object)[names(RepoMetaData(object)) != dcname]
              return(object)
          })

setMethod("length",
          signature(x = "TextRepository"),
          function(x){
              return(length(as(x, "list")))
    })

setMethod("show",
          signature(object = "TextRepository"),
          function(object){
               cat(sprintf(ngettext(length(object),
                                    "A text repository with %d text document collection\n",
                                    "A text repository with %d text document collections\n"),
                           length(object)))
    })

setMethod("summary",
          signature(object = "TextRepository"),
          function(object){
              show(object)
              if (length(RepoMetaData(object)) > 0) {
                  cat(sprintf(ngettext(length(RepoMetaData(object)),
                                              "\nThe repository metadata consists of %d tag-value pair\n",
                                              "\nThe repository metadata consists of %d tag-value pairs\n"),
                                       length(RepoMetaData(object))))
                  cat("Available tags are:\n")
                  cat(names(RepoMetaData(object)), "\n")
              }
    })

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