-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
30 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
nlp_module = NaturalLanguageProcessingModule() | ||
|
||
# Train the model | ||
X_train = [ | ||
"This product is amazing!", | ||
"I love this product!", | ||
"This product is terrible.", | ||
"I hate this product.", | ||
"This product is okay.", | ||
"I'm neutral about this product." | ||
] | ||
y_train = [1, 1, 0, 0, 0.5, 0.5] # 1: positive, 0: negative, 0.5: neutral | ||
|
||
nlp_module.train(X_train, y_train) | ||
|
||
# Predict sentiment | ||
text = "This is a great product!" | ||
sentiment = nlp_module.sentiment_analysis(text) | ||
print("Sentiment:", sentiment) | ||
|
||
# Predict topics | ||
texts = [ | ||
"I love playing basketball.", | ||
"The new iPhone is amazing.", | ||
"I'm so excited for the summer.", | ||
"This restaurant serves great food.", | ||
"I'm feeling sad today." | ||
] | ||
topics = nlp_module.topic_modeling(texts) | ||
print("Topics:", topics) |