JasonTPhillipsJr commited on
Commit
b8aeb00
1 Parent(s): fa29176

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -3
app.py CHANGED
@@ -112,7 +112,12 @@ def get_bert_embedding(review_text):
112
  #Get SpaBERT Embedding for geo-entity
113
  def get_spaBert_embedding(entity):
114
  entity_index = entity_index_dict.get(entity.lower(), None)
115
- return spaBERT_embeddings[entity_index]
 
 
 
 
 
116
 
117
  #Go through each review, identify all geo-entities, then extract their SpaBERT embedings
118
  def processSpatialEntities(review, nlp):
@@ -123,8 +128,8 @@ def processSpatialEntities(review, nlp):
123
  # Iterate over each entity span and process only geo entities
124
  for start, end, text, label in entity_spans:
125
  if label in ['FAC', 'ORG', 'LOC', 'GPE']: # Filter to geo-entities
126
- #spaBert_emb = get_spaBert_embedding(text)
127
- #token_embeddings.append((text, spaBert_emb))
128
  st.write("Geo-Entity Found in review: ", text)
129
  return token_embeddings
130
 
 
112
  #Get SpaBERT Embedding for geo-entity
113
  def get_spaBert_embedding(entity):
114
  entity_index = entity_index_dict.get(entity.lower(), None)
115
+ if entity_index is None:
116
+ st.write("Got Bert embedding for: ", entity)
117
+ return get_bert_embedding(text)
118
+ else:
119
+ st.write("Got SpaBert embedding for: ", entity)
120
+ return spaBERT_embeddings[entity_index]
121
 
122
  #Go through each review, identify all geo-entities, then extract their SpaBERT embedings
123
  def processSpatialEntities(review, nlp):
 
128
  # Iterate over each entity span and process only geo entities
129
  for start, end, text, label in entity_spans:
130
  if label in ['FAC', 'ORG', 'LOC', 'GPE']: # Filter to geo-entities
131
+ spaBert_emb = get_spaBert_embedding(text)
132
+ token_embeddings.append((text, spaBert_emb))
133
  st.write("Geo-Entity Found in review: ", text)
134
  return token_embeddings
135