SCM

SCM Repository

[tm] Diff of /pkg/R/corpus.R
ViewVC logotype

Diff of /pkg/R/corpus.R

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

revision 76, Thu Nov 23 16:29:02 2006 UTC revision 77, Sun Nov 26 13:32:16 2006 UTC
# Line 562  Line 562 
562                return(any(grep(pattern, Corpus(object))))                return(any(grep(pattern, Corpus(object))))
563            })            })
564    
565  setGeneric("attach_data", function(object, data) standardGeneric("attach_data"))  setGeneric("append_elem", function(object, data, meta = NULL) standardGeneric("append_elem"))
566  setGeneric("attach_metadata", function(object, name, metadata) standardGeneric("attach_metadata"))  setMethod("append_elem",
   
 setGeneric("append_doc", function(object, data, meta = NULL) standardGeneric("append_doc"))  
 setMethod("append_doc",  
567            signature(object = "TextDocCol", data = "TextDocument"),            signature(object = "TextDocCol", data = "TextDocument"),
568            function(object, data, meta = NULL) {            function(object, data, meta = NULL) {
569                object@.Data <- c(object@.Data, list(data))                object@.Data[[length(object)+1]] <- data
570                object@DMetaData <- rbind(object@DMetaData, c(MetaID = DCMetaData(object)@NodeID, meta))                object@DMetaData <- rbind(object@DMetaData, c(MetaID = DCMetaData(object)@NodeID, meta))
571                return(object)                return(object)
572            })            })
573    
574  setGeneric("append_meta", function(object, dcmeta = list(), dmeta = NULL) standardGeneric("append_meta"))  setGeneric("append_meta", function(object, dcmeta = NULL, dmeta = NULL) standardGeneric("append_meta"))
575  setMethod("append_meta",  setMethod("append_meta",
576            signature(object = "TextDocCol"),            signature(object = "TextDocCol"),
577            function(object, dcmeta = list(), dmeta = NULL) {            function(object, dcmeta = NULL, dmeta = NULL) {
578                object@DCMetaData@MetaData <- c(object@DCMetaData@MetaData, dcmeta)                object@DCMetaData@MetaData <- c(object@DCMetaData@MetaData, dcmeta)
579                if (length(dmeta) > 0)                if (!is.null(dcmeta))
580                    object@DMetaData <- cbind(object@DMetaData, dmeta)                    object@DMetaData <- cbind(object@DMetaData, dmeta)
581                return(object)                return(object)
582            })            })
583    
584  setGeneric("remove_metadata", function(object, name) standardGeneric("remove_metadata"))  setGeneric("remove_meta", function(object, dcname = NULL, dname = NULL) standardGeneric("remove_meta"))
585  #setMethod("remove_metadata",  setMethod("remove_meta",
586  #          signature(object = "TextDocCol"),            signature(object = "TextDocCol"),
587  #          function(object, name) {            function(object, dcname = NULL, dname = NULL) {
588  #              object@DMetaData <- DMetaData(object)[names(DMetaData(object)) != name]                if (!is.null(dcname)) {
589  #              return(object)                    object@DCMetaData@MetaData <- DCMetaData(object)@MetaData[names(DCMetaData(object)@MetaData) != dcname]
590  #          })                }
591                  if (!is.null(dname)) {
592  setGeneric("modify_metadata", function(object, name, metadata) standardGeneric("modify_metadata"))                    object@DMetaData <- DMetaData(object)[names(DMetaData(object)) != dname]
593  #setMethod("modify_metadata",                }
594  #          signature(object = "TextDocCol"),                return(object)
595  #          function(object, name, metadata) {            })
 #              object@DMetaData[[name]] <- metadata  
 #              return(object)  
 #          })  
596    
597  setGeneric("prescind_meta", function(object, meta) standardGeneric("prescind_meta"))  setGeneric("prescind_meta", function(object, meta) standardGeneric("prescind_meta"))
598  setMethod("prescind_meta",  setMethod("prescind_meta",
# Line 785  Line 779 
779            function(object){            function(object){
780                show(object)                show(object)
781                if (length(DMetaData(object)) > 0) {                if (length(DMetaData(object)) > 0) {
782                    cat(sprintf(ngettext(length(DMetaData(object)),                    cat(sprintf(ngettext(length(DCMetaData(object)@MetaData),
783                                                "\nThe global metadata consists of %d tag-value pair\n",                                                "\nThe metadata consists of %d tag-value pair and a data frame\n",
784                                                "\nThe global metadata consists of %d tag-value pairs\n"),                                                "\nThe metadata consists of %d tag-value pairs and a data frame\n"),
785                                         length(DMetaData(object))))                                         length(DCMetaData(object)@MetaData)))
786                    cat("Available tags are:\n")                    cat("Available tags are:\n")
787                      cat(names(DCMetaData(object)@MetaData), "\n")
788                      cat("Available variables in the data frame are:\n")
789                    cat(names(DMetaData(object)), "\n")                    cat(names(DMetaData(object)), "\n")
790                }                }
791      })      })

Legend:
Removed from v.76  
changed lines
  Added in v.77

R-Forge@R-project.org
ViewVC Help
Powered by ViewVC 1.0.0  
Thanks to:
Vienna University of Economics and Business University of Wisconsin - Madison Powered By FusionForge