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 1315, Mon Mar 31 08:38:05 2014 UTC revision 1327, Mon Apr 14 15:35:38 2014 UTC
# Line 162  Line 162 
162      x      x
163  }  }
164    
165  #c2 <-  outer_union <-
166  #function(x, y, ...)  function(x, y, ...)
167  #{  {
168  #    # Update the CMetaData tree      if (nrow(x) > 0L)
169  #    cmeta <- .MetaDataNode(0, list(merge_date = as.POSIXlt(Sys.time(), tz = "GMT"), merger = Sys.getenv("LOGNAME")), list(CMetaData(x), CMetaData(y)))          x[, setdiff(names(y), names(x))] <- NA
170  #    update.struct <- .update_id(cmeta)      if (nrow(y) > 0L)
171  #          y[, setdiff(names(x), names(y))] <- NA
172  #    new <- .VCorpus(c(unclass(x), unclass(y)), update.struct$root, NULL)      res <- rbind(x, y)
173  #      if (ncol(res) == 0L)
174  #    # Find indices to be updated for the left tree          res <- data.frame(row.names = seq_len(nrow(x) + nrow(y)))
175  #    indices.mapping <- .find_indices(x)      res
176  #  }
 #    # Update the CorpusDMeta data frames for the left tree  
 #    for (i in 1:ncol(update.struct$left.mapping)) {  
 #        map <- update.struct$left.mapping[,i]  
 #        DMetaData(x)$MetaID <- replace(DMetaData(x)$MetaID, indices.mapping[[as.character(map[1])]], map[2])  
 #    }  
 #  
 #    # Find indices to be updated for the right tree  
 #    indices.mapping <- .find_indices(y)  
 #  
 #    # Update the CorpusDMeta data frames for the right tree  
 #    for (i in 1:ncol(update.struct$right.mapping)) {  
 #        map <- update.struct$right.mapping[,i]  
 #        DMetaData(y)$MetaID <- replace(DMetaData(y)$MetaID, indices.mapping[[as.character(map[1])]], map[2])  
 #    }  
 #  
 #    # Merge the CorpusDMeta data frames  
 #    labels <- setdiff(names(DMetaData(y)), names(DMetaData(x)))  
 #    na.matrix <- matrix(NA,  
 #                        nrow = nrow(DMetaData(x)),  
 #                        ncol = length(labels),  
 #                        dimnames = list(row.names(DMetaData(x)), labels))  
 #    x.dmeta.aug <- cbind(DMetaData(x), na.matrix)  
 #    labels <- setdiff(names(DMetaData(x)), names(DMetaData(y)))  
 #    na.matrix <- matrix(NA,  
 #                        nrow = nrow(DMetaData(y)),  
 #                        ncol = length(labels),  
 #                        dimnames = list(row.names(DMetaData(y)), labels))  
 #    y.dmeta.aug <- cbind(DMetaData(y), na.matrix)  
 #    DMetaData(new) <- rbind(x.dmeta.aug, y.dmeta.aug)  
 #  
 #    new  
 #}  
177    
178  c.VCorpus <-  c.VCorpus <-
179  function(..., recursive = FALSE)  function(..., recursive = FALSE)
# Line 219  Line 187 
187      if (!all(unlist(lapply(args, inherits, class(x)))))      if (!all(unlist(lapply(args, inherits, class(x)))))
188          stop("not all arguments are of the same corpus type")          stop("not all arguments are of the same corpus type")
189    
190      if (recursive)      structure(list(content = do.call("c", lapply(args, content)),
191          Reduce(c2, args)                     meta = structure(do.call("c",
192      else {                       lapply(args, function(a) meta(a, type = "corpus"))),
193          args <- do.call("c", lapply(args, content))                                      class = "CorpusMeta"),
194          structure(list(content = args,                     dmeta = Reduce(outer_union, lapply(args, meta))),
                        meta = CorpusMeta(),  
                        dmeta = data.frame(row.names = seq_along(args))),  
195                    class = c("VCorpus", "Corpus"))                    class = c("VCorpus", "Corpus"))
196      }      }
 }  
197    
198  c.TextDocument <-  c.TextDocument <-
199  function(..., recursive = FALSE)  function(..., recursive = FALSE)

Legend:
Removed from v.1315  
changed lines
  Added in v.1327

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