arxyzan commited on
Commit
106bd16
1 Parent(s): ecbe00a

Delete parstwiner.py

Browse files
Files changed (1) hide show
  1. parstwiner.py +0 -107
parstwiner.py DELETED
@@ -1,107 +0,0 @@
1
- import csv
2
- from ast import literal_eval
3
-
4
- import datasets
5
-
6
- logger = datasets.logging.get_logger(__name__)
7
-
8
- _CITATION = """
9
- @inproceedings{aghajani-etal-2021-parstwiner,
10
- title = "{P}ars{T}wi{NER}: A Corpus for Named Entity Recognition at Informal {P}ersian",
11
- author = "Aghajani, MohammadMahdi and
12
- Badri, AliAkbar and
13
- Beigy, Hamid",
14
- booktitle = "Proceedings of the Seventh Workshop on Noisy User-generated Text (W-NUT 2021)",
15
- month = nov,
16
- year = "2021",
17
- address = "Online",
18
- publisher = "Association for Computational Linguistics",
19
- url = "https://aclanthology.org/2021.wnut-1.16",
20
- pages = "131--136",
21
- abstract = "As a result of unstructured sentences and some misspellings and errors, finding named entities in a noisy environment such as social media takes much more effort. ParsTwiNER contains about 250k tokens, based on standard instructions like MUC-6 or CoNLL 2003, gathered from Persian Twitter. Using Cohen{'}s Kappa coefficient, the consistency of annotators is 0.95, a high score. In this study, we demonstrate that some state-of-the-art models degrade on these corpora, and trained a new model using parallel transfer learning based on the BERT architecture. Experimental results show that the model works well in informal Persian as well as in formal Persian.",
22
- }
23
- """
24
-
25
- _DESCRIPTION = """"""
26
-
27
- _DOWNLOAD_URLS = {
28
- "train": "https://huggingface.co/datasets/hezarai/parstwiner/resolve/main/parstwiner_train.csv",
29
- "test": "https://huggingface.co/datasets/hezarai/parstwiner/resolve/main/parstwiner_test.csv",
30
- }
31
-
32
-
33
- class ParsTwiNERConfig(datasets.BuilderConfig):
34
- def __init__(self, **kwargs):
35
- super(ParsTwiNERConfig, self).__init__(**kwargs)
36
-
37
-
38
- class ParsTwiNER(datasets.GeneratorBasedBuilder):
39
- BUILDER_CONFIGS = [
40
- ParsTwiNERConfig(
41
- name="ParsTwiNER",
42
- version=datasets.Version("1.0.0"),
43
- description=_DESCRIPTION,
44
- ),
45
- ]
46
-
47
- def _info(self):
48
- return datasets.DatasetInfo(
49
- description=_DESCRIPTION,
50
- features=datasets.Features(
51
- {
52
- "tokens": datasets.Sequence(datasets.Value("string")),
53
- "ner_tags": datasets.Sequence(
54
- datasets.features.ClassLabel(
55
- names=[
56
- "O",
57
- "B-POG",
58
- "I-POG",
59
- "B-PER",
60
- "I-PER",
61
- "B-ORG",
62
- "I-ORG",
63
- "B-NAT",
64
- "I-NAT",
65
- "B-LOC",
66
- "I-LOC",
67
- "B-EVE",
68
- "I-EVE",
69
- ]
70
- )
71
- ),
72
- }
73
- ),
74
- homepage="https://github.com/overfit-ir/parstwiner",
75
- citation=_CITATION,
76
- )
77
-
78
- def _split_generators(self, dl_manager):
79
- """
80
- Return SplitGenerators.
81
- """
82
-
83
- train_path = dl_manager.download_and_extract(_DOWNLOAD_URLS["train"])
84
- test_path = dl_manager.download_and_extract(_DOWNLOAD_URLS["test"])
85
-
86
- return [
87
- datasets.SplitGenerator(
88
- name=datasets.Split.TRAIN, gen_kwargs={"filepath": train_path}
89
- ),
90
- datasets.SplitGenerator(
91
- name=datasets.Split.TEST, gen_kwargs={"filepath": test_path}
92
- ),
93
- ]
94
-
95
- def _generate_examples(self, filepath):
96
- logger.info("⏳ Generating examples from = %s", filepath)
97
- with open(filepath, encoding="utf-8") as csv_file:
98
- csv_reader = csv.reader(csv_file, quotechar='"', skipinitialspace=True)
99
-
100
- next(csv_reader, None)
101
-
102
- for id_, row in enumerate(csv_reader):
103
- tokens, ner_tags = row
104
- # Optional preprocessing here
105
- tokens = literal_eval(tokens)
106
- ner_tags = literal_eval(ner_tags)
107
- yield id_, {"tokens": tokens, "ner_tags": ner_tags}