-
Notifications
You must be signed in to change notification settings - Fork 1
/
sentence-deconstructor.py
102 lines (92 loc) · 3.03 KB
/
sentence-deconstructor.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
from src.app.spo.SPODetector import SPO
from src.app.alliteration.AlliterationDetector import Alliteration
from src.app.tone.ToneAnalyzer import display_tones, detect_tone
from src.app.tense.TenseDetector import tenseDetection
from src.app.simile.SimileDetector import detect_similes
import os
import pandas as pd
import numpy as np
import sys
import nltk
import time
# from ToneAnalyzer import
if __name__ == "__main__":
# nltk.download("stopwords")
# time.sleep(5)
os.system("CLS")
print("Welcome to the Sentence Deconstructor!")
print("----------------------------------------")
print()
text = input("Enter your sentence: ")
while True:
os.system("CLS")
print("Welcome to the Sentence Deconstructor!")
print("----------------------------------------")
print("\nSentence:", text)
print()
print("Menu")
print("1.\t Detect SPO")
print("2.\t Detect Alliterations")
print("3.\t Detect Tense")
print("4.\t Detect Tone")
print("5.\t Detect Similes")
print("6.\t Change Input")
print("7.\t Exit")
print()
try:
choice = int(input("Enter your choice: "))
except:
print("Invalid choice. Please enter again.")
time.sleep(1)
continue
if choice == 1:
spo = SPO(text)
spo.detect_svo()
spo.display_spo()
print("\n")
moveon = input("Press any key to return to Menu")
time.sleep(1)
elif choice == 2:
print("\nSentence:", text)
# print()
allit = Alliteration(text)
alliterations = allit.detect_alliterations()
allit.display_alliterations()
moveon = input("Press any key to return to Menu")
time.sleep(1)
elif choice == 3:
print("\nSentence:", text)
# print()
tense = tenseDetection(text)
print("Tense:", tense)
print("\n")
moveon = input("Press any key to return to Menu")
time.sleep(1)
elif choice == 4:
tone = detect_tone(text)
# print(tone)
display_tones(text, tone)
print("\n")
moveon = input("Press any key to return to Menu")
time.sleep(1)
elif choice == 5:
text = text.rstrip()
val, similes = detect_similes(text)
if val == 0:
print("No Similes Found!")
else:
print("Similes:")
for i in similes:
print(i)
print()
moveon = input("Press any key to return to Menu")
time.sleep(1)
elif choice == 6:
print()
text = input("Enter new sentence: ")
time.sleep(1)
elif choice == 7:
exit(0)
else:
print("Invalid Choice. Please enter again.")
time.sleep(1)