Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -98,9 +98,11 @@ class AspectSentimentPipeline(Pipeline):
|
|
| 98 |
for i, (token, prediction) in enumerate(zip(aligned_tokens, aligned_predictions)):
|
| 99 |
if prediction == "B-A":
|
| 100 |
if current_aspect:
|
|
|
|
| 101 |
aspects.append(" ".join(current_aspect))
|
| 102 |
current_aspect = []
|
| 103 |
-
|
|
|
|
| 104 |
elif prediction == "I-A":
|
| 105 |
if current_aspect:
|
| 106 |
current_aspect.append(token)
|
|
@@ -110,13 +112,6 @@ class AspectSentimentPipeline(Pipeline):
|
|
| 110 |
if current_aspect:
|
| 111 |
aspects.append(" ".join(current_aspect))
|
| 112 |
current_aspect = []
|
| 113 |
-
else:
|
| 114 |
-
if current_aspect:
|
| 115 |
-
aspects.append(" ".join(current_aspect))
|
| 116 |
-
current_aspect = []
|
| 117 |
-
|
| 118 |
-
if current_aspect:
|
| 119 |
-
aspects.append(" ".join(current_aspect))
|
| 120 |
|
| 121 |
return aspects
|
| 122 |
|
|
|
|
| 98 |
for i, (token, prediction) in enumerate(zip(aligned_tokens, aligned_predictions)):
|
| 99 |
if prediction == "B-A":
|
| 100 |
if current_aspect:
|
| 101 |
+
current_aspect.append(token)
|
| 102 |
aspects.append(" ".join(current_aspect))
|
| 103 |
current_aspect = []
|
| 104 |
+
else:
|
| 105 |
+
current_aspect.append(token)
|
| 106 |
elif prediction == "I-A":
|
| 107 |
if current_aspect:
|
| 108 |
current_aspect.append(token)
|
|
|
|
| 112 |
if current_aspect:
|
| 113 |
aspects.append(" ".join(current_aspect))
|
| 114 |
current_aspect = []
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 115 |
|
| 116 |
return aspects
|
| 117 |
|