7th August 2023

Post your solutions over here
07 Aug 2023
Share

Recent Comments

Furkan Mistry says:

import spacy
from collections import Counter

nlp = spacy.load("en_core_web_sm")

paragraph = """Various educators teach rules governing the length of paragraphs. They may say that a paragraph should be 100 to 200 words long, or be no more than five or six sentences. But a good paragraph should not be measured in characters, words, or sentences. The true measure of your paragraphs should be ideas."""

doc = nlp(paragraph)

verbs = []
adjectives = []

for token in doc:
if token.pos_ == 'VERB':
verbs.append(token.text)
elif token.pos_ == 'ADJ':
adjectives.append(token.text)

cverbs = Counter(verbs)
cadjectives = Counter(adjectives)

print("Verbs are :", verbs)
print("Adjectives are:", adjectives)

print("Count of occurence of verbs:", cverbs)
print("Count of occurence of adjective:", cadjectives)

print("Count of no of Verbs:", len(verbs))
print("Count of no of Adjectives:", len(adjectives))

search_word = input("enter a word to search ----> ")

if any(token.text.lower() == search_word.lower() for token in doc):
print("it is present")
else:
print("it is not present")

Leave a Comment