Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -7,7 +7,6 @@ import pandas as pd
|
|
7 |
|
8 |
model = SentenceTransformer('gart-labor/eng-distilBERT-se-eclass')
|
9 |
|
10 |
-
|
11 |
corpus = pd.read_json('corpus.jsonl', lines = True, encoding = 'utf-8')
|
12 |
|
13 |
def predict(name, description):
|
@@ -23,34 +22,12 @@ def predict(name, description):
|
|
23 |
IRDI1 = corpus.iloc[output[0][0].get('corpus_id'),4]
|
24 |
score1 = output[0][0].get('score')
|
25 |
|
26 |
-
|
27 |
-
definition2 = corpus.iloc[output[0][1].get('corpus_id'),1]
|
28 |
-
IRDI2 = corpus.iloc[output[0][1].get('corpus_id'),4]
|
29 |
-
score2 = output[0][1].get('score')
|
30 |
-
|
31 |
-
preferedName3 = corpus.iloc[output[0][2].get('corpus_id'),2]
|
32 |
-
definition3 = corpus.iloc[output[0][2].get('corpus_id'),1]
|
33 |
-
IRDI3 = corpus.iloc[output[0][2].get('corpus_id'),4]
|
34 |
-
score3 = output[0][2].get('score')
|
35 |
-
|
36 |
-
preferedName4 = corpus.iloc[output[0][3].get('corpus_id'),2]
|
37 |
-
definition4 = corpus.iloc[output[0][3].get('corpus_id'),1]
|
38 |
-
IRDI4 = corpus.iloc[output[0][3].get('corpus_id'),4]
|
39 |
-
score4 = output[0][3].get('score')
|
40 |
-
|
41 |
-
preferedName5 = corpus.iloc[output[0][4].get('corpus_id'),2]
|
42 |
-
definition5 = corpus.iloc[output[0][4].get('corpus_id'),1]
|
43 |
-
IRDI5 = corpus.iloc[output[0][4].get('corpus_id'),4]
|
44 |
-
score5 = output[0][4].get('score')
|
45 |
-
|
46 |
-
df = [[preferedName1, IRDI1, score1], [preferedName2, IRDI2, score2],[preferedName3, IRDI3, score3],[preferedName4, IRDI4, score4], [preferedName5, IRDI5, score5]]
|
47 |
-
|
48 |
-
return pd.DataFrame(df)
|
49 |
|
50 |
interface = gr.Interface(fn = predict,
|
51 |
inputs = [gr.Textbox(label="Name:", placeholder="Name of the Pump Property", lines=1), gr.Textbox(label="Description:", placeholder="Description of the Pump Property", lines=1)],
|
52 |
-
|
53 |
-
outputs = [gr.Dataframe(row_count = (5, "fixed"), col_count=(3, "fixed"), label="Predictions", headers=['ECLASS preferedName', 'ECLASS IRDI', 'simularity score'])],
|
54 |
examples = [['Device type', 'describing a set of common specific characteristics in products or goods'], ['Item type','the type of product, an item can be assigned to'],
|
55 |
['Nominal power','power being consumed by or dissipated within an electric component as a variable'], ['Power consumption', 'power that is typically taken from the auxiliary power supply when the device is operating normally']],
|
56 |
#theme = 'huggingface',
|
|
|
7 |
|
8 |
model = SentenceTransformer('gart-labor/eng-distilBERT-se-eclass')
|
9 |
|
|
|
10 |
corpus = pd.read_json('corpus.jsonl', lines = True, encoding = 'utf-8')
|
11 |
|
12 |
def predict(name, description):
|
|
|
22 |
IRDI1 = corpus.iloc[output[0][0].get('corpus_id'),4]
|
23 |
score1 = output[0][0].get('score')
|
24 |
|
25 |
+
return preferedName1, definition1, IRDI1, score1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
26 |
|
27 |
interface = gr.Interface(fn = predict,
|
28 |
inputs = [gr.Textbox(label="Name:", placeholder="Name of the Pump Property", lines=1), gr.Textbox(label="Description:", placeholder="Description of the Pump Property", lines=1)],
|
29 |
+
outputs = [gr.Textbox(label = 'preferedName'),gr.Textbox(label = 'definition'), gr.Textbox(label = 'IDRI'),gr.Textbox(label = 'score')],
|
30 |
+
#outputs = [gr.Dataframe(row_count = (5, "fixed"), col_count=(3, "fixed"), label="Predictions", headers=['ECLASS preferedName', 'ECLASS IRDI', 'simularity score'])],
|
31 |
examples = [['Device type', 'describing a set of common specific characteristics in products or goods'], ['Item type','the type of product, an item can be assigned to'],
|
32 |
['Nominal power','power being consumed by or dissipated within an electric component as a variable'], ['Power consumption', 'power that is typically taken from the auxiliary power supply when the device is operating normally']],
|
33 |
#theme = 'huggingface',
|