When I enter this code results = [] import spacy from tqdm import tqdm Load the spaCy…
- User
When I enter this code results = [] import spacy from tqdm import tqdm
Load the spaCy model
nlp = spacy.load("en_core_web_lg")
Define the lists of lexical terms, verbs, modal verbs, adverbial phrases, and phrasal verbs
lexical_terms = ["Proposal", "Plan"] verbs = ["Propose", "Plan""] modal_verbs = ["Can", "Could"] adverbial_phrases = ["In the long run", "As a temporary measure" phrasal_verbs = ["Come up with", "Look into"]
Iterate through the sentences in your dataframe
for sentence in tqdm(df['sentence']): # Process the sentence with spaCy doc = nlp(sentence)
code# Extract entities and check if they match any of the lexical terms in your list for ent in doc.ents: if ent.text in lexical_terms: results.append(ent.text) # Extract verbs and check for token in doc: if token.text in verbs: # Extract the subject of the verb subj = [tok for tok in token.subtree if tok.dep_ == "nsubj"] if subj: results.append(subj[0].text, token.text) # Extract modal verbs and check if they match any of the modal verbs in your list for token in doc: if token.text in modal_verbs: # Extract the subject of the modal verb subj = [tok for tok in token.subtree if tok.dep_ == "nsubj"] if subj: results.append(subj[0].text, token.text) # Extract adverbial phrases and check if they match any of the adverbial phrases in your list for token in doc: if token.text in adverbial_phrases: # Extract the subject of the adverbial phrase subj = [tok for tok in token.subtree if tok.dep_ == "nsubj"] if subj: results.append(subj[0].text, token.text) # Extract phrasal verbs and check if they match any of the phrasal verbs in your list for token in doc: if token.text in phrasal_verbs: # Extract the subject of the phrasal verb subj = [tok for tok in token.subtree if tok.dep_ == "nsubj"] if subj: results.append(subj[0].text, token.text) Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.