Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update main.py #5

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Elastic/addIndex.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

docType = "doc"
# by default we connect to localhost:9200
es = Elasticsearch(['https://5e9acbee.ngrok.io/'])
es = Elasticsearch(['http://node1.research.tib.eu:9200/'])
path_to_data = '/app/'
# path_to_data = '../'

Expand Down
14 changes: 5 additions & 9 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@


nlp = spacy.load('en_core_web_sm')
#wikidataSPARQL="https://17d140f2.ngrok.io/sparql"
wikidataSPARQL="http://node3.research.tib.eu:4010/sparql"

stopWordsList=wiki_stopwords.getStopWords()
Expand Down Expand Up @@ -470,9 +469,8 @@ def split_base_on_s(combinations):
result.append(comb)
return result

def process_word_E_long(question):
def process_word_E_long(question, k=1):
global count
k=1

entities=[]

Expand Down Expand Up @@ -518,11 +516,10 @@ def process_word_E_long(question):
results.append(entity)
return [[entity[1],entity[4]] for entity in results]

def process_word_E(question):
def process_word_E(question,k=1):
#print(question)
startTime=time.time()
global count
k=1

entities=[]
question=question.replace("?","")
Expand All @@ -546,7 +543,7 @@ def process_word_E(question):
return [[entity[1],entity[2]] for entity in entities]

def process_text_E_R(question,k=1):
raw=evaluate([question])
raw=evaluate([question],k)
#time=raw[1]
#print(raw)
question=question.replace("?","")
Expand Down Expand Up @@ -592,7 +589,7 @@ def split_bas_on_comparison(combinations):
return new_comb,compare_found


def evaluate(raw):
def evaluate(raw,k):
<<<<<<< HEAD
evaluation=False
startTime=time.time()
Expand All @@ -611,7 +608,6 @@ def evaluate(raw):
r_entity=0
p_relation=0
r_relation=0
k=1
correct=True
questionRelationsNumber=0
entities=[]
Expand Down Expand Up @@ -830,7 +826,7 @@ def datasets_evaluate(dataset_file):

if __name__ == '__main__':
#datasets_evaluate()
process_text_E_R('What is the operating income for Qantas?')
process_text_E_R('What is the operating income for Qantas?', 5)