Skip to content

Instantly share code, notes, and snippets.

View karthikavijayanexpts's full-sized avatar

karthikavijayanexpts

View GitHub Profile
@karthikavijayanexpts
karthikavijayanexpts / compound_to_simple.py
Created May 31, 2022 09:56
Splitting compound sentences to a set of simple sentences using spaCy package
import spacy
nlp = spacy.load('en_core_web_md')
def compound_to_simple(sentence):
doc = nlp(sentence)
root_token = None
for token in doc:
if (token.dep_ == "ROOT"):
root_token = token
@karthikavijayanexpts
karthikavijayanexpts / corefResolve.py
Created May 31, 2022 09:52
Coreference resolution using coreferee and spaCy packages
import spacy
import coreferee
def coref_resolve(text):
nlp1 = spacy.load('en_core_web_trf')
nlp1.add_pipe('coreferee')
doc1 = nlp1(text)
tok_list = list(token.text for token in doc1)
c = 0
for chain in doc1._.coref_chains: