Texnologiyalari universiteti “Ma'lumotlarning intellektual tahlili” fani Mustaqil ish Mavzu


Download 1.35 Mb.
bet3/15
Sana23.04.2023
Hajmi1.35 Mb.
#1388517
1   2   3   4   5   6   7   8   9   ...   15
Bog'liq
Pochta xabarlarini intellectual

from textblob import TextBlob
def analyze_sentiment(text):
blob = TextBlob(text)
sentiment = blob.sentiment.polarity
if sentiment > 0:
return 'positive'
elif sentiment < 0:
return 'negative'
else:
return 'neutral'
# Example Usage:
text = "I am happy to inform you that we have approved your request."
sentiment = analyze_sentiment(text)
print(sentiment) # Output: positive
-------------------------------------------------
import spacy
nlp = spacy.load("en_core_web_sm")
def extract_entities(text):
doc = nlp(text)
entities = []
for ent in doc.ents:
entities.append((ent.text, ent.label_))
return entities
# Example Usage:
text = "Please send the report to John Smith at john.smith@example.com."
entities = extract_entities(text)
print(entities) # Output: [('John Smith', 'PERSON'), ('john.smith@example.com', 'EMAIL')]
from gensim import corpora, models
def perform_topic_modeling(texts, num_topics=5, num_words=5):
dictionary = corpora.Dictionary(texts)
corpus = [dictionary.doc2bow(text) for text in texts]
lda = models.LdaModel(corpus, num_topics=num_topics, id2word=dictionary)
topics = lda.print_topics(num_topics=num_topics, num_words=num_words)
return topics
# Example Usage:
texts = ["We need to finalize the proposal by the end of the week.",
"Can you please provide an update on the project status?",

Download 1.35 Mb.

Do'stlaringiz bilan baham:
1   2   3   4   5   6   7   8   9   ...   15




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling