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 994, Mon Sep 7 07:38:14 2009 UTC revision 995, Mon Sep 7 07:54:08 2009 UTC
# Line 87  Line 87 
87    
88  `[.PCorpus` <- function(x, i) {  `[.PCorpus` <- function(x, i) {
89      if (missing(i)) return(x)      if (missing(i)) return(x)
     cmeta <- CMetaData(x)  
90      index <- attr(x, "DMetaData")[[1 , "subset"]]      index <- attr(x, "DMetaData")[[1 , "subset"]]
91      attr(x, "DMetaData")[[1 , "subset"]] <- if (is.numeric(index)) index[i] else i      attr(x, "DMetaData")[[1 , "subset"]] <- if (is.numeric(index)) index[i] else i
92      dmeta <- attr(x, "DMetaData")      dmeta <- attr(x, "DMetaData")
93      dbcontrol <- DBControl(x)      .PCorpus(NextMethod("["), CMetaData(x), dmeta, DBControl(x))
     class(x) <- "list"  
     .PCorpus(x[i, drop = FALSE], cmeta, dmeta, dbcontrol)  
94  }  }
95    
96  `[.VCorpus` <- function(x, i) {  `[.VCorpus` <- function(x, i) {
97      if (missing(i)) return(x)      if (missing(i)) return(x)
98      cmeta <- CMetaData(x)      .VCorpus(NextMethod("["), CMetaData(x), DMetaData(x)[i, , drop = FALSE])
     dmeta <- DMetaData(x)[i, , drop = FALSE]  
     class(x) <- "list"  
     .VCorpus(x[i, drop = FALSE], cmeta, dmeta)  
99  }  }
100    
101  `[<-.PCorpus` <- function(x, i, value) {  `[<-.PCorpus` <- function(x, i, value) {
# Line 117  Line 111 
111    
112  `[[.PCorpus` <-  function(x, i) {  `[[.PCorpus` <-  function(x, i) {
113      db <- filehash::dbInit(DBControl(x)[["dbName"]], DBControl(x)[["dbType"]])      db <- filehash::dbInit(DBControl(x)[["dbName"]], DBControl(x)[["dbType"]])
114      class(x) <- "list"      filehash::dbFetch(db, NextMethod("[["))
     filehash::dbFetch(db, x[[i]])  
115  }  }
116  `[[.VCorpus` <-  function(x, i) {  `[[.VCorpus` <-  function(x, i) {
117      lazyTmMap <- meta(x, tag = "lazyTmMap", type = "corpus")      lazyTmMap <- meta(x, tag = "lazyTmMap", type = "corpus")
118      if (!is.null(lazyTmMap))      if (!is.null(lazyTmMap))
119          .Call("copyCorpus", x, materialize(x, i))          .Call("copyCorpus", x, materialize(x, i))
120      class(x) <- "list"      NextMethod("[[")
     x[[i]]  
121  }  }
122    
123  `[[<-.PCorpus` <-  function(x, i, value) {  `[[<-.PCorpus` <-  function(x, i, value) {
# Line 143  Line 135 
135      }      }
136      # Set the value      # Set the value
137      cl <- class(x)      cl <- class(x)
138      class(x) <- "list"      y <- NextMethod("[[<-")
139      x[[i]] <- value      class(y) <- cl
140      class(x) <- cl      y
     x  
141  }  }
142    
143  # Update \code{NodeID}s of a CMetaData tree  # Update \code{NodeID}s of a CMetaData tree

Legend:
Removed from v.994  
changed lines
  Added in v.995

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