Greg Thompson commited on
Commit
a61d64f
1 Parent(s): ee60b4d

Update nlu keyword commands and message filtering

Browse files
Files changed (2) hide show
  1. mathtext_fastapi/nlu.py +12 -12
  2. scripts/make_request.py +29 -24
mathtext_fastapi/nlu.py CHANGED
@@ -107,6 +107,16 @@ def run_intent_classification(message_text):
107
  'hint',
108
  'next',
109
  'stop',
 
 
 
 
 
 
 
 
 
 
110
  ]
111
 
112
  for command in commands:
@@ -132,19 +142,9 @@ def evaluate_message_with_nlu(message_data):
132
  """
133
  # Keeps system working with two different inputs - full and filtered @event object
134
  try:
135
- message_text = str(message_data['message_body'])
136
  except KeyError:
137
- message_data = {
138
- 'author_id': message_data['message']['_vnd']['v1']['chat']['owner'],
139
- 'author_type': message_data['message']['_vnd']['v1']['author']['type'],
140
- 'contact_uuid': message_data['message']['_vnd']['v1']['chat']['contact_uuid'],
141
- 'message_body': message_data['message']['text']['body'],
142
- 'message_direction': message_data['message']['_vnd']['v1']['direction'],
143
- 'message_id': message_data['message']['id'],
144
- 'message_inserted_at': message_data['message']['_vnd']['v1']['chat']['inserted_at'],
145
- 'message_updated_at': message_data['message']['_vnd']['v1']['chat']['updated_at'],
146
- }
147
- message_text = str(message_data['message_body'])
148
 
149
  # Run intent classification only for keywords
150
  intent_api_response = run_intent_classification(message_text)
 
107
  'hint',
108
  'next',
109
  'stop',
110
+ 'tired',
111
+ 'tomorrow',
112
+ 'finished',
113
+ 'help',
114
+ 'please',
115
+ 'understand',
116
+ 'question',
117
+ 'easier',
118
+ 'easy',
119
+ 'support'
120
  ]
121
 
122
  for command in commands:
 
142
  """
143
  # Keeps system working with two different inputs - full and filtered @event object
144
  try:
145
+ message_text = str(message_data.get('message_body', ''))
146
  except KeyError:
147
+ message_text = ''
 
 
 
 
 
 
 
 
 
 
148
 
149
  # Run intent classification only for keywords
150
  intent_api_response = run_intent_classification(message_text)
scripts/make_request.py CHANGED
@@ -64,32 +64,37 @@ def run_simulated_request(endpoint, sample_answer, context=None):
64
 
65
  # run_simulated_request('intent-classification', 'exit')
66
  # run_simulated_request('intent-classification', "I'm not sure")
67
- run_simulated_request('intent-classification', "easier")
68
- run_simulated_request('intent-classification', "easy")
69
- run_simulated_request('intent-classification', "harder")
70
- run_simulated_request('intent-classification', "hard")
71
- run_simulated_request('intent-classification', "hint")
72
- run_simulated_request('intent-classification', "hin")
73
- run_simulated_request('intent-classification', "hnt")
74
- run_simulated_request('intent-classification', "stop")
75
- run_simulated_request('intent-classification', "stp")
76
- run_simulated_request('intent-classification', "sop")
77
- run_simulated_request('intent-classification', "please stop")
78
  # run_simulated_request('sentiment-analysis', 'I reject it')
79
  # run_simulated_request('text2int', 'seven thousand nine hundred fifty seven')
80
- # run_simulated_request('nlu', 'test message')
81
- # run_simulated_request('nlu', 'eight')
82
- # run_simulated_request('nlu', 'is it 8')
83
- # run_simulated_request('nlu', 'can I know how its 0.5')
84
- # run_simulated_request('nlu', 'eight, nine, ten')
85
- # run_simulated_request('nlu', '8, 9, 10')
86
- # run_simulated_request('nlu', '8')
87
- # run_simulated_request('nlu', "I don't know")
88
- # run_simulated_request('nlu', "I don't know eight")
89
- # run_simulated_request('nlu', "I don't 9")
90
- # run_simulated_request('nlu', "0.2")
91
- # run_simulated_request('nlu', 'Today is a wonderful day')
92
- # run_simulated_request('nlu', 'IDK 5?')
 
 
 
 
 
93
  # run_simulated_request('manager', '')
94
  # run_simulated_request('manager', 'add')
95
  # run_simulated_request('manager', 'subtract')
 
64
 
65
  # run_simulated_request('intent-classification', 'exit')
66
  # run_simulated_request('intent-classification', "I'm not sure")
67
+ # run_simulated_request('intent-classification', "easier")
68
+ # run_simulated_request('intent-classification', "easy")
69
+ # run_simulated_request('intent-classification', "harder")
70
+ # run_simulated_request('intent-classification', "hard")
71
+ # run_simulated_request('intent-classification', "hint")
72
+ # run_simulated_request('intent-classification', "hin")
73
+ # run_simulated_request('intent-classification', "hnt")
74
+ # run_simulated_request('intent-classification', "stop")
75
+ # run_simulated_request('intent-classification', "stp")
76
+ # run_simulated_request('intent-classification', "sop")
77
+ # run_simulated_request('intent-classification', "please stop")
78
  # run_simulated_request('sentiment-analysis', 'I reject it')
79
  # run_simulated_request('text2int', 'seven thousand nine hundred fifty seven')
80
+ run_simulated_request('nlu', 'test message')
81
+ run_simulated_request('nlu', 'eight')
82
+ run_simulated_request('nlu', 'is it 8')
83
+ run_simulated_request('nlu', 'can I know how its 0.5')
84
+ run_simulated_request('nlu', 'eight, nine, ten')
85
+ run_simulated_request('nlu', '8, 9, 10')
86
+ run_simulated_request('nlu', '8')
87
+ run_simulated_request('nlu', "I don't know")
88
+ run_simulated_request('nlu', "I don't know eight")
89
+ run_simulated_request('nlu', "I don't 9")
90
+ run_simulated_request('nlu', "0.2")
91
+ run_simulated_request('nlu', 'Today is a wonderful day')
92
+ run_simulated_request('nlu', 'IDK 5?')
93
+ run_simulated_request('nlu', 'hin')
94
+ run_simulated_request('nlu', 'exi')
95
+ run_simulated_request('nlu', 'easier')
96
+ run_simulated_request('nlu', 'stp')
97
+ run_simulated_request('nlu', '')
98
  # run_simulated_request('manager', '')
99
  # run_simulated_request('manager', 'add')
100
  # run_simulated_request('manager', 'subtract')