GRAMMAR CHECKER

IFRAME SYNC import spacy def grammar_checker(text): # Load the spaCy English model nlp = spacy.load("en_core_web_sm") # Process the input text doc = nlp(text) # Check for grammar issues grammar_issues = [] for sent in doc.sents: for token in sent: if token.pos_ in ["PRON", "VERB", "ADJ", "ADV"] and token.dep_ in ["nsubj", "attr", "prep"]: # Example: Check for common issues with pronouns, verbs, adjectives, and adverbs if token.text.lower() == "your": grammar_issues.append(f"Possible grammar issue: Use 'you're' instead of 'your' in '{sent.text}'.") return grammar_issues # Example usage text_to_check = "Your going to the store." issues = grammar_checker(text_to_check) if issues: for issue in issues: print(issue) else: print("No grammar issues found.")import spacy from spacy import displacy from gingerit.gingerit import GingerIt def grammar_checker(text): # Load the spaCy English model nlp = spacy.load("en_core_web_sm") # Process the input text doc = nlp(text) # Use GingerIt for more grammar suggestions ginger_parser = GingerIt() grammar_issues = [] for sent in doc.sents: for token in sent: # Check for common issues with pronouns, verbs, adjectives, and adverbs if token.pos_ in ["PRON", "VERB", "ADJ", "ADV"] and token.dep_ in ["nsubj", "attr", "prep"]: if token.text.lower() == "your": grammar_issues.append( f"Possible grammar issue: Use 'you're' instead of 'your' in '{sent.text}'." ) # Use GingerIt for additional suggestions ginger_results = ginger_parser.parse(text) if ginger_results["corrections"]: grammar_issues.append("Grammar suggestions from GingerIt:") grammar_issues.extend(ginger_results["corrections"]) return grammar_issues # Example usage text_to_check = "Your going to the store. Its a beautiful day." issues = grammar_checker(text_to_check) if issues: for issue in issues: print(issue) else: print("No grammar issues found.") IFRAME SYNC

Comments