Spaces:
Paused
Paused
update
Browse files
app.py
CHANGED
|
@@ -116,84 +116,71 @@ def perform_aste_inference(text, dataset):
|
|
| 116 |
demo = gr.Blocks()
|
| 117 |
|
| 118 |
with demo:
|
| 119 |
-
|
| 120 |
-
gr.Markdown("# <p align='center'>Aspect Sentiment Triplet Extraction !</p>")
|
| 121 |
-
|
| 122 |
-
gr.Markdown(
|
| 123 |
-
"Your input text should be no more than 80 words, that's the longest text we used in trainer. "
|
| 124 |
-
"However, you can try longer text in self-trainer "
|
| 125 |
-
)
|
| 126 |
-
gr.Markdown(
|
| 127 |
-
"**You don't need to split each Chinese (Korean, etc.) token as the provided,"
|
| 128 |
-
" just input the natural language text.**"
|
| 129 |
-
)
|
| 130 |
-
output_dfs = []
|
| 131 |
-
|
| 132 |
-
|
| 133 |
with gr.Row():
|
| 134 |
-
with gr.Column():
|
| 135 |
-
aste_input_sentence = gr.Textbox(
|
| 136 |
-
placeholder="Leave this box blank and choose a dataset will give you a random example...",
|
| 137 |
-
label="Example:",
|
| 138 |
-
)
|
| 139 |
-
gr.Markdown(
|
| 140 |
-
"You can find code and dataset at [ASTE examples](https://github.com/yangheng95/PyABSA/examples-v2/aspect_sentiment_triplet_extration)"
|
| 141 |
-
)
|
| 142 |
-
aste_dataset_ids = gr.Radio(
|
| 143 |
-
choices=[dataset.name for dataset in ASTE.ASTEDatasetList()[:-1]],
|
| 144 |
-
value="Restaurant14",
|
| 145 |
-
label="Datasets",
|
| 146 |
-
)
|
| 147 |
-
aste_inference_button = gr.Button("Let's go!")
|
| 148 |
|
| 149 |
with gr.Column():
|
| 150 |
-
|
| 151 |
-
|
| 152 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 153 |
|
| 154 |
-
aste_inference_button.click(
|
| 155 |
-
fn=perform_aste_inference,
|
| 156 |
-
inputs=[aste_input_sentence, aste_dataset_ids],
|
| 157 |
-
outputs=[aste_output_pred_df, aste_output_true_df, aste_output_text],
|
| 158 |
-
)
|
| 159 |
-
|
| 160 |
-
|
| 161 |
-
gr.Markdown(
|
| 162 |
-
"# <p align='center'>Multilingual Aspect-based Sentiment Analysis !</p>"
|
| 163 |
-
)
|
| 164 |
-
with gr.Row():
|
| 165 |
with gr.Column():
|
| 166 |
-
atepc_input_sentence = gr.Textbox(
|
| 167 |
-
placeholder="Leave this box blank and choose a dataset will give you a random example...",
|
| 168 |
-
label="Example:",
|
| 169 |
-
)
|
| 170 |
gr.Markdown(
|
| 171 |
-
"
|
| 172 |
)
|
| 173 |
-
|
| 174 |
-
|
| 175 |
-
|
| 176 |
-
|
| 177 |
-
|
| 178 |
-
|
| 179 |
-
|
| 180 |
-
|
| 181 |
-
|
| 182 |
-
|
| 183 |
-
|
| 184 |
-
|
| 185 |
-
|
| 186 |
-
|
| 187 |
-
|
| 188 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 189 |
gr.Markdown(
|
| 190 |
-
"""### Repo: [PyABSA V2](https://github.com/yangheng95/PyABSA)
|
| 191 |
-
|
| 192 |
-
|
| 193 |
-
|
| 194 |
-
|
| 195 |
-
)
|
| 196 |
-
gr.Markdown(
|
| 197 |
-
"This demo support many other language as well, you can try and explore the results of other languages by yourself."
|
| 198 |
)
|
|
|
|
| 199 |
demo.launch()
|
|
|
|
| 116 |
demo = gr.Blocks()
|
| 117 |
|
| 118 |
with demo:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 119 |
with gr.Row():
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 120 |
|
| 121 |
with gr.Column():
|
| 122 |
+
gr.Markdown("# <p align='center'>Aspect Sentiment Triplet Extraction !</p>")
|
| 123 |
+
|
| 124 |
+
with gr.Row():
|
| 125 |
+
with gr.Column():
|
| 126 |
+
aste_input_sentence = gr.Textbox(
|
| 127 |
+
placeholder="Leave this box blank and choose a dataset will give you a random example...",
|
| 128 |
+
label="Example:",
|
| 129 |
+
)
|
| 130 |
+
gr.Markdown(
|
| 131 |
+
"You can find code and dataset at [ASTE examples](https://github.com/yangheng95/PyABSA/tree/v2/examples-v2/aspect_sentiment_triplet_extration)"
|
| 132 |
+
)
|
| 133 |
+
aste_dataset_ids = gr.Radio(
|
| 134 |
+
choices=[dataset.name for dataset in ASTE.ASTEDatasetList()[:-1]],
|
| 135 |
+
value="Restaurant14",
|
| 136 |
+
label="Datasets",
|
| 137 |
+
)
|
| 138 |
+
aste_inference_button = gr.Button("Let's go!")
|
| 139 |
+
|
| 140 |
+
aste_output_text = gr.TextArea(label="Example:")
|
| 141 |
+
aste_output_pred_df = gr.DataFrame(label="Predicted Triplets:")
|
| 142 |
+
aste_output_true_df = gr.DataFrame(label="Original Triplets:")
|
| 143 |
+
|
| 144 |
+
aste_inference_button.click(
|
| 145 |
+
fn=perform_aste_inference,
|
| 146 |
+
inputs=[aste_input_sentence, aste_dataset_ids],
|
| 147 |
+
outputs=[aste_output_pred_df, aste_output_true_df, aste_output_text],
|
| 148 |
+
)
|
| 149 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 150 |
with gr.Column():
|
|
|
|
|
|
|
|
|
|
|
|
|
| 151 |
gr.Markdown(
|
| 152 |
+
"# <p align='center'>Multilingual Aspect-based Sentiment Analysis !</p>"
|
| 153 |
)
|
| 154 |
+
with gr.Row():
|
| 155 |
+
with gr.Column():
|
| 156 |
+
atepc_input_sentence = gr.Textbox(
|
| 157 |
+
placeholder="Leave this box blank and choose a dataset will give you a random example...",
|
| 158 |
+
label="Example:",
|
| 159 |
+
)
|
| 160 |
+
gr.Markdown(
|
| 161 |
+
"You can find the datasets at [github.com/yangheng95/ABSADatasets](https://github.com/yangheng95/ABSADatasets/tree/v1.2/datasets/text_classification)"
|
| 162 |
+
)
|
| 163 |
+
atepc_dataset_ids = gr.Radio(
|
| 164 |
+
choices=[dataset.name for dataset in ATEPC.ATEPCDatasetList()[:-1]],
|
| 165 |
+
value="Laptop14",
|
| 166 |
+
label="Datasets",
|
| 167 |
+
)
|
| 168 |
+
atepc_inference_button = gr.Button("Let's go!")
|
| 169 |
+
|
| 170 |
+
atepc_output_text = gr.TextArea(label="Example:")
|
| 171 |
+
atepc_output_df = gr.DataFrame(label="Prediction Results:")
|
| 172 |
+
|
| 173 |
+
atepc_inference_button.click(
|
| 174 |
+
fn=perform_atepc_inference,
|
| 175 |
+
inputs=[atepc_input_sentence, atepc_dataset_ids],
|
| 176 |
+
outputs=[atepc_output_df, atepc_output_text],
|
| 177 |
+
)
|
| 178 |
gr.Markdown(
|
| 179 |
+
"""### GitHub Repo: [PyABSA V2](https://github.com/yangheng95/PyABSA)
|
| 180 |
+
### Author: [Heng Yang](https://github.com/yangheng95) (杨恒)
|
| 181 |
+
[](https://pepy.tech/project/pyabsa)
|
| 182 |
+
[](https://pepy.tech/project/pyabsa)
|
| 183 |
+
"""
|
|
|
|
|
|
|
|
|
|
| 184 |
)
|
| 185 |
+
|
| 186 |
demo.launch()
|