spacy-3

Spacy Regex "SyntaxError: invalid syntax"

Spacy Regex "SyntaxError: invalid syntax" Question: Hi everyone I am executing this code in Spacy to match with Regex, but I get an error: import spacy from spacy.matcher import Matcher nlp = spacy.load("en_core_web_md") doc1 = nlp("Hello hello hello, how are you?") doc2 = nlp("Hello, how are you?") doc3 = nlp("How are you?") pattern = [{"LOWER": …

Total answers: 1

Spacy add_alias, TypeError

Spacy add_alias, TypeError Question: MWE from spacy.kb import KnowledgeBase import spacy #kb.add_entity already called. nlp = spacy.blank("en") kb = KnowledgeBase(vocab=nlp.vocab, entity_vector_length=96) name = "test" qid = 1 # type(qid) => int kb.add_alias(alias=name.lower(), entities=[qid], probabilities=[1]) produces the error at the last line: TypeError: an integer is required A previous SO post suggested that the same error …

Total answers: 1

Can spacy's text categorizer learn the logic of recognizing two words in order?

Can spacy's text categorizer learn the logic of recognizing two words in order? Question: I’m trying to determine if Spacy’s text categorizer can learn a simple logic to detect the presence of two consecutive words in order: "jhon died". After training, for this experiment, the only results that matter are the output for the same …

Total answers: 1

Convert spaCy `Doc` into CoNLL 2003 sample

Convert spaCy `Doc` into CoNLL 2003 sample Question: I was planning to train a Spark NLP custom NER model, which uses the CoNLL 2003 format to do so (this blog even leaves some traning sample data to speed-up the follow-up). This "sample data" is NOT useful for me, as I have my own training data …

Total answers: 3

How to access span custom attributes with a variable name

How to access span custom attributes with a variable name Question: I am using spacy to categorize custom spans in documents. Then I create custom extension on the spans for every type of span. The example of the documentation is: from spacy.tokens import Span city_getter = lambda span: any(city in span.text for city in ("New …

Total answers: 1

Training spaCy model as a Vertex AI Pipeline "Component"

Training spaCy model as a Vertex AI Pipeline "Component" Question: I am trying to train a spaCy model , but turning the code into a Vertex AI Pipeline Component. My current code is: @component( packages_to_install=[ "setuptools", "wheel", "spacy[cuda113,transformers,lookups]", ], base_image="gcr.io/deeplearning-platform-release/base-cu113", output_component_file="train.yaml" ) def train(train_name: str, dev_name: str) -> NamedTuple("output", [("model_path", str)]): """ Trains a spacy …

Total answers: 3

How to I update my trained space ner model with new training dataset?

How to I update my trained space ner model with new training dataset? Question: I’m new to nlp, I started learning how to train the custom ner in spacy. TRAIN_DATA = [ (‘what is the price of polo?’, {‘entities’: [(21, 25, ‘Product’)]}), (‘what is the price of ball?’, {‘entities’: [(21, 25, ‘Product’)]}), (‘what is the …

Total answers: 1

Given a word can we get all possible lemmas for it using Spacy?

Given a word can we get all possible lemmas for it using Spacy? Question: The input word is standalone and not part of a sentence but I would like to get all of its possible lemmas as if the input word were in different sentences with all possible POS tags. I would also like to …

Total answers: 3