SCM

SCM Repository

[tm] Annotation of /trunk/R/textmin/R/textrepo.R
ViewVC logotype

Annotation of /trunk/R/textmin/R/textrepo.R

Parent Directory Parent Directory | Revision Log Revision Log


Revision 70 - (view) (download)

1 : feinerer 52 # Author: Ingo Feinerer
2 :    
3 :     setGeneric("TextRepository", function(object, metaname = "created", meta = date()) standardGeneric("TextRepository"))
4 :     setMethod("TextRepository",
5 : feinerer 62 signature(object = "TextDocCol"),
6 : feinerer 52 function(object, metaname, meta) {
7 :     tr <- new("TextRepository", .Data = list(object), RepresentationMetaData = list(created = meta))
8 :     names(tr@RepresentationMetaData) <- metaname
9 :     return(tr)
10 :     })
11 :    
12 : feinerer 66 setMethod("attach_data",
13 : feinerer 62 signature(object = "TextRepository", data = "TextDocCol"),
14 : feinerer 52 function(object, data) {
15 : feinerer 68 object[[length(object)+1]] <- data
16 : feinerer 52 return(object)
17 :     })
18 :    
19 : feinerer 66 setMethod("attach_metadata",
20 : feinerer 62 signature(object = "TextRepository"),
21 : feinerer 52 function(object, name, metadata) {
22 :     object@RepresentationMetaData <- c(object@RepresentationMetaData, new = list(metadata))
23 :     names(object@RepresentationMetaData)[length(names(object@RepresentationMetaData))] <- name
24 :     return(object)
25 :     })
26 : feinerer 54
27 : feinerer 69 setMethod("remove_metadata",
28 :     signature(object = "TextRepository"),
29 :     function(object, name) {
30 :     object@RepresentationMetaData <- RepresentationMetaData(object)[names(RepresentationMetaData(object)) != name]
31 :     return(object)
32 :     })
33 :    
34 :     setMethod("modify_metadata",
35 :     signature(object = "TextRepository"),
36 :     function(object, name, metadata) {
37 :     object@RepresentationMetaData[[name]] <- metadata
38 :     return(object)
39 :     })
40 :    
41 : feinerer 54 setMethod("length",
42 :     signature(x = "TextRepository"),
43 :     function(x){
44 :     return(length(as(x, "list")))
45 :     })
46 :    
47 :     setMethod("show",
48 :     signature(object = "TextRepository"),
49 :     function(object){
50 : feinerer 70 cat(sprintf(ngettext(length(object),
51 :     "A text repository with %d text document collection\n",
52 :     "A text repository with %d text document collections\n"),
53 :     length(object)))
54 : feinerer 54 })
55 :    
56 :     setMethod("summary",
57 :     signature(object = "TextRepository"),
58 :     function(object){
59 :     show(object)
60 :     if (length(RepresentationMetaData(object)) > 0) {
61 : feinerer 70 cat(sprintf(ngettext(length(RepresentationMetaData(object)),
62 :     "\nThe representation metadata consists of %d tag-value pair\n",
63 :     "\nThe representation metadata consists of %d tag-value pairs\n"),
64 :     length(RepresentationMetaData(object))))
65 : feinerer 54 cat("Available tags are:\n")
66 :     cat(names(RepresentationMetaData(object)), "\n")
67 :     }
68 :     })

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