2 |
|
|
3 |
# The "..." are additional arguments for the FunctionGenerator parser |
# The "..." are additional arguments for the FunctionGenerator parser |
4 |
setGeneric("TextDocCol", function(object, |
setGeneric("TextDocCol", function(object, |
5 |
parser = readPlain, |
parserControl = list(parser = readPlain, language = "en_US", load = FALSE), |
|
load = FALSE, |
|
6 |
dbControl = list(useDb = FALSE, dbName = "", dbType = "DB1"), |
dbControl = list(useDb = FALSE, dbName = "", dbType = "DB1"), |
7 |
...) standardGeneric("TextDocCol")) |
...) standardGeneric("TextDocCol")) |
8 |
setMethod("TextDocCol", |
setMethod("TextDocCol", |
9 |
signature(object = "Source"), |
signature(object = "Source"), |
10 |
function(object, parser = readPlain, load = FALSE, dbControl = list(useDb = FALSE, dbName = "", dbType = "DB1"), ...) { |
function(object, |
11 |
if (inherits(parser, "FunctionGenerator")) |
parserControl = list(parser = readPlain, language = "en_US", load = FALSE), |
12 |
parser <- parser(...) |
dbControl = list(useDb = FALSE, dbName = "", dbType = "DB1"), |
13 |
|
...) { |
14 |
|
if (inherits(parserControl$parser, "FunctionGenerator")) |
15 |
|
parserControl$parser <- parserControl$parser(...) |
16 |
|
|
17 |
if (dbControl$useDb) { |
if (dbControl$useDb) { |
18 |
if (!dbCreate(dbControl$dbName, dbControl$dbType)) |
if (!dbCreate(dbControl$dbName, dbControl$dbType)) |
28 |
# If there is no Load on Demand support |
# If there is no Load on Demand support |
29 |
# we need to load the corpus into memory at startup |
# we need to load the corpus into memory at startup |
30 |
if (!object@LoDSupport) |
if (!object@LoDSupport) |
31 |
load <- TRUE |
parserControl$load <- TRUE |
32 |
doc <- parser(elem, load, as.character(counter)) |
doc <- parserControl$parser(elem, parserControl$load, parserControl$language, as.character(counter)) |
33 |
if (dbControl$useDb) { |
if (dbControl$useDb) { |
34 |
dbInsert(db, ID(doc), doc) |
dbInsert(db, ID(doc), doc) |
35 |
tdl <- c(tdl, ID(doc)) |
tdl <- c(tdl, ID(doc)) |
106 |
} |
} |
107 |
}) |
}) |
108 |
|
|
109 |
|
# TODO: Check regarding new TextDocCol signature |
110 |
setGeneric("tmUpdate", function(object, origin, parser = readPlain, ...) standardGeneric("tmUpdate")) |
setGeneric("tmUpdate", function(object, origin, parser = readPlain, ...) standardGeneric("tmUpdate")) |
111 |
# Update is only supported for directories |
# Update is only supported for directories |
112 |
# At the moment no other LoD devices are available anyway |
# At the moment no other LoD devices are available anyway |