-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathWikiNewsPOS.py
80 lines (72 loc) · 2.43 KB
/
WikiNewsPOS.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
from llmebench.datasets.dataset_base import DatasetBase
from llmebench.tasks import TaskType
class WikiNewsPOSDataset(DatasetBase):
def __init__(self, **kwargs):
super(WikiNewsPOSDataset, self).__init__(**kwargs)
@staticmethod
def metadata():
return {
"language": "ar",
"citation": """@inproceedings{darwish2017arabic,
title={Arabic {POS} tagging: Don’t abandon feature engineering just yet},
author={Darwish, Kareem and Mubarak, Hamdy and Abdelali, Ahmed and Eldesouki, Mohamed},
booktitle={Proceedings of the third arabic natural language processing workshop},
pages={130--137},
year={2017}
}""",
"link": "https://github.com/kdarwish/Farasa/blob/master/WikiNews.pos.ref",
"license": "Research Purpose Only",
"splits": {
"test": "WikiNewsTruth.txt.POS.tab",
"train": "WikiNewsTruthDev.txt",
},
"task_type": TaskType.SequenceLabeling,
"class_labels": [
"ABBREV",
"ADJ",
"ADJ/CONJ",
"ADJ/DET",
"ADJ/NUM",
"ADV",
"CASE",
"CONJ",
"DET",
"FOREIGN",
"FUT_PART",
"NOUN",
"NOUN/DET",
"NSUFF",
"NSUFF/ADJ",
"NSUFF/DET",
"NSUFF/NOUN",
"NUM",
"PART",
"PART/CONJ",
"PART/NOUN",
"PART/PART",
"PART/PREP",
"PREP",
"PRON",
"PUNC",
"V",
],
}
@staticmethod
def get_data_sample():
return {
"input": "Original sentence",
"label": "Sentence with POS tags",
}
def load_data(self, data_path, no_labels=False):
data_path = self.resolve_path(data_path)
data = []
with open(data_path, "r") as fp:
for line_idx, line in enumerate(fp):
data.append(
{
"input": line.strip().split("\t")[0],
"label": line.strip().split("\t")[1],
"line_number": line_idx,
}
)
return data