MCPcopy Create free account
hub / github.com/BIT-DataLab/LakeBench / process_subset

Function process_subset

union/TUS/Usem.py:164–203  ·  view source on GitHub ↗
(file_list)

Source from the content-addressed store, hash-verified

162 cal_list = [x for x in floder_list if x not in exist_list]
163
164 def process_subset(file_list):
165 conn, cursor = get_yagoTypes_from_tsv()
166 for file_name in file_list:
167 if file_name.endswith('.csv') and file_name not in exist_list:
168 file_path = os.path.join(floder_path, file_name)
169 df = pd.read_csv(file_path)
170 saved_data = {}
171
172 for column in df.columns:
173 values = df[column].to_list()
174 values = [process_string(s) for s in values if s != ' ' and s != '']
175 counter = Counter(values)
176 values_set = set(values)
177
178 classes_of_thisColumn = []
179 for value in values_set:
180 search_keywords = value
181 results = query_lsh(lsh, search_keywords, 1)
182
183 for result in results:
184 query = f'''SELECT distinct taxonomy_class
185 FROM yagoTypejoinclasses
186 WHERE entity = '{result}';
187 '''
188 cursor.execute(query)
189 temp = cursor.fetchall()
190 for i in range(len(temp)):
191 temp[i] = temp[i][0]
192
193 classes_of_thisColumn += temp * counter[value]
194 saved_data[column] = classes_of_thisColumn
195
196 saved_data = fill_zero(saved_data)
197 saved_df = pd.DataFrame(saved_data)
198 saved_file_path = os.path.join(save_floder_path, file_name)
199 saved_df.to_csv(saved_file_path, index=False)
200 conn.commit()
201 cursor.close()
202 conn.close()
203 print('success saved on' + saved_file_path)
204 cal_sublists = np.array_split(cal_list, 16)
205 cal_sublists = [c.tolist() for c in cal_sublists]
206

Callers

nothing calls this directly

Calls 5

get_yagoTypes_from_tsvFunction · 0.90
process_stringFunction · 0.90
closeMethod · 0.80
query_lshFunction · 0.70
fill_zeroFunction · 0.70

Tested by

no test coverage detected