-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsmile
More file actions
executable file
·32 lines (24 loc) · 712 Bytes
/
smile
File metadata and controls
executable file
·32 lines (24 loc) · 712 Bytes
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
#!/usr/bin/env python3
import os
import sys
from analyzer import Analyzer
from termcolor import colored
def main():
# ensure proper usage
if len(sys.argv) != 2:
sys.exit("Usage: ./smile word")
# absolute paths to lists
positives = os.path.join(sys.path[0], "positive-words.txt")
negatives = os.path.join(sys.path[0], "negative-words.txt")
# instantiate analyzer
analyzer = Analyzer(positives, negatives)
# analyze word
score = analyzer.analyze(sys.argv[1])
if score > 0.0:
print(colored(":)", "green"))
elif score < 0.0:
print(colored(":(", "red"))
else:
print(colored(":|", "yellow"))
if __name__ == "__main__":
main()