Nasty.AST.Token (Nasty v0.3.0)
View SourceToken node representing a single word or punctuation mark.
Uses Universal Dependencies POS tag set for cross-linguistic consistency.
Summary
Functions
Checks if a POS tag is a content word (open class).
Checks if a POS tag is a function word (closed class).
Creates a new token.
Returns all supported Universal Dependencies POS tags.
Types
Morphological features following Universal Dependencies.
Common features:
number::singular|:pluraltense::past|:present|:futureperson::first|:second|:thirdcase::nominative|:accusative|:genitive| etc.gender::masculine|:feminine|:neutermood::indicative|:subjunctive|:imperativevoice::active|:passive
Reference: https://universaldependencies.org/u/feat/
@type pos_tag() ::
:adj
| :adp
| :adv
| :aux
| :cconj
| :det
| :intj
| :noun
| :num
| :part
| :pron
| :propn
| :punct
| :sconj
| :sym
| :verb
| :x
Universal Dependencies POS tags.
Open Class Words (content)
:adj- Adjective:adv- Adverb:intj- Interjection:noun- Noun:propn- Proper noun:verb- Verb
Closed Class Words (function)
:adp- Adposition (preposition/postposition):aux- Auxiliary verb:cconj- Coordinating conjunction:det- Determiner:num- Numeral:part- Particle:pron- Pronoun:sconj- Subordinating conjunction
Other
:punct- Punctuation:sym- Symbol:x- Other (foreign words, typos, etc.)
Reference: https://universaldependencies.org/u/pos/
@type t() :: %Nasty.AST.Token{ language: Nasty.AST.Node.language(), lemma: String.t(), morphology: morphology(), pos_tag: pos_tag(), span: Nasty.AST.Node.span(), text: String.t() }
Functions
Checks if a POS tag is a content word (open class).
Examples
iex> Nasty.AST.Token.content_word?(:noun)
true
iex> Nasty.AST.Token.content_word?(:det)
false
Checks if a POS tag is a function word (closed class).
Examples
iex> Nasty.AST.Token.function_word?(:det)
true
iex> Nasty.AST.Token.function_word?(:noun)
false
@spec new( String.t(), pos_tag(), Nasty.AST.Node.language(), Nasty.AST.Node.span(), keyword() ) :: t()
Creates a new token.
Examples
iex> span = Nasty.AST.Node.make_span({1, 0}, 0, {1, 3}, 3)
iex> token = Nasty.AST.Token.new("cat", :noun, :en, span)
iex> token.text
"cat"
iex> token.pos_tag
:noun
@spec pos_tags() :: [pos_tag()]
Returns all supported Universal Dependencies POS tags.