I want to append the list of verbs extracted from spacy, to my spacy stopwords list. I extracted the verbs as you will see below.
However, they seem to be spacy.span.span
and this does not allow me to append them. Any ideas? I tried to convert them into a string but nothing happened.
import spacy # the libraries i have imported so far
import textacy
import en_core_web_sm
from spacy.lang.en.stop_words import STOP_WORDS
import string
punctuations = string.punctuation
stopwords = list(STOP_WORDS)
stopwords[:10]
nlp1=spacy.load("en_core_web_sm")
doc=nlp1(one)
sentences=list(doc.sents)
sentence=sentences[2]
patterns=[{'POS':'VERB'}] # extracting the verbs
verbs=textacy.extract.matches(doc, patterns=patterns)
for verb in verbs:
print(verb) # it prints all the verbs of my coprus.
#I want to achieve that. Append the extracted verbs to the list of stopwords.
for i in verb:
if i not in stopwords:
stopwords.append(i) # here is the error / bug
I receive the following error: spacy.span.span has no attribute str
Any suggestion would be appreciated
question from:
https://stackoverflow.com/questions/65937117/how-to-turn-the-spacy-span-span-to-string-in-order-to-append-the-verbs-extacted 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…