Spaces:
Runtime error
Runtime error
adding time info
Browse files
app.py
CHANGED
|
@@ -6,6 +6,7 @@ import pickle
|
|
| 6 |
import nltk
|
| 7 |
nltk.download('punkt') # tokenizer
|
| 8 |
nltk.download('averaged_perceptron_tagger') # postagger
|
|
|
|
| 9 |
|
| 10 |
from input_format import *
|
| 11 |
from score import *
|
|
@@ -28,7 +29,8 @@ def get_similar_paper(
|
|
| 28 |
author_id_input,
|
| 29 |
num_papers_show=10
|
| 30 |
):
|
| 31 |
-
print('retrieving similar papers')
|
|
|
|
| 32 |
input_sentences = sent_tokenize(abstract_text_input)
|
| 33 |
|
| 34 |
# TODO handle pdf file input
|
|
@@ -41,7 +43,7 @@ def get_similar_paper(
|
|
| 41 |
name, papers = get_text_from_author_id(author_id_input)
|
| 42 |
|
| 43 |
# Compute Doc-level affinity scores for the Papers
|
| 44 |
-
print('computing scores')
|
| 45 |
titles, abstracts, doc_scores = compute_document_score(
|
| 46 |
doc_model,
|
| 47 |
tokenizer,
|
|
@@ -63,7 +65,8 @@ def get_similar_paper(
|
|
| 63 |
doc_scores = doc_scores[:num_papers_show]
|
| 64 |
|
| 65 |
display_title = ['[ %0.3f ] %s'%(s, t) for t, s in zip(titles, doc_scores)]
|
| 66 |
-
|
|
|
|
| 67 |
|
| 68 |
return (
|
| 69 |
gr.update(choices=display_title, interactive=True, visible=True), # set of papers
|
|
@@ -79,7 +82,8 @@ def get_highlights(
|
|
| 79 |
abstract,
|
| 80 |
K=2
|
| 81 |
):
|
| 82 |
-
print('obtaining highlights')
|
|
|
|
| 83 |
# Compute sent-level and phrase-level affinity scores for each papers
|
| 84 |
sent_ids, sent_scores, info = get_highlight_info(
|
| 85 |
sent_model,
|
|
@@ -105,7 +109,8 @@ def get_highlights(
|
|
| 105 |
'highlight': word_scores
|
| 106 |
}
|
| 107 |
pickle.dump(tmp, open('highlight_info.pkl', 'wb'))
|
| 108 |
-
|
|
|
|
| 109 |
|
| 110 |
# update the visibility of radio choices
|
| 111 |
return gr.update(visible=True)
|
|
|
|
| 6 |
import nltk
|
| 7 |
nltk.download('punkt') # tokenizer
|
| 8 |
nltk.download('averaged_perceptron_tagger') # postagger
|
| 9 |
+
import time
|
| 10 |
|
| 11 |
from input_format import *
|
| 12 |
from score import *
|
|
|
|
| 29 |
author_id_input,
|
| 30 |
num_papers_show=10
|
| 31 |
):
|
| 32 |
+
print('retrieving similar papers...')
|
| 33 |
+
start = time.time()
|
| 34 |
input_sentences = sent_tokenize(abstract_text_input)
|
| 35 |
|
| 36 |
# TODO handle pdf file input
|
|
|
|
| 43 |
name, papers = get_text_from_author_id(author_id_input)
|
| 44 |
|
| 45 |
# Compute Doc-level affinity scores for the Papers
|
| 46 |
+
print('computing scores...')
|
| 47 |
titles, abstracts, doc_scores = compute_document_score(
|
| 48 |
doc_model,
|
| 49 |
tokenizer,
|
|
|
|
| 65 |
doc_scores = doc_scores[:num_papers_show]
|
| 66 |
|
| 67 |
display_title = ['[ %0.3f ] %s'%(s, t) for t, s in zip(titles, doc_scores)]
|
| 68 |
+
end = time.time()
|
| 69 |
+
print('retrieval complete in [%0.2f] seconds'%(end - start))
|
| 70 |
|
| 71 |
return (
|
| 72 |
gr.update(choices=display_title, interactive=True, visible=True), # set of papers
|
|
|
|
| 82 |
abstract,
|
| 83 |
K=2
|
| 84 |
):
|
| 85 |
+
print('obtaining highlights..')
|
| 86 |
+
start = time.time()
|
| 87 |
# Compute sent-level and phrase-level affinity scores for each papers
|
| 88 |
sent_ids, sent_scores, info = get_highlight_info(
|
| 89 |
sent_model,
|
|
|
|
| 109 |
'highlight': word_scores
|
| 110 |
}
|
| 111 |
pickle.dump(tmp, open('highlight_info.pkl', 'wb'))
|
| 112 |
+
end = time.time()
|
| 113 |
+
print('done in [%0.2f] seconds'%(end - start))
|
| 114 |
|
| 115 |
# update the visibility of radio choices
|
| 116 |
return gr.update(visible=True)
|