@@ -18,6 +18,7 @@ def compute_stopwords(
1818):
1919 if remove_stopwords :
2020 dataset_to_filter = sampled_data .copy ()
21+
2122 dataset_to_filter [column_name ] = remove_stopwords_from_column (
2223 dataset_to_filter [column_name ], dataset_language , custom_stopwords
2324 )
@@ -40,7 +41,7 @@ def compute_embeddings(
4041 my_bar = progress_bar .progress (0 )
4142 with streamlit .spinner (":hourglass: Loading language model..." ):
4243 lang = load_languages (embedding_language , languages_dict )
43-
44+ uuid_series = df . labelling_uuid
4445 temp_datasets = np .array_split (df , 100 )
4546 with streamlit .spinner (":hourglass: Computing embeddings..." ):
4647
@@ -63,20 +64,23 @@ def compute_embeddings(
6364 df = (
6465 get_embeddingset (embarray_encoding , embarray_texts ).to_dataframe ().reset_index ()
6566 )
67+ df ['labelling_uuid' ]= uuid_series
6668 return df
6769
6870
6971def compute_dimension_reduction (df , transformer_option , transformers_dict ):
7072 with streamlit .spinner (":hourglass: Reducing embedding dimensions..." ):
7173 transformer = load_transformer (transformer_option , transformers_dict )
72- embarray_encoding = df .drop (columns = "index" ).values
74+ uuid_series = df .labelling_uuid
75+ embarray_encoding = df .drop (columns = ["index" ,"labelling_uuid" ]).values
7376 embarray_texts = df ["index" ]
7477 embedding_df = (
7578 get_embeddingset (embarray_encoding , embarray_texts )
7679 .transform (transformer )
7780 .to_dataframe ()
7881 .reset_index ()
7982 )
83+ embedding_df ['labelling_uuid' ]= uuid_series
8084 return embedding_df
8185
8286
@@ -102,14 +106,18 @@ def compute_all(
102106 dataset_language
103107):
104108 df = compute_samples (sample_data , df )
105- write_cache ("sampled_cache.csv" , df )
109+ # write_cache("sampled_cache.csv", df)
110+ streamlit .write (df )
106111 df = compute_stopwords (remove_stopwords , df , column_name ,dataset_language ,custom_stopwords )
107- write_cache ("stopwords_cache.csv" , df )
112+ # write_cache("stopwords_cache.csv", df)
113+ streamlit .write (df )
108114 df = compute_embeddings (
109115 df , embedding_language , languages_dict , progress_bar , column_name
110116 )
111- write_cache ("embedding_cache.csv" , df )
117+ # write_cache("embedding_cache.csv", df)
118+ streamlit .write (df )
112119 df = compute_dimension_reduction (df , transformer_option , transformers_dict )
120+ # write_cache("cache.csv",df)
113121 return df
114122
115123
@@ -143,22 +151,11 @@ def compute_cache(
143151
144152
145153 if ("cache.json" not in os .listdir ("data/plotting_data/cache" )) and compute :
146- streamlit .write ("no cache. computing..." )
147- my_bar = progress_bar .progress (0 )
148154
149- df = compute_all (
150- sample_data ,
151- dataset ,
152- remove_stopwords ,
153- column_name ,
154- embedding_language ,
155- languages_dict ,
156- progress_bar ,
157- transformer_option ,
158- transformers_dict ,
159- dataset_language ,
160- custom_stopwords
161- )
155+ my_bar = progress_bar .progress (0 )
156+
157+ df = compute_all (sample_data ,dataset ,remove_stopwords ,column_name ,embedding_language ,languages_dict ,progress_bar ,transformer_option ,transformers_dict ,custom_stopwords ,dataset_language )
158+
162159
163160 no_cache = True
164161 progress_bar .success (":heavy_check_mark: Your data is ready!" )
0 commit comments