File: wordlist.R

package info (click to toggle)
r-cran-nlp 0.3-2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 456 kB
  • sloc: makefile: 2
file content (44 lines) | stat: -rw-r--r-- 1,022 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
WordListDocument <-
function(con, encoding = "unknown", meta = list())
{
    words <- readLines(con, encoding = encoding, warn = FALSE)
    doc <- list(content = words, meta = meta)
    class(doc) <- c("WordListDocument", "TextDocument")
    doc
}

format.WordListDocument <-
function(x, ...)    
    c(.format_TextDocument(x),
      sprintf("Content:  words: %d", length(x$content)))
    
## print.WordListDocument <-
## function(x, ...)
## {
##     writeLines(sprintf("<<WordListDocument (words: %d)>>",
##                        length(x$content)))
##     invisible(x)
## }

content.WordListDocument <-
function(x)
    x$content

## meta.WordListDocument <-
## function(x, tag = NULL, ...)
##     if(is.null(tag)) x$meta else x$meta[[tag]]

## `meta<-.WordListDocument` <-
## function(x, tag = NULL, ..., value)
## {
##     if(is.null(tag))
##         x$meta <- value
##     else
##         x$meta[[tag]] <- value
##     x
## }

as.character.WordListDocument <-
words.WordListDocument <-
function(x, ...)
    x$content