Get results from documents processed by spaCy (deprecated)
Source:R/parse-extractor-functions.R
get-functions.RdThese functions are deprecated, and will be removed in a future version of
spacyr. They give a warning on every call. spacy_parse() returns all
of their results in one data.frame, one row per token:
get_tokens(): thetokencolumn;get_tags(): theposcolumn, ortagwithspacy_parse(x, tag = TRUE);get_attrs():spacy_parse(x, additional_attributes = attr_name);get_named_entities(): theentitycolumn;get_dependency(): thehead_token_idanddep_relcolumns ofspacy_parse(x, dependency = TRUE). Note thathead_token_idnumbers the tokens within each sentence, while thehead_idofget_dependency()numbers them within each document. To number the head tokens within each document, add the number of tokens in the document's earlier sentences:get_ntokens()andget_ntokens_by_sent(): count the rows bydoc_id, and bydoc_idandsentence_id;get_noun_phrases():spacy_extract_nounphrases().
Each reads the documents held by the result of process_document(),
which are not affected by later calls to other spacyr functions.
Usage
get_tokens(spacy_out)
get_tags(spacy_out, tagset = c("google", "detailed"))
get_attrs(spacy_out, attr_name, deal_utf8 = FALSE)
get_named_entities(spacy_out)
get_dependency(spacy_out)
get_noun_phrases(spacy_out)
get_ntokens(spacy_out)
get_ntokens_by_sent(spacy_out)Arguments
- spacy_out
the result of
process_document()character label for the tagset to use, either
"google"or"detailed"to use the simplified Google tagset, or the more detailed scheme from the Penn Treebank (or the German Text Archive in case of German language model).- attr_name
name of spaCy token attributes to extract
- deal_utf8
not used; kept for compatibility
Value
get_tokens() returns a character vector of the tokens of all the
documents.
get_tags() returns a character vector of the part-of-speech tags
of all the tokens.
get_attrs() returns the values of the attribute for all the
tokens.
get_named_entities() returns a character vector of the entity
tags of all the tokens.
get_dependency() returns a list of the head token IDs
(head_id) and the dependency relations (dep_rel) of all the tokens.
get_noun_phrases() returns a data.frame of noun phrases.
get_ntokens() returns the number of tokens in each document.
get_ntokens_by_sent() returns a list of the number of tokens in
each sentence, for each document.