class Spacy::Lexeme

See also spaCy Python API document for [`Lexeme`](spacy.io/api/lexeme).

Attributes

py_lexeme[R]

@return [Object] a Python `Lexeme` instance accessible via `PyCall`

text[R]

@return [String] a string representing the token

Public Class Methods

new(py_lexeme) click to toggle source

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

lang() click to toggle source

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
lower() click to toggle source

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
method_missing(name, *args) click to toggle source

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
norm() click to toggle source

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
prefix() click to toggle source

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
shape() click to toggle source

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
similarity(other) click to toggle source

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
suffix() click to toggle source

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
to_s() click to toggle source

String representation of the token. @return [String]

# File lib/ruby-spacy.rb, line 706
def to_s
  @text
end