class Spacy::Lexeme
See also spaCy Python API document for [`Lexeme`](spacy.io/api/lexeme).
Attributes
@return [Object] a Python `Lexeme` instance accessible via `PyCall`
@return [String] a string representing the token
Public Class Methods
It is recommended to use {Language#vocab} or {Token#lexeme} methods to create tokens. There is no way to generate a lexeme from scratch but relying on a pre-exising Python {Lexeme} object. @param py_lexeme
[Object] Python `Lexeme` object
# File lib/ruby-spacy.rb, line 699 def initialize(py_lexeme) @py_lexeme = py_lexeme @text = @py_lexeme.text end
Public Instance Methods
Returns the language by calling `lang_' of `@py_lexeme` object @return [String]
# File lib/ruby-spacy.rb, line 724 def lang @py_lexeme.lang_ end
Returns the lowercase form by calling `lower_' of `@py_lexeme` object @return [String]
# File lib/ruby-spacy.rb, line 712 def lower @py_lexeme.lower_ end
Methods defined in Python but not wrapped in ruby-spacy can be called by this dynamic method handling mechanism.
# File lib/ruby-spacy.rb, line 754 def method_missing(name, *args) @py_lexeme.send(name, *args) end
Returns the lexemes's norm, i.e. a normalized form of the lexeme calling `norm_' of `@py_lexeme` object @return [String]
# File lib/ruby-spacy.rb, line 742 def norm @py_lexeme.norm_ end
Returns the length-N substring from the start of the word by calling `prefix_' of `@py_lexeme` object @return [String]
# File lib/ruby-spacy.rb, line 730 def prefix @py_lexeme.prefix_ end
Returns the shape (e.g. “Xxxxx”) by calling `shape_' of `@py_lexeme` object @return [String]
# File lib/ruby-spacy.rb, line 718 def shape @py_lexeme.shape_ end
Returns a semantic similarity estimate. @param other [Lexeme] the other doc to which a similarity estimation is made @return [Float]
# File lib/ruby-spacy.rb, line 749 def similarity(other) @py_lexeme.similarity(other.py_lexeme) end
Returns the length-N substring from the end of the word by calling `suffix_' of `@py_lexeme` object @return [String]
# File lib/ruby-spacy.rb, line 736 def suffix @py_lexeme.suffix_ end
String representation of the token. @return [String]
# File lib/ruby-spacy.rb, line 706 def to_s @text end