Spaces:
Sleeping
Sleeping
Commit
·
3072ee1
1
Parent(s):
880c8ba
Delete modules/language_model.py
Browse files- modules/language_model.py +0 -34
modules/language_model.py
DELETED
@@ -1,34 +0,0 @@
|
|
1 |
-
from transformers import pipeline
|
2 |
-
import pandas as pd
|
3 |
-
|
4 |
-
def TAPAS(question, table_main):
|
5 |
-
"""
|
6 |
-
Processing the question using an expression and the main and geom table.
|
7 |
-
|
8 |
-
Args:
|
9 |
-
question (str): the question.
|
10 |
-
table_main (df): main table
|
11 |
-
table_geom (df): geom table
|
12 |
-
Returns:
|
13 |
-
answer (str): answer to the question
|
14 |
-
"""
|
15 |
-
|
16 |
-
# set up a TAPAS pipeline for table-based question answering
|
17 |
-
tqa = pipeline(task="table-question-answering", model="google/tapas-large-finetuned-wtq")
|
18 |
-
|
19 |
-
# use the tqa pipeline to perform table-based question answering.
|
20 |
-
i = tqa(table=table_main, query=question)['cells'][0]
|
21 |
-
|
22 |
-
# Check if the output is the link to the TEMP DB:
|
23 |
-
# Has to be done because the entrys for geometry, ... are an array :(
|
24 |
-
if ';' in i:
|
25 |
-
i = i.split(";")
|
26 |
-
path = i[0]
|
27 |
-
r = int(i[1])
|
28 |
-
c = int(i[2])
|
29 |
-
answer_table = pd.read_csv(path)
|
30 |
-
answer = answer_table.iloc[r,c]
|
31 |
-
return(answer)
|
32 |
-
|
33 |
-
answer = str(i)
|
34 |
-
return(answer)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|