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 1397, Fri Sep 12 19:30:27 2014 UTC revision 1409, Fri Feb 27 16:10:18 2015 UTC
# Line 28  Line 28 
28      }      }
29      x <- close(x)      x <- close(x)
30    
31      structure(list(content = tdl,      p <- list(content = tdl,
32                     meta = CorpusMeta(),                     meta = CorpusMeta(),
33                     dmeta = data.frame(row.names = seq_along(tdl)),                     dmeta = data.frame(row.names = seq_along(tdl)),
34                     dbcontrol = dbControl),                dbcontrol = dbControl)
35                class = c("PCorpus", "Corpus"))      class(p) <- c("PCorpus", "Corpus")
36        p
37  }  }
38    
39  Corpus <-  Corpus <-
# Line 66  Line 67 
67      }      }
68      x <- close(x)      x <- close(x)
69    
70      structure(list(content = tdl,      as.VCorpus(tdl)
                    meta = CorpusMeta(),  
                    dmeta = data.frame(row.names = seq_along(tdl))),  
               class = c("VCorpus", "Corpus"))  
71  }  }
72    
73  `[.PCorpus` <-  `[.PCorpus` <-
# Line 146  Line 144 
144  function(x)  function(x)
145      UseMethod("as.VCorpus")      UseMethod("as.VCorpus")
146  as.VCorpus.VCorpus <- identity  as.VCorpus.VCorpus <- identity
147    as.VCorpus.list <-
148    function(x)
149    {
150        v <- list(content = x,
151                  meta = CorpusMeta(),
152                  dmeta = data.frame(row.names = seq_along(x)))
153        class(v) <- c("VCorpus", "Corpus")
154        v
155    }
156    
157  outer_union <-  outer_union <-
158  function(x, y, ...)  function(x, y, ...)
# Line 172  Line 179 
179      if (!all(unlist(lapply(args, inherits, class(x)))))      if (!all(unlist(lapply(args, inherits, class(x)))))
180          stop("not all arguments are of the same corpus type")          stop("not all arguments are of the same corpus type")
181    
182      structure(list(content = do.call("c", lapply(args, content)),      v <- list(content = do.call("c", lapply(args, content)),
183                     meta = CorpusMeta(meta = do.call("c",                     meta = CorpusMeta(meta = do.call("c",
184                       lapply(args, function(a) meta(a, type = "corpus")))),                       lapply(args, function(a) meta(a, type = "corpus")))),
185                     dmeta = Reduce(outer_union, lapply(args, meta))),                dmeta = Reduce(outer_union, lapply(args, meta)))
186                class = c("VCorpus", "Corpus"))      class(v) <- c("VCorpus", "Corpus")
187        v
188  }  }
189    
190  content.VCorpus <-  content.VCorpus <-

Legend:
Removed from v.1397  
changed lines
  Added in v.1409

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