This repository has been archived by the owner on Oct 10, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbehavior_analyzer.py
163 lines (108 loc) · 4.41 KB
/
behavior_analyzer.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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
from tokenizer import *
import lexicon
class Behave:
# passive_list=[]
# excited_list=[]
# inquisitive_list=[]
def __init__(self, text):
self.tokenizer = Token(" ".join(text))
self.aggressiveDict = {}
self.passiveDict = {}
self.excitedDict = {}
self.inquisitiveDict = {}
self.tokenizer.words_are_tokenized(" ".join(text))
print(self.tokenizer.words_are_tokenized(" ".join(text)))
self.assign_aggressive_values(text)
print(self.assign_aggressive_values(text))
self.assign_passive_values(text)
print(self.assign_passive_values(text))
self.assign_excited_values(text)
print(self.assign_excited_values(text))
self.assign_inquisitive_values(text)
print(self.assign_inquisitive_values(text))
def input_is_list(self, phrase):
#"assures the input is not an empty string, and converts input into lower case"
text = phrase
return text
def assign_aggressive_values(self, phrase):
aggressive_list=[]
for item in phrase:
value = lexicon.aggressive_behavior.get(item, 0)
aggressive_list.append(value)
# Behave.aggressive_dictionary(self, aggressive_list)
aggressive_dict = {}
aggressive_nums = aggressive_list
aggressive_sum = sum(aggressive_nums)
aggressive_dict['aggressive'] = aggressive_sum # update existing entry
self.aggressiveDict = aggressive_dict
return aggressive_dict
def assign_passive_values(self, phrase):
passive_list=[]
for item in phrase:
value = lexicon.passive_behavior.get(item, 0)
passive_list.append(value)
passive_dict = {}
passive_nums = passive_list
passive_sum = sum(passive_nums)
passive_dict['passive'] = passive_sum # update existing entry
self.passiveDict = passive_dict
return passive_dict
def assign_excited_values(self,phrase):
excited_list=[]
for item in phrase:
value = lexicon.excited_behavior.get(item, 0)
excited_list.append(value)
excited_dict = {}
excited_nums = excited_list
excited_sum = sum(excited_nums)
excited_dict['excited'] = excited_sum # update existing entry
self.excitedDict = excited_dict
return excited_dict
def assign_inquisitive_values(self,phrase):
inquisitive_list=[]
for item in phrase:
value = lexicon.inquisitive_behavior.get(item, 0)
inquisitive_list.append(value)
inquisitive_dict = {}
inquisitive_nums = inquisitive_list
inquisitive_sum = sum(inquisitive_nums)
inquisitive_dict['inquisitive'] = inquisitive_sum # update existing entry
self.inquisitiveDict = inquisitive_dict
return inquisitive_dict
def spitBehavior(self, text):
if self.assign_aggressive_values(text) >= self.assign_passive_values(text):
print(self.assign_aggressive_values(text))
elif self.assign_passive_values(text) >= self.assign_aggressive_values(text):
print(self.assign_passive_values(text))
if self.assign_excited_values(text) >= self.assign_inquisitive_values(text):
print(self.assign_excited_values(text))
elif self.assign_inquisitive_values(text) >= self.assign_excited_values(text):
print(self.assign_inquisitive_values(text))
# def aggressive_dictionary(self,agro):
# aggressive_dict = {}
# aggressive_nums = agro
# aggressive_sum = sum(aggressive_nums)
# aggressive_dict['aggressive'] = aggressive_sum # update existing entry
# self.aggressiveDict = aggressive_dict
# return aggressive_dict
# def passive_dictionary(self,passive):
# passive_dict = {}
# passive_nums = passive
# passive_sum = sum(passive_nums)
# passive_dict['passive'] = passive_sum # update existing entry
# self.passiveDict = passive_dict
# return passive_dict
# def excited_dictionary(self,excited):
# excited_dict = {}
# excited_nums = excited
# excited_sum = sum(excited_nums)
# excited_dict['excited'] = excited_sum # update existing entry
# self.excitedDict = excited_dict
# return excited_dict
# def inquisitive_dictionary(self,inquisitive):
# inquisitive_dict = {}
# inquisitive_nums = inquisitive
# inquisitive_sum = sum(inquisitive_nums)
# inquisitive_dict['inquisitive'] = inquisitive_sum # update existing entry
# self.inquisitiveDict = inquisitive_dict
# return inquisitive_dict