-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpseudocode.py
47 lines (37 loc) · 1.17 KB
/
pseudocode.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
import requests
import spacy
def get_class(q):
# send request to NLPC to get result
pass
def get_entity(q, q_class, ner):
# extract named entity using spaCy
# may need branching to extract different
# entity for different class
pass
def get_info(keyword):
# search KB for keyword using elasticsearch
pass
if __name__ == '__main__':
# load spaCy model for entity extraction
ner = ...
# read input / classify using NLPC
q = input('Hello')
q_class = get_class(q)
while q_class != GOODBYE:
# branching for each possible class
if q_class == GREETING:
print('Hi')
if q_class == PREREQ:
# extract entity
class_num = get_entity(q, q_class, ner)
# search KB for info
class_info = get_info(keyword=class_num)
# format and output answer
print(class_info)
# other classes follow the same paradigm
if ...:
pass
# read input / classify using NLPC
q = input('Anything else I can help with?')
q_class = get_class(q)
print('Goodbye!')