| """BOUN dataset""" | |
| import datasets | |
| _CITATION = """ | |
| @article{celebi2018segmenting, | |
| title={Segmenting hashtags and analyzing their grammatical structure}, | |
| author={Celebi, Arda and {\"O}zg{\"u}r, Arzucan}, | |
| journal={Journal of the Association for Information Science and Technology}, | |
| volume={69}, | |
| number={5}, | |
| pages={675--686}, | |
| year={2018}, | |
| publisher={Wiley Online Library} | |
| } | |
| """ | |
| _DESCRIPTION = """ | |
| Dev-BOUN Development set that includes 500 manually segmented hashtags. These are selected from tweets about movies, | |
| tv shows, popular people, sports teams etc. Test-BOUN Test set that includes 500 manually segmented hashtags. | |
| These are selected from tweets about movies, tv shows, popular people, sports teams etc. | |
| """ | |
| _URLS = { | |
| "dev": "https://raw.githubusercontent.com/ardax/hashtag-segmentor/master/Dev-BOUN", | |
| "test": "https://raw.githubusercontent.com/ardax/hashtag-segmentor/master/Test-BOUN" | |
| } | |
| class Boun(datasets.GeneratorBasedBuilder): | |
| VERSION = datasets.Version("1.0.0") | |
| def _info(self): | |
| return datasets.DatasetInfo( | |
| description=_DESCRIPTION, | |
| features=datasets.Features( | |
| { | |
| "index": datasets.Value("int32"), | |
| "hashtag": datasets.Value("string"), | |
| "segmentation": datasets.Value("string") | |
| } | |
| ), | |
| supervised_keys=None, | |
| homepage="https://github.com/ardax/hashtag-segmentor", | |
| citation=_CITATION, | |
| ) | |
| def _split_generators(self, dl_manager): | |
| downloaded_files = dl_manager.download(_URLS) | |
| return [ | |
| datasets.SplitGenerator(name=datasets.Split.VALIDATION, gen_kwargs={"filepath": downloaded_files["dev"] }), | |
| datasets.SplitGenerator(name=datasets.Split.TEST, gen_kwargs={"filepath": downloaded_files["test"] }), | |
| ] | |
| def _generate_examples(self, filepath): | |
| with open(filepath, 'r') as f: | |
| for idx, line in enumerate(f): | |
| yield idx, { | |
| "index": idx, | |
| "hashtag": line.strip().replace(" ", ""), | |
| "segmentation": line.strip() | |
| } |