SCM

SCM Repository

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

Annotation of /trunk/tm/R/textrepo.R

Parent Directory Parent Directory | Revision Log Revision Log


Revision 698 - (view) (download)

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

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