SCM

SCM Repository

[tm] Diff of /trunk/tm/R/source.R
ViewVC logotype

Diff of /trunk/tm/R/source.R

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

revision 831, Wed Mar 12 09:10:46 2008 UTC revision 832, Wed Mar 12 12:59:48 2008 UTC
# Line 9  Line 9 
9                          Encoding = "character",                          Encoding = "character",
10                          "VIRTUAL"))                          "VIRTUAL"))
11    
12    # A vector where each component is interpreted as document
13    setClass("VectorSource",
14             representation(Content = "vector"),
15             contains = c("Source"))
16    
17  # A directory with files  # A directory with files
18  setClass("DirSource",  setClass("DirSource",
19           representation(FileList = "character"),           representation(FileList = "character"),
# Line 36  Line 41 
41    
42  # Methods for Source objects  # Methods for Source objects
43    
44    setGeneric("VectorSource", function(object, encoding = "UTF-8") standardGeneric("VectorSource"))
45    setMethod("VectorSource",
46              signature(object = "vector"),
47              function(object, encoding = "UTF-8") {
48                  new("VectorSource", LoDSupport = FALSE, Content = object, Position = 0,
49                      DefaultReader = readPlain, Encoding = encoding)
50              })
51    
52  setGeneric("DirSource", function(directory, encoding = "UTF-8", recursive = FALSE) standardGeneric("DirSource"))  setGeneric("DirSource", function(directory, encoding = "UTF-8", recursive = FALSE) standardGeneric("DirSource"))
53  setMethod("DirSource",  setMethod("DirSource",
54            signature(directory = "character"),            signature(directory = "character"),
# Line 127  Line 140 
140    
141  setGeneric("stepNext", function(object) standardGeneric("stepNext"))  setGeneric("stepNext", function(object) standardGeneric("stepNext"))
142  setMethod("stepNext",  setMethod("stepNext",
143              signature(object = "VectorSource"),
144              function(object) {
145                  object@Position <- object@Position + 1
146                  object
147              })
148    setMethod("stepNext",
149            signature(object = "DirSource"),            signature(object = "DirSource"),
150            function(object) {            function(object) {
151                object@Position <- object@Position + 1                object@Position <- object@Position + 1
# Line 153  Line 172 
172    
173  setGeneric("getElem", function(object) standardGeneric("getElem"))  setGeneric("getElem", function(object) standardGeneric("getElem"))
174  setMethod("getElem",  setMethod("getElem",
175              signature(object = "VectorSource"),
176              function(object) {
177                  list(content = object@Content[object@Position],
178                       uri = NULL)
179              })
180    setMethod("getElem",
181            signature(object = "DirSource"),            signature(object = "DirSource"),
182            function(object) {            function(object) {
183                filename <- object@FileList[object@Position]                filename <- object@FileList[object@Position]
# Line 189  Line 214 
214    
215  setGeneric("eoi", function(object) standardGeneric("eoi"))  setGeneric("eoi", function(object) standardGeneric("eoi"))
216  setMethod("eoi",  setMethod("eoi",
217              signature(object = "VectorSource"),
218              function(object) {
219                  if (length(object@Content) <= object@Position)
220                      return(TRUE)
221                  else
222                      return(FALSE)
223              })
224    setMethod("eoi",
225            signature(object = "DirSource"),            signature(object = "DirSource"),
226            function(object) {            function(object) {
227                if (length(object@FileList) <= object@Position)                if (length(object@FileList) <= object@Position)

Legend:
Removed from v.831  
changed lines
  Added in v.832

root@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