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 1003, Tue Sep 8 06:00:14 2009 UTC revision 1004, Tue Sep 8 10:28:28 2009 UTC
# Line 140  Line 140 
140      y      y
141  }  }
142    
143  # Update \code{NodeID}s of a CMetaData tree  # Update NodeIDs of a CMetaData tree
144  update_id <- function(x, id = 0, mapping = NULL, left.mapping = NULL, level = 0) {  .update_id <- function(x, id = 0, mapping = NULL, left.mapping = NULL, level = 0) {
145      # Traversal of (binary) CMetaData tree with setup of \code{NodeID}s      # Traversal of (binary) CMetaData tree with setup of NodeIDs
146      set_id <- function(x) {      set_id <- function(x) {
147          x$NodeID <- id          x$NodeID <- id
148          id <<- id + 1          id <<- id + 1
# Line 165  Line 165 
165      list(root = set_id(x), left.mapping = left.mapping, right.mapping = mapping)      list(root = set_id(x), left.mapping = left.mapping, right.mapping = mapping)
166  }  }
167    
168    # Find indices to be updated for a CMetaData tree
169    .find_indices <- function(x) {
170        indices.mapping <- NULL
171        for (m in levels(as.factor(DMetaData(x)$MetaID))) {
172            indices <- (DMetaData(x)$MetaID == m)
173            indices.mapping <- c(indices.mapping, list(m = indices))
174            names(indices.mapping)[length(indices.mapping)] <- m
175        }
176        indices.mapping
177    }
178    
179  c2 <- function(x, y, ...) {  c2 <- function(x, y, ...) {
180      # Update the CMetaData tree      # Update the CMetaData tree
181      cmeta <- .MetaDataNode(0, list(merge_date = as.POSIXlt(Sys.time(), tz = "GMT"), merger = Sys.getenv("LOGNAME")), list(CMetaData(x), CMetaData(y)))      cmeta <- .MetaDataNode(0, list(merge_date = as.POSIXlt(Sys.time(), tz = "GMT"), merger = Sys.getenv("LOGNAME")), list(CMetaData(x), CMetaData(y)))
182      update.struct <- update_id(cmeta)      update.struct <- .update_id(cmeta)
183    
184      new <- .VCorpus(c(unclass(x), unclass(y)), update.struct$root, NULL)      new <- .VCorpus(c(unclass(x), unclass(y)), update.struct$root, NULL)
185    
186      # Find indices to be updated for the left tree      # Find indices to be updated for the left tree
187      indices.mapping <- NULL      indices.mapping <- .find_indices(x)
     for (m in levels(as.factor(DMetaData(x)$MetaID))) {  
         indices <- (DMetaData(x)$MetaID == m)  
         indices.mapping <- c(indices.mapping, list(m = indices))  
         names(indices.mapping)[length(indices.mapping)] <- m  
     }  
188    
189      # Update the DMetaData data frames for the left tree      # Update the DMetaData data frames for the left tree
190      for (i in 1:ncol(update.struct$left.mapping)) {      for (i in 1:ncol(update.struct$left.mapping)) {
# Line 187  Line 193 
193      }      }
194    
195      # Find indices to be updated for the right tree      # Find indices to be updated for the right tree
196      indices.mapping <- NULL      indices.mapping <- .find_indices(y)
     for (m in levels(as.factor(DMetaData(y)$MetaID))) {  
         indices <- (DMetaData(y)$MetaID == m)  
         indices.mapping <- c(indices.mapping, list(m = indices))  
         names(indices.mapping)[length(indices.mapping)] <- m  
     }  
197    
198      # Update the DMetaData data frames for the right tree      # Update the DMetaData data frames for the right tree
199      for (i in 1:ncol(update.struct$right.mapping)) {      for (i in 1:ncol(update.struct$right.mapping)) {

Legend:
Removed from v.1003  
changed lines
  Added in v.1004

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