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 61, Mon Oct 23 20:07:05 2006 UTC revision 62, Tue Oct 24 10:08:58 2006 UTC
# Line 139  Line 139 
139    
140  setGeneric("loadFileIntoMem", function(object) standardGeneric("loadFileIntoMem"))  setGeneric("loadFileIntoMem", function(object) standardGeneric("loadFileIntoMem"))
141  setMethod("loadFileIntoMem",  setMethod("loadFileIntoMem",
142            c("PlainTextDocument"),            signature(object = "PlainTextDocument"),
143            function(object) {            function(object) {
144                if (!Cached(object)) {                if (!Cached(object)) {
145                    corpus <- readLines(FileName(object))                    corpus <- readLines(FileName(object))
# Line 151  Line 151 
151                }                }
152            })            })
153  setMethod("loadFileIntoMem",  setMethod("loadFileIntoMem",
154            c("XMLTextDocument"),            signature(object =  "XMLTextDocument"),
155            function(object) {            function(object) {
156                if (!Cached(object)) {                if (!Cached(object)) {
157                    file <- FileName(object)                    file <- FileName(object)
# Line 165  Line 165 
165                }                }
166            })            })
167  setMethod("loadFileIntoMem",  setMethod("loadFileIntoMem",
168            c("NewsgroupDocument"),            signature(object = "NewsgroupDocument"),
169            function(object) {            function(object) {
170                if (!Cached(object)) {                if (!Cached(object)) {
171                    mail <- readLines(FileName(object))                    mail <- readLines(FileName(object))
# Line 180  Line 180 
180    
181  setGeneric("tm_transform", function(object, FUN, ...) standardGeneric("tm_transform"))  setGeneric("tm_transform", function(object, FUN, ...) standardGeneric("tm_transform"))
182  setMethod("tm_transform",  setMethod("tm_transform",
183            c("TextDocCol"),            signature(object = "TextDocCol", FUN = "function"),
184            function(object, FUN, ...) {            function(object, FUN, ...) {
185                result <- as(lapply(object, FUN, ..., GlobalMetaData = GlobalMetaData(object)), "TextDocCol")                result <- as(lapply(object, FUN, ..., GlobalMetaData = GlobalMetaData(object)), "TextDocCol")
186                result@GlobalMetaData <- GlobalMetaData(object)                result@GlobalMetaData <- GlobalMetaData(object)
# Line 189  Line 189 
189    
190  setGeneric("toPlainTextDocument", function(object, FUN, ...) standardGeneric("toPlainTextDocument"))  setGeneric("toPlainTextDocument", function(object, FUN, ...) standardGeneric("toPlainTextDocument"))
191  setMethod("toPlainTextDocument",  setMethod("toPlainTextDocument",
192            c("PlainTextDocument"),            signature(object = "PlainTextDocument"),
193            function(object, FUN, ...) {            function(object, FUN, ...) {
194                return(object)                return(object)
195            })            })
196  setMethod("toPlainTextDocument",  setMethod("toPlainTextDocument",
197            c("XMLTextDocument"),            signature(object = "XMLTextDocument", FUN = "function"),
198            function(object, FUN, ...) {            function(object, FUN, ...) {
199                if (!Cached(object))                if (!Cached(object))
200                    object <- loadFileIntoMem(object)                    object <- loadFileIntoMem(object)
# Line 210  Line 210 
210    
211  setGeneric("stemTextDocument", function(object, ...) standardGeneric("stemTextDocument"))  setGeneric("stemTextDocument", function(object, ...) standardGeneric("stemTextDocument"))
212  setMethod("stemTextDocument",  setMethod("stemTextDocument",
213            c("PlainTextDocument"),            signature(object = "PlainTextDocument"),
214            function(object, ...) {            function(object, ...) {
215                if (!Cached(object))                if (!Cached(object))
216                    object <- loadFileIntoMem(object)                    object <- loadFileIntoMem(object)
# Line 276  Line 276 
276    
277  setGeneric("reuters21578.topic.filter", function(object, topics, ...) standardGeneric("reuters21578.topic.filter"))  setGeneric("reuters21578.topic.filter", function(object, topics, ...) standardGeneric("reuters21578.topic.filter"))
278  setMethod("reuters21578.topic.filter",  setMethod("reuters21578.topic.filter",
279            c("PlainTextDocument", "character"),            signature(object = "PlainTextDocument", topics = "character"),
280            function(object, topics, ...) {            function(object, topics, ...) {
281                if (!Cached(object))                if (!Cached(object))
282                    object <- loadFileIntoMem(object)                    object <- loadFileIntoMem(object)
# Line 289  Line 289 
289    
290  setGeneric("id.filter", function(object, IDs, ...) standardGeneric("id.filter"))  setGeneric("id.filter", function(object, IDs, ...) standardGeneric("id.filter"))
291  setMethod("id.filter",  setMethod("id.filter",
292            c("TextDocument", "numeric"),            signature(object = "TextDocument", IDs = "numeric"),
293            function(object, IDs, ...) {            function(object, IDs, ...) {
294                if (ID(object) %in% IDs)                if (ID(object) %in% IDs)
295                    return(TRUE)                    return(TRUE)
# Line 299  Line 299 
299    
300  setGeneric("attachData", function(object, data) standardGeneric("attachData"))  setGeneric("attachData", function(object, data) standardGeneric("attachData"))
301  setMethod("attachData",  setMethod("attachData",
302            c("TextDocCol","TextDocument"),            signature(object = "TextDocCol", data = "TextDocument"),
303            function(object, data) {            function(object, data) {
304                data <- as(list(data), "TextDocCol")                data <- as(list(data), "TextDocCol")
305                object@.Data <- as(c(object@.Data, data), "TextDocCol")                object@.Data <- as(c(object@.Data, data), "TextDocCol")
# Line 308  Line 308 
308    
309  setGeneric("attachMetaData", function(object, name, metadata) standardGeneric("attachMetaData"))  setGeneric("attachMetaData", function(object, name, metadata) standardGeneric("attachMetaData"))
310  setMethod("attachMetaData",  setMethod("attachMetaData",
311            c("TextDocCol"),            signature(object = "TextDocCol"),
312            function(object, name, metadata) {            function(object, name, metadata) {
313                object@GlobalMetaData <- c(GlobalMetaData(object), new = list(metadata))                object@GlobalMetaData <- c(GlobalMetaData(object), new = list(metadata))
314                names(object@GlobalMetaData)[length(names(GlobalMetaData(object)))] <- name                names(object@GlobalMetaData)[length(names(GlobalMetaData(object)))] <- name
# Line 317  Line 317 
317    
318  setGeneric("setSubscriptable", function(object, name) standardGeneric("setSubscriptable"))  setGeneric("setSubscriptable", function(object, name) standardGeneric("setSubscriptable"))
319  setMethod("setSubscriptable",  setMethod("setSubscriptable",
320            c("TextDocCol"),            signature(object = "TextDocCol"),
321            function(object, name) {            function(object, name) {
322                if (!is.character(GlobalMetaData(object)$subscriptable))                if (!is.character(GlobalMetaData(object)$subscriptable))
323                    object <- attachMetaData(object, "subscriptable", name)                    object <- attachMetaData(object, "subscriptable", name)

Legend:
Removed from v.61  
changed lines
  Added in v.62

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