Description Usage Arguments Details Value Examples
View source: R/TokenNameFinder.R
Learnable Name Finder
1 2 3 |
model |
Model to use, generally returned by |
sentences |
Sentences containing entities to find, a character vector or full path to file, usually |
output |
An output file, generally |
name tagging:
<END>.
is invalid
<END> .
is valid
Use check_tags
Full path to the output
if specified.
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 | ## Not run:
# get working directory
# need to pass full path
wd <- getwd()
# Training to find "WEF"
data <- paste("This organisation is called the <START:wef> World Economic Forum <END>",
"It is often referred to as <START:wef> Davos <END> or the <START:wef> WEF <END> .")
# train the model
model <- tnf_train(model = paste0(wd, "/wef.bin"), lang = "en",
data = data, type = "wef")
# Create sentences to test our model
sentences <- paste("This sentence mentions the World Economic Forum the annual meeting",
"of which takes place in Davos. Note that the forum is often called the WEF.")
# run model on sentences
results <- tnf(model = model, sentences = sentences)
# same with text files
# Save the above as file
write(data, file = "input.txt")
# Trains the model and returns the full path to the model
model <- tnf_train_(model = paste0(wd, "/wef.bin"), lang = "en",
data = paste0(wd, "/input.txt"), type = "wef")
# Create sentences to test our model
sentences <- paste("This sentence mentions the World Economic Forum the annual meeting",
"of which takes place in Davos. Note that the forum is often called the WEF.")
# Save sentences
write(data, file = "sentences.txt")
# Extract names
# Without specifying an output file the extracted names appear in the console
tnf(model = model, sentences = paste0(wd, "/sentences.txt"))
# returns path to output file
output <- tnf_(model = model, sentences = paste0(wd, "/sentences.txt"),
output = paste0(wd, "/output.txt"))
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.