jskim commited on
Commit
a6756ef
·
1 Parent(s): 2fad322

added text instruction and fixed phrase matching.

Browse files
Files changed (2) hide show
  1. app.py +11 -10
  2. score.py +17 -26
app.py CHANGED
@@ -150,8 +150,9 @@ def change_paper(selected_papers_radio):
150
 
151
  with gr.Blocks() as demo:
152
 
153
- # TODO Text description about the app and disclaimer
154
  ### TEXT Description
 
155
  gr.Markdown(
156
  """
157
  # Paper Matching Helper
@@ -160,21 +161,21 @@ This is a tool designed to help match an academic paper (submission) to a potent
160
  Below we describe how to use the tool. Also feel free to check out the [video]() for a more detailed rundown.
161
 
162
  ##### Input
163
- - The tool requires two inputs: (1) an academic paper's abstract in text format, (2) and a potential reviewer's [Semantic Scholar](https://www.semanticscholar.org/) profile link. Once you put in a valid profile link, the reviewer's name will be displayed.
164
- - Once the name is confirmed, press the "Search Similar Papers" button.
165
  ##### Search Similar Papers
166
  - Based on the input information above, the tool will search for similar papers from the reviewer's previous publications using [Semantic Scholar API](https://www.semanticscholar.org/product/api).
167
- - It will list top 10 similar papers along with the affinity score (ranging from 0 -1), computed using text representations from a [language model](https://github.com/allenai/specter/tree/master/specter).
168
  - You can click on different papers to see title, abstract, and affinity scores in detail.
169
  ##### Show Relevant Parts
170
- - Once you have retrieved the similar papers above, and selected a paper that you are interested in, you will have an option to see what parts of the selected paper may be relevant to the submission abstract. Click on the "Show Relevant Parts" button.
171
  - On the left, you will see individual sentences from the submission abstract you can select from.
172
- - On the right, you will see the abstract of the selected paper, with highlights.
173
- - <span style="color:red">Red</span> highlights: sentences from the reviewer's paper abstract with high semantic similarity to the selected sentence.
174
- - <span style="color:blue">Blue</span> highlights: matching phrases from the reviewer's paper abstract that is included in the selected sentence.
175
- - To see relevant parts in a different paper from the reviewer, select the paper above and re-click "Show Relevant Parts" to refresh.
176
 
177
- **Disclaimer.** This tool and its output should not serve as a sole justification for confirming a match for the submission. It is intended as a supplementary tool that the user may use at their discretion; the correctness of the output of the tool is not guaranteed. This may be improved by updating the internal models used to compute the affinity scores and sentence relevance, which may require additional research independently. The tool does not compromise the privacy of the reviewers as it relies only on their publicly-available information (e.g., names and list of previously published papers).
178
  """
179
  )
180
 
 
150
 
151
  with gr.Blocks() as demo:
152
 
153
+ # Text description about the app and disclaimer
154
  ### TEXT Description
155
+ # TODO add instruction video link
156
  gr.Markdown(
157
  """
158
  # Paper Matching Helper
 
161
  Below we describe how to use the tool. Also feel free to check out the [video]() for a more detailed rundown.
162
 
163
  ##### Input
164
+ - The tool requires two inputs: (1) an academic paper's abstract in a text format, (2) and a potential reviewer's [Semantic Scholar](https://www.semanticscholar.org/) profile link. Once you put in a valid profile link, the reviewer's name will be displayed.
165
+ - Once the name is confirmed, press the `Search Similar Papers from the Reviewer` button.
166
  ##### Search Similar Papers
167
  - Based on the input information above, the tool will search for similar papers from the reviewer's previous publications using [Semantic Scholar API](https://www.semanticscholar.org/product/api).
168
+ - It will list top 10 similar papers along with the **affinity scores** (ranging from 0 -1) for each, computed using text representations from a [language model](https://github.com/allenai/specter/tree/master/specter).
169
  - You can click on different papers to see title, abstract, and affinity scores in detail.
170
  ##### Show Relevant Parts
171
+ - Once you have retrieved the similar papers above, and selected a paper that you are interested in, you will have an option to see what parts of the selected paper may be relevant to the submission abstract. Click `Show Relevant Parts from Selected Paper` button.
172
  - On the left, you will see individual sentences from the submission abstract you can select from.
173
+ - On the right, you will see the abstract of the selected paper, with **highlights**.
174
+ - **<span style="color:black;background-color:#DB7262;">Red highlights</span>**: sentences from the reviewer's paper abstract with high semantic similarity to the selected sentence.
175
+ - **<span style="color:black;background-color:#5296D5;">Blue highlights</span>**: matching phrases from the reviewer's paper abstract that is included in the selected sentence.
176
+ - To see relevant parts in a different paper from the reviewer, select another paper above and re-click `Show Relevant Parts from Selected Paper` button to refresh.
177
 
178
+ **Disclaimer.** This tool and its output should not serve as the sole justification for confirming a match for the submission. It is intended as a supplementary tool that the user may use at their discretion; the correctness of the output of the tool is not guaranteed. This may be improved by updating the internal models used to compute the affinity scores and sentence relevance, which may require additional research independently. The tool does not compromise the privacy of the reviewers as it relies only on their publicly-available information (e.g., names and list of previously published papers).
179
  """
180
  )
181
 
score.py CHANGED
@@ -52,38 +52,29 @@ def get_words(sent):
52
  assert(len(sent_start_id) == len(sent))
53
  return words, all_words, sent_start_id
54
 
55
- def get_match_phrase(w1, w2):
56
  """
57
  Input: list of words for query and candidate text
58
  Output: word list and binary mask of matching phrases between the inputs
59
  """
60
- # POS tags that should be considered for matching phrase
61
- include = [
62
- 'JJ',
63
- 'JJR',
64
- 'JJS',
65
- 'MD',
66
- 'NN',
67
- 'NNS',
68
- 'NNP',
69
- 'NNPS',
70
- 'RB',
71
- 'RBR',
72
- 'RBS',
73
- 'SYM',
74
- 'VB',
75
- 'VBD',
76
- 'VBG',
77
- 'VBN',
78
- 'FW'
79
- ]
80
  mask1 = np.zeros(len(w1))
81
  mask2 = np.zeros(len(w2))
82
- pos1 = pos_tag(w1)
83
- pos2 = pos_tag(w2)
84
- for i, (w, p) in enumerate(pos2):
85
- if w.lower() in w1 and p in include:
86
- mask2[i] = 1
 
 
 
 
 
 
 
 
 
 
 
87
  return mask2
88
 
89
  def mark_words(query_sents, words, all_words, sent_start_id, sent_ids, sent_scores):
 
52
  assert(len(sent_start_id) == len(sent))
53
  return words, all_words, sent_start_id
54
 
55
+ def get_match_phrase(w1, w2, method='pos'):
56
  """
57
  Input: list of words for query and candidate text
58
  Output: word list and binary mask of matching phrases between the inputs
59
  """
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
60
  mask1 = np.zeros(len(w1))
61
  mask2 = np.zeros(len(w2))
62
+ if method == 'pos':
63
+ # POS tags that should be considered for matching phrase
64
+ include = [
65
+ 'NN',
66
+ 'NNS',
67
+ 'NNP',
68
+ 'NNPS',
69
+ 'LS',
70
+ 'SYM',
71
+ 'FW'
72
+ ]
73
+ pos1 = pos_tag(w1)
74
+ pos2 = pos_tag(w2)
75
+ for i, (w, p) in enumerate(pos2):
76
+ if w.lower() in w1 and p in include:
77
+ mask2[i] = 1
78
  return mask2
79
 
80
  def mark_words(query_sents, words, all_words, sent_start_id, sent_ids, sent_scores):