Sanatbek_Matlatipov
commited on
Commit
·
b61620b
1
Parent(s):
c111fdf
Script is changed to JSON read
Browse files
data/aspect-based-sentiment-analysis-uzbek1.py → aspect-based-sentiment-analysis-uzbek.py
RENAMED
@@ -1,9 +1,9 @@
|
|
1 |
-
import
|
2 |
-
import xml.etree.ElementTree as ET
|
3 |
import datasets
|
4 |
from datasets import GeneratorBasedBuilder, DatasetInfo, Split, SplitGenerator, Features, Value, Sequence
|
5 |
|
6 |
-
_BASE_URL = "https://drive.google.com/uc?export=download&id=
|
|
|
7 |
|
8 |
class UzABSA(GeneratorBasedBuilder):
|
9 |
VERSION = datasets.Version("1.0.0")
|
@@ -39,32 +39,13 @@ class UzABSA(GeneratorBasedBuilder):
|
|
39 |
]
|
40 |
|
41 |
def _generate_examples(self, filepath):
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
"term": aspect_term.get("term"),
|
53 |
-
"polarity": aspect_term.get("polarity"),
|
54 |
-
"from": int(aspect_term.get("from")),
|
55 |
-
"to": int(aspect_term.get("to")),
|
56 |
-
})
|
57 |
-
|
58 |
-
aspect_categories = []
|
59 |
-
for aspect_category in sentence.findall("./aspectCategories/aspectCategory"):
|
60 |
-
aspect_categories.append({
|
61 |
-
"category": aspect_category.get("category"),
|
62 |
-
"polarity": aspect_category.get("polarity"),
|
63 |
-
})
|
64 |
-
|
65 |
-
yield sentence_id, {
|
66 |
-
"sentence_id": sentence_id,
|
67 |
-
"text": text,
|
68 |
-
"aspect_terms": aspect_terms,
|
69 |
-
"aspect_categories": aspect_categories,
|
70 |
-
}
|
|
|
1 |
+
import json
|
|
|
2 |
import datasets
|
3 |
from datasets import GeneratorBasedBuilder, DatasetInfo, Split, SplitGenerator, Features, Value, Sequence
|
4 |
|
5 |
+
_BASE_URL = "https://drive.google.com/uc?export=download&id=12J5C6knWWPebLsjdZt0zCU4GKzDO5kGa"
|
6 |
+
|
7 |
|
8 |
class UzABSA(GeneratorBasedBuilder):
|
9 |
VERSION = datasets.Version("1.0.0")
|
|
|
39 |
]
|
40 |
|
41 |
def _generate_examples(self, filepath):
|
42 |
+
# Now we'll read the jsonl format
|
43 |
+
with open(filepath, 'r') as file:
|
44 |
+
for line in file:
|
45 |
+
record = json.loads(line.strip())
|
46 |
+
yield record["sentence_id"], {
|
47 |
+
"sentence_id": record["sentence_id"],
|
48 |
+
"text": record["text"],
|
49 |
+
"aspect_terms": record["aspect_terms"],
|
50 |
+
"aspect_categories": record["aspect_categories"],
|
51 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|