Pendrokar commited on
Commit
11f2f1a
β€’
1 Parent(s): 1bea690

asterisk fix; DeepMoji: quotes confuse deepmoji

Browse files
resources/app/plugins/deepmoji_plugin/sentiment.py CHANGED
@@ -146,7 +146,9 @@ def fetch_text(data=None):
146
  prev_sentence += ' '
147
 
148
  # add previous sentence for a better flow
149
- text_scores = scoreText(prev_sentence + data["sequence"], emoji_count)
 
 
150
  logger.log(text_scores)
151
 
152
  text_scores[0] = data["sequence"]
@@ -201,6 +203,21 @@ def fetch_text_batch(data=None):
201
  # 'Emoji_1', 'Emoji_2', 'Emoji_3', 'Emoji_4', 'Emoji_5',
202
  # 'Pct_1', 'Pct_2', 'Pct_3', 'Pct_4', 'Pct_5'])
203
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
204
  def adjust_values(data=None):
205
  global root_path, os, csv, example_helper,\
206
  isBatch, isXVAPitch, isEnglish, logger, emoji_count, text_scores, plugin_settings,\
@@ -284,7 +301,7 @@ def adjust_values(data=None):
284
  )
285
  em_angry = em_angry if (em_angry == top_em) else 0
286
  em_happy = em_happy if (em_happy == top_em) else 0
287
- # amplified sadness ratio
288
  em_sad = (em_sad * 3) if (em_sad == top_em) else 0
289
 
290
  # amplifier
 
146
  prev_sentence += ' '
147
 
148
  # add previous sentence for a better flow
149
+ text_to_score = prev_sentence + data["sequence"]
150
+ text_to_score = clean_special_chars(text_to_score)
151
+ text_scores = scoreText(text_to_score, emoji_count)
152
  logger.log(text_scores)
153
 
154
  text_scores[0] = data["sequence"]
 
203
  # 'Emoji_1', 'Emoji_2', 'Emoji_3', 'Emoji_4', 'Emoji_5',
204
  # 'Pct_1', 'Pct_2', 'Pct_3', 'Pct_4', 'Pct_5'])
205
 
206
+ def clean_special_chars(text):
207
+ # quotemarks " can create problems for dict_replace
208
+ # remove the ones at start and end of text
209
+ if text.strip()[0]:\
210
+ text = text.replace("\"", "", 1)
211
+ if text.strip()[-1]:\
212
+ text = text[::-1].replace("\"", "", 1)[::-1]
213
+ # replace all others with a colon
214
+ text = text.replace("\"", ":")
215
+
216
+ # remove asterisks
217
+ text.replace("*","")
218
+
219
+ return text
220
+
221
  def adjust_values(data=None):
222
  global root_path, os, csv, example_helper,\
223
  isBatch, isXVAPitch, isEnglish, logger, emoji_count, text_scores, plugin_settings,\
 
301
  )
302
  em_angry = em_angry if (em_angry == top_em) else 0
303
  em_happy = em_happy if (em_happy == top_em) else 0
304
+ # amplified sadness ratio due to rareness of these emojis
305
  em_sad = (em_sad * 3) if (em_sad == top_em) else 0
306
 
307
  # amplifier
resources/app/plugins/deepmoji_plugin/xvasynth_torchmoji.py CHANGED
@@ -45,7 +45,6 @@ def scoreText(text, scalp_amount=5):
45
  print('Running predictions.')
46
  # text
47
  tokenized, _, _ = st.tokenize_sentences([text])
48
- print(tokenized)
49
  prob = model(tokenized)
50
 
51
  for prob in [prob]:
 
45
  print('Running predictions.')
46
  # text
47
  tokenized, _, _ = st.tokenize_sentences([text])
 
48
  prob = model(tokenized)
49
 
50
  for prob in [prob]:
resources/app/python/xvapitch/text/text_preprocessing.py CHANGED
@@ -428,7 +428,7 @@ class TextPreprocessor():
428
  text = text.replace("\"", ":")
429
 
430
  # remove asterisks
431
- text.replace("*","")
432
 
433
  return text
434
 
 
428
  text = text.replace("\"", ":")
429
 
430
  # remove asterisks
431
+ text = text.replace("*","")
432
 
433
  return text
434