Spaces:
Runtime error
Runtime error
Commit
·
695e402
1
Parent(s):
45a9fa0
Update app.py
Browse files
app.py
CHANGED
@@ -19,7 +19,12 @@ examples = [
|
|
19 |
["Lütfen yardım Akevler mahallesi Rüzgar sokak Tuncay apartmanı zemin kat Antakya akrabalarım göçük altında #hatay #Afad"]
|
20 |
]
|
21 |
|
22 |
-
def create_record(input_text):
|
|
|
|
|
|
|
|
|
|
|
23 |
# Making the prediction
|
24 |
predictions = nlp(input_text, aggregation_strategy="first")
|
25 |
|
@@ -38,6 +43,7 @@ def create_record(input_text):
|
|
38 |
record = rg.TokenClassificationRecord(
|
39 |
text=input_text,
|
40 |
tokens=words,
|
|
|
41 |
prediction=prediction,
|
42 |
prediction_agent="deprem-ml/deprem-ner",
|
43 |
)
|
@@ -59,7 +65,7 @@ class ArgillaLogger(FlaggingCallback):
|
|
59 |
) -> int:
|
60 |
text = flag_data[0]
|
61 |
inference = flag_data[1]
|
62 |
-
rg.log(name=self.dataset_name, records=create_record(text))
|
63 |
|
64 |
|
65 |
|
@@ -68,8 +74,8 @@ gr.Interface.load(
|
|
68 |
examples=examples,
|
69 |
allow_flagging="manual",
|
70 |
flagging_callback=ArgillaLogger(
|
71 |
-
api_url="https://
|
72 |
-
api_key=
|
73 |
dataset_name="ner-flags"
|
74 |
),
|
75 |
flagging_options=["Correct", "Incorrect", "Ambiguous"]
|
|
|
19 |
["Lütfen yardım Akevler mahallesi Rüzgar sokak Tuncay apartmanı zemin kat Antakya akrabalarım göçük altında #hatay #Afad"]
|
20 |
]
|
21 |
|
22 |
+
def create_record(input_text, feedback):
|
23 |
+
# define the record status based on feedback
|
24 |
+
# default means it needs to be reviewed --> "Incorrect" or "Ambiguous"
|
25 |
+
# validated means it's correct and has been checked --> "Correct"
|
26 |
+
status = "Validated" if feedback == "Correct" else "Default"
|
27 |
+
|
28 |
# Making the prediction
|
29 |
predictions = nlp(input_text, aggregation_strategy="first")
|
30 |
|
|
|
43 |
record = rg.TokenClassificationRecord(
|
44 |
text=input_text,
|
45 |
tokens=words,
|
46 |
+
status=status,
|
47 |
prediction=prediction,
|
48 |
prediction_agent="deprem-ml/deprem-ner",
|
49 |
)
|
|
|
65 |
) -> int:
|
66 |
text = flag_data[0]
|
67 |
inference = flag_data[1]
|
68 |
+
rg.log(name=self.dataset_name, records=create_record(text, flag_option))
|
69 |
|
70 |
|
71 |
|
|
|
74 |
examples=examples,
|
75 |
allow_flagging="manual",
|
76 |
flagging_callback=ArgillaLogger(
|
77 |
+
api_url="https://dvilasuero-argilla-template-space-2.hf.space",
|
78 |
+
api_key="team.apikey",
|
79 |
dataset_name="ner-flags"
|
80 |
),
|
81 |
flagging_options=["Correct", "Incorrect", "Ambiguous"]
|