rkrstacic commited on
Commit
241b707
1 Parent(s): 4da38bc

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -9
app.py CHANGED
@@ -100,7 +100,6 @@ import tensorflow_hub as tfh
100
  import pandas as pd
101
  import numpy as np
102
  import seaborn as sns
103
- import matplotlib.pyplot as plt
104
 
105
  # Text preprocessor for bert based models
106
  preprocessor = tfh.KerasLayer('https://tfhub.dev/google/universal-sentence-encoder-cmlm/multilingual-preprocess/2')
@@ -123,10 +122,6 @@ data = data[data["process"] == trainedProcess].drop(columns="process")
123
  data['intent'] = data['intent'].astype('category')
124
  data['intent_codes'] = data['intent'].cat.codes
125
 
126
- # Display the distribution of codes
127
- values = data['intent'].value_counts()
128
- plt.stem(values)
129
-
130
  """#### Normalize data
131
 
132
  ### Text preprocessing
@@ -324,7 +319,7 @@ def getFlattenTasks(tasks) -> List[str]:
324
  def taskSimilarity(text: str, tasks) -> int:
325
  """ Returns the task index which is the most similar to the text """
326
  return getTaskSimilarityIndex(torch.argmax(util.pytorch_cos_sim(
327
- model.encode(text, convert_to_tensor=True),
328
  model.encode(getFlattenTasks(tasks), convert_to_tensor=True)
329
  )).item(), tasks)
330
 
@@ -419,13 +414,11 @@ def chatbot(input_text) -> None:
419
 
420
  """## Gradio app"""
421
 
422
- chatbot("Koliko traje predaja dnevnika prakse")
423
-
424
  iface = gr.Interface(
425
  fn=chatbot,
426
  inputs="text",
427
  outputs=["text"],
428
- title="Sentiment Analysis"
429
  )
430
 
431
  iface.launch()
 
100
  import pandas as pd
101
  import numpy as np
102
  import seaborn as sns
 
103
 
104
  # Text preprocessor for bert based models
105
  preprocessor = tfh.KerasLayer('https://tfhub.dev/google/universal-sentence-encoder-cmlm/multilingual-preprocess/2')
 
122
  data['intent'] = data['intent'].astype('category')
123
  data['intent_codes'] = data['intent'].cat.codes
124
 
 
 
 
 
125
  """#### Normalize data
126
 
127
  ### Text preprocessing
 
319
  def taskSimilarity(text: str, tasks) -> int:
320
  """ Returns the task index which is the most similar to the text """
321
  return getTaskSimilarityIndex(torch.argmax(util.pytorch_cos_sim(
322
+ model.encode(predictNER(text)["Task"], convert_to_tensor=True),
323
  model.encode(getFlattenTasks(tasks), convert_to_tensor=True)
324
  )).item(), tasks)
325
 
 
414
 
415
  """## Gradio app"""
416
 
 
 
417
  iface = gr.Interface(
418
  fn=chatbot,
419
  inputs="text",
420
  outputs=["text"],
421
+ title="Software module for answering questions on processes"
422
  )
423
 
424
  iface.launch()