Extract or consolidate noun phrases from parsed documents
Source:R/nounphrase-functions.R
nounphrase_extract.RdFrom an object parsed by spacy_parse(), extract the multi-word
noun phrases as a separate object, or convert the multi-word noun phrases
into single "token" consisting of the concatenated elements of the multi-word
noun phrases.
Arguments
- x
output from
spacy_parse()- concatenator
the character(s) used to join elements of multi-word noun phrases
Value
noun returns a data.frame of all named
entities, containing the following fields:
doc_idname of the document containing the noun phrasesentence_idthe sentence ID containing the noun phrase, within the documentnounphrasethe noun phraserootthe root token of the noun phrase
nounphrase_consolidate returns a modified data.frame of
parsed results, where the noun phrases have been combined into a single
"token". Currently, dependency parsing is removed when this consolidation
occurs. If x has the columns start and end of
spacy_parse(offsets = TRUE), a consolidated noun phrase runs from the
start of its first token to the end of its last.
Examples
if (FALSE) { # \dontrun{
spacy_initialize()
# entity extraction
txt <- "Mr. Smith of moved to San Francisco in December."
parsed <- spacy_parse(txt, nounphrase = TRUE)
entity_extract(parsed)
} # }
if (FALSE) { # \dontrun{
# consolidating multi-word noun phrases
txt <- "The House of Representatives voted to suspend aid to South Dakota."
parsed <- spacy_parse(txt, nounphrase = TRUE)
nounphrase_consolidate(parsed)
} # }