aisafe commited on
Commit
6654499
1 Parent(s): 16ef5db

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +30 -10
app.py CHANGED
@@ -20,7 +20,9 @@ from tenacity import retry
20
  from tqdm import tqdm
21
  import tiktoken
22
  import scipy.stats
 
23
  import torch
 
24
  from transformers import GPT2LMHeadModel
25
  import tiktoken
26
  import seaborn as sns
@@ -28,6 +30,24 @@ from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
28
  # from colorama import Fore, Style
29
  import openai # for OpenAI API calls
30
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
31
  ######################################
32
  import streamlit as st
33
  def colorize_tokens(token_data, sentence):
@@ -50,16 +70,16 @@ def colorize_tokens(token_data, sentence):
50
 
51
  # Define colors for the tags
52
  tag_colors = {
53
- "ADJP": "#0000FF", # Blue
54
- "ADVP": "#008000", # Green
55
- "CONJP": "#FF0000", # Red
56
- "INTJ": "#00FFFF", # Cyan
57
- "LST": "#FF00FF", # Magenta
58
- "NP": "#FFFF00", # Yellow
59
- "PP": "#800080", # Purple
60
- "PRT": "#00008B", # Dark Blue
61
- "SBAR": "#006400", # Dark Green
62
- "VP": "#008B8B", # Dark Cyan
63
  }
64
  ##################
65
 
 
20
  from tqdm import tqdm
21
  import tiktoken
22
  import scipy.stats
23
+ import inseq
24
  import torch
25
+ from transformers import AutoModelForCausalLM
26
  from transformers import GPT2LMHeadModel
27
  import tiktoken
28
  import seaborn as sns
 
30
  # from colorama import Fore, Style
31
  import openai # for OpenAI API calls
32
 
33
+ ######################################
34
+ def find_indices(arr, target):
35
+ indices = []
36
+ start_index = None
37
+
38
+ for i, element in enumerate(arr):
39
+ if target in element:
40
+ if start_index is None:
41
+ start_index = i
42
+ else:
43
+ indices.append((start_index, i - 1))
44
+ start_index = i
45
+
46
+ if start_index is not None:
47
+ indices.append((start_index, len(arr) - 1))
48
+
49
+ return indices
50
+
51
  ######################################
52
  import streamlit as st
53
  def colorize_tokens(token_data, sentence):
 
70
 
71
  # Define colors for the tags
72
  tag_colors = {
73
+ "ADJP": "#8F6B9F", # Blue
74
+ "ADVP": "#7275A7", # Green
75
+ "CONJP": "#5BA4BB", # Red
76
+ "INTJ": "#95CA73", # Cyan
77
+ "LST": "#DFDA70", # Magenta
78
+ "NP": "#EFBC65", # Yellow
79
+ "PP": "#FC979B", # Purple
80
+ "PRT": "#F1C5C1", # Dark Blue
81
+ "SBAR": "#FAEBE8", # Dark Green
82
+ "VP": "#90DFD2", # Dark Cyan
83
  }
84
  ##################
85