-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsense2.py
More file actions
34 lines (28 loc) · 1.04 KB
/
sense2.py
File metadata and controls
34 lines (28 loc) · 1.04 KB
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
from csense.parser.sentence import parse
from csense.mining.search import HeuristicSearch
from csense.mining.search import RelatednessSearch
from csense.mining.conceptnet import lookup
from csense.benchmark.cqa import getSplitDataSet
from concurrent.futures import ThreadPoolExecutor
import threading
import random
def parseQuestion(question):
candidates = []
answer = None
answerLabel = question['answerKey']
for choice in question['question']['choices']:
candidates.append(choice['text'])
if(choice['label'] == answerLabel):
answer = choice['text']
return (question['question']['stem'], candidates, answer)
def task(rawQuestion, index):
question, candidate, correctAnswer = parseQuestion(rawQuestion)
parsedSentence = parse(question, "WHERE", candidate)
print(parsedSentence)
dataset = getSplitDataSet()
questions = dataset["where"]
print(questions[7])
task(questions[7],7)
# for index in range(0, len(questions)):
# res = executor.submit(task, questions[index], index)
# futures.append(res)