SCM

SCM Repository

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

Diff of /pkg/R/textdoccol.R

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

revision 71, Sun Nov 19 17:30:26 2006 UTC revision 72, Mon Nov 20 20:43:34 2006 UTC
# Line 115  Line 115 
115            signature(object = "DirSource"),            signature(object = "DirSource"),
116            function(object) {            function(object) {
117                filename <- object@FileList[object@Position]                filename <- object@FileList[object@Position]
118                list(content = readLines(object@FileList[object@Position]),                list(content = readLines(filename),
119                     uri = substitute(file(filename)))                     uri = substitute(file(filename)))
120            })            })
121  setMethod("get_elem",  setMethod("get_elem",
# Line 373  Line 373 
373                }                }
374            })            })
375    
376    setGeneric("tm_update", function(object, origin, parser = plaintext_parser, ...) standardGeneric("tm_update"))
377    # Update is only supported for directories
378    # At the moment no other LoD devices are available anyway
379    setMethod("tm_update",
380              signature(object = "TextDocCol", origin = "DirSource"),
381              function(object, origin, parser = plaintext_parser, ...) {
382                  if (inherits(parser, "function_generator"))
383                      parser <- parser(...)
384    
385                  object.filelist <- unlist(lapply(object, function(x) {as.character(URI(x))[2]}))
386                  new.files <- setdiff(origin@FileList, object.filelist)
387    
388                  for (filename in new.files) {
389                      elem <- list(content = readLines(filename),
390                                   uri = substitute(file(filename)))
391                      object <- append_doc(object, parser(elem, TRUE, origin@Load, filename), NA)
392                  }
393    
394                  return(object)
395              })
396    
397  setGeneric("tm_transform", function(object, FUN, ...) standardGeneric("tm_transform"))  setGeneric("tm_transform", function(object, FUN, ...) standardGeneric("tm_transform"))
398  setMethod("tm_transform",  setMethod("tm_transform",
399            signature(object = "TextDocCol", FUN = "function"),            signature(object = "TextDocCol", FUN = "function"),
# Line 495  Line 516 
516  setGeneric("attach_data", function(object, data) standardGeneric("attach_data"))  setGeneric("attach_data", function(object, data) standardGeneric("attach_data"))
517  setGeneric("attach_metadata", function(object, name, metadata) standardGeneric("attach_metadata"))  setGeneric("attach_metadata", function(object, name, metadata) standardGeneric("attach_metadata"))
518    
519  setGeneric("append_doc", function(object, data, meta) standardGeneric("append_doc"))  setGeneric("append_doc", function(object, data, meta = NULL) standardGeneric("append_doc"))
520  setMethod("append_doc",  setMethod("append_doc",
521            signature(object = "TextDocCol", data = "TextDocument", meta = "list"),            signature(object = "TextDocCol", data = "TextDocument"),
522            function(object, data, meta) {            function(object, data, meta = NULL) {
523                object@.Data <- c(object@.Data, list(data))                object@.Data <- c(object@.Data, list(data))
524                  if (length(meta) > 0)
525                object@DMetaData <- rbind(object@DMetaData, c(MetaID = DCMetaData(object)@NodeID, meta))                object@DMetaData <- rbind(object@DMetaData, c(MetaID = DCMetaData(object)@NodeID, meta))
526                return(object)                return(object)
527            })            })
528    
529  setGeneric("append_meta", function(object, dcmeta, dmeta) standardGeneric("append_meta"))  setGeneric("append_meta", function(object, dcmeta = list(), dmeta = NULL) standardGeneric("append_meta"))
530  setMethod("append_meta",  setMethod("append_meta",
531            signature(object = "TextDocCol", dcmeta = "list", dmeta = "list"),            signature(object = "TextDocCol"),
532            function(object, dcmeta, dmeta) {            function(object, dcmeta = list(), dmeta = NULL) {
533                object@DCMetaData@MetaData <- c(object@DCMetaData@MetaData, dcmeta)                object@DCMetaData@MetaData <- c(object@DCMetaData@MetaData, dcmeta)
534                  if (length(dmeta) > 0)
535                object@DMetaData <- cbind(object@DMetaData, dmeta)                object@DMetaData <- cbind(object@DMetaData, dmeta)
536                return(object)                return(object)
537            })            })
# Line 649  Line 672 
672    
673                return(object)                return(object)
674      })      })
675  #setMethod("c",  setMethod("c",
676  #          signature(x = "TextDocument"),            signature(x = "TextDocument"),
677  #          function(x, ..., recursive = TRUE){            function(x, ..., recursive = TRUE){
678  #              args <- list(...)                args <- list(...)
679  #              if(length(args) == 0)                if(length(args) == 0)
680  #                  return(x)                    return(x)
681  #              return(new("TextDocCol", .Data = list(x, ...)))  
682  #    })                dmeta.df <- data.frame(MetaID = rep(0, length(list(x, ...))))
683                  dcmeta.node <- new("MetaDataNode",
684                                NodeID = 0,
685                                MetaData = list(create_date = date(), creator = Sys.getenv("LOGNAME")),
686                                children = list())
687    
688                  return(new("TextDocCol", .Data = list(x, ...), DMetaData = dmeta.df, DCMetaData = dcmeta.node))
689              })
690    
691  setMethod("length",  setMethod("length",
692            signature(x = "TextDocCol"),            signature(x = "TextDocCol"),

Legend:
Removed from v.71  
changed lines
  Added in v.72

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