Module: Spacy
- Defined in:
- lib/ruby-spacy.rb,
lib/ruby-spacy/version.rb,
lib/ruby-spacy/openai_client.rb,
lib/ruby-spacy/openai_helper.rb
Overview
This module covers the areas of spaCy functionality for using many varieties of its language models, not for building ones.
Defined Under Namespace
Classes: Doc, Language, Lexeme, Matcher, OpenAIClient, OpenAIHelper, PhraseMatcher, Span, Token
Constant Summary collapse
- MAX_RETRIAL =
5- Builtins =
PyCall.import_module("builtins")
- SpacyVersion =
spacy.__version__
- PyLanguage =
Python
Languageclass spacy.language.Language
- PyDoc =
Python
Docclass object spacy.tokens.Doc
- PySpan =
Python
Spanclass object spacy.tokens.Span
- PyToken =
Python
Tokenclass object spacy.tokens.Token
- PyMatcher =
Python
Matcherclass object spacy.matcher.Matcher
- PyPhraseMatcher =
Python
PhraseMatcherclass object spacy.matcher.PhraseMatcher
- PyDisplacy =
Python
displacyobject PyCall.import_module('spacy.displacy')
- VERSION =
The version number of the module
"0.4.0"
Class Method Summary collapse
-
.generator_to_array(py_generator) ⇒ Object
A utility module method to convert Python’s generator object to a Ruby array, mainly used on the items inside the array returned from dependency-related methods such as Span#rights, Span#lefts and Span#subtree.
-
.py_hasattr?(py_obj, attr) ⇒ Boolean
Checks if a Python object has a given attribute using builtins.hasattr.
Class Method Details
.generator_to_array(py_generator) ⇒ Object
A utility module method to convert Python’s generator object to a Ruby array, mainly used on the items inside the array returned from dependency-related methods such as Spacy::Span#rights, Spacy::Span#lefts and Spacy::Span#subtree.
53 54 55 |
# File 'lib/ruby-spacy.rb', line 53 def self.generator_to_array(py_generator) PyCall::List.call(py_generator) end |
.py_hasattr?(py_obj, attr) ⇒ Boolean
Checks if a Python object has a given attribute using builtins.hasattr. Falls back to true if the check itself fails (e.g. due to PyCall issues).
62 63 64 65 66 |
# File 'lib/ruby-spacy.rb', line 62 def self.py_hasattr?(py_obj, attr) Builtins.hasattr(py_obj, attr.to_s) rescue StandardError true end |