AmazonScience/massive
MASSIVE is a parallel dataset of > 1M utterances across 51 languages with annotations for the Natural Language Understanding tasks of intent prediction and slot annotation. Utterances span 60 intents and include 55 slot types. MASSIVE was created by localizing the SLURP dataset, composed of general Intelligent Voice Assistant single-shot interactions.
10116k
1# coding=utf-82 3"""MASSIVE: A 1M-Example Multilingual Natural Language Understanding Dataset with 51 Typologically-Diverse Languages"""4 5import json6import datasets7 8logger = datasets.logging.get_logger(__name__)9 10_DESCRIPTION = """\11 MASSIVE is a parallel dataset of > 1M utterances across 51 languages with annotations12 for the Natural Language Understanding tasks of intent prediction and slot annotation.13 Utterances span 60 intents and include 55 slot types. MASSIVE was created by localizing14 the SLURP dataset, composed of general Intelligent Voice Assistant single-shot interactions.15"""16 17_CITATION = """\18 @misc{fitzgerald2022massive,19 title={MASSIVE: A 1M-Example Multilingual Natural Language Understanding Dataset with 51 Typologically-Diverse Languages},20 author={Jack FitzGerald and Christopher Hench and Charith Peris and Scott Mackie and Kay Rottmann and Ana Sanchez and Aaron Nash and Liam Urbach and Vishesh Kakarala and Richa Singh and Swetha Ranganath and Laurie Crist and Misha Britan and Wouter Leeuwis and Gokhan Tur and Prem Natarajan},21 year={2022},22 eprint={2204.08582},23 archivePrefix={arXiv},24 primaryClass={cs.CL}25 }26 \27 @inproceedings{bastianelli-etal-2020-slurp,28 title = "{SLURP}: A Spoken Language Understanding Resource Package",29 author = "Bastianelli, Emanuele and30 Vanzo, Andrea and31 Swietojanski, Pawel and32 Rieser, Verena",33 booktitle = "Proceedings of the 2020 Conference on Empirical Methods in Natural Language Processing (EMNLP)",34 month = nov,35 year = "2020",36 address = "Online",37 publisher = "Association for Computational Linguistics",38 url = "https://aclanthology.org/2020.emnlp-main.588",39 doi = "10.18653/v1/2020.emnlp-main.588",40 pages = "7252--7262",41 abstract = "Spoken Language Understanding infers semantic meaning directly from audio data, and thus promises to reduce error propagation and misunderstandings in end-user applications. However, publicly available SLU resources are limited. In this paper, we release SLURP, a new SLU package containing the following: (1) A new challenging dataset in English spanning 18 domains, which is substantially bigger and linguistically more diverse than existing datasets; (2) Competitive baselines based on state-of-the-art NLU and ASR systems; (3) A new transparent metric for entity labelling which enables a detailed error analysis for identifying potential areas of improvement. SLURP is available at https://github.com/pswietojanski/slurp."42 }43"""44 45_LICENSE = """\46Copyright Amazon.com Inc. or its affiliates.47 48Attribution 4.0 International49 50=======================================================================51 52Creative Commons Corporation ("Creative Commons") is not a law firm and53does not provide legal services or legal advice. Distribution of54Creative Commons public licenses does not create a lawyer-client or55other relationship. Creative Commons makes its licenses and related56information available on an "as-is" basis. Creative Commons gives no57warranties regarding its licenses, any material licensed under their58terms and conditions, or any related information. Creative Commons59disclaims all liability for damages resulting from their use to the60fullest extent possible.61 62Using Creative Commons Public Licenses63 64Creative Commons public licenses provide a standard set of terms and65conditions that creators and other rights holders may use to share66original works of authorship and other material subject to copyright67and certain other rights specified in the public license below. The68following considerations are for informational purposes only, are not69exhaustive, and do not form part of our licenses.70 71 Considerations for licensors: Our public licenses are72 intended for use by those authorized to give the public73 permission to use material in ways otherwise restricted by74 copyright and certain other rights. Our licenses are75 irrevocable. Licensors should read and understand the terms76 and conditions of the license they choose before applying it.77 Licensors should also secure all rights necessary before78 applying our licenses so that the public can reuse the79 material as expected. Licensors should clearly mark any80 material not subject to the license. This includes other CC-81 licensed material, or material used under an exception or82 limitation to copyright. More considerations for licensors:83 wiki.creativecommons.org/Considerations_for_licensors84 85 Considerations for the public: By using one of our public86 licenses, a licensor grants the public permission to use the87 licensed material under specified terms and conditions. If88 the licensor's permission is not necessary for any reason--for89 example, because of any applicable exception or limitation to90 copyright--then that use is not regulated by the license. Our91 licenses grant only permissions under copyright and certain92 other rights that a licensor has authority to grant. Use of93 the licensed material may still be restricted for other94 reasons, including because others have copyright or other95 rights in the material. A licensor may make special requests,96 such as asking that all changes be marked or described.97 Although not required by our licenses, you are encouraged to98 respect those requests where reasonable. More considerations99 for the public:100 wiki.creativecommons.org/Considerations_for_licensees101 102=======================================================================103 104Creative Commons Attribution 4.0 International Public License105 106By exercising the Licensed Rights (defined below), You accept and agree107to be bound by the terms and conditions of this Creative Commons108Attribution 4.0 International Public License ("Public License"). To the109extent this Public License may be interpreted as a contract, You are110granted the Licensed Rights in consideration of Your acceptance of111these terms and conditions, and the Licensor grants You such rights in112consideration of benefits the Licensor receives from making the113Licensed Material available under these terms and conditions.114 115 116Section 1 -- Definitions.117 118 a. Adapted Material means material subject to Copyright and Similar119 Rights that is derived from or based upon the Licensed Material120 and in which the Licensed Material is translated, altered,121 arranged, transformed, or otherwise modified in a manner requiring122 permission under the Copyright and Similar Rights held by the123 Licensor. For purposes of this Public License, where the Licensed124 Material is a musical work, performance, or sound recording,125 Adapted Material is always produced where the Licensed Material is126 synched in timed relation with a moving image.127 128 b. Adapter's License means the license You apply to Your Copyright129 and Similar Rights in Your contributions to Adapted Material in130 accordance with the terms and conditions of this Public License.131 132 c. Copyright and Similar Rights means copyright and/or similar rights133 closely related to copyright including, without limitation,134 performance, broadcast, sound recording, and Sui Generis Database135 Rights, without regard to how the rights are labeled or136 categorized. For purposes of this Public License, the rights137 specified in Section 2(b)(1)-(2) are not Copyright and Similar138 Rights.139 140 d. Effective Technological Measures means those measures that, in the141 absence of proper authority, may not be circumvented under laws142 fulfilling obligations under Article 11 of the WIPO Copyright143 Treaty adopted on December 20, 1996, and/or similar international144 agreements.145 146 e. Exceptions and Limitations means fair use, fair dealing, and/or147 any other exception or limitation to Copyright and Similar Rights148 that applies to Your use of the Licensed Material.149 150 f. Licensed Material means the artistic or literary work, database,151 or other material to which the Licensor applied this Public152 License.153 154 g. Licensed Rights means the rights granted to You subject to the155 terms and conditions of this Public License, which are limited to156 all Copyright and Similar Rights that apply to Your use of the157 Licensed Material and that the Licensor has authority to license.158 159 h. Licensor means the individual(s) or entity(ies) granting rights160 under this Public License.161 162 i. Share means to provide material to the public by any means or163 process that requires permission under the Licensed Rights, such164 as reproduction, public display, public performance, distribution,165 dissemination, communication, or importation, and to make material166 available to the public including in ways that members of the167 public may access the material from a place and at a time168 individually chosen by them.169 170 j. Sui Generis Database Rights means rights other than copyright171 resulting from Directive 96/9/EC of the European Parliament and of172 the Council of 11 March 1996 on the legal protection of databases,173 as amended and/or succeeded, as well as other essentially174 equivalent rights anywhere in the world.175 176 k. You means the individual or entity exercising the Licensed Rights177 under this Public License. Your has a corresponding meaning.178 179 180Section 2 -- Scope.181 182 a. License grant.183 184 1. Subject to the terms and conditions of this Public License,185 the Licensor hereby grants You a worldwide, royalty-free,186 non-sublicensable, non-exclusive, irrevocable license to187 exercise the Licensed Rights in the Licensed Material to:188 189 a. reproduce and Share the Licensed Material, in whole or190 in part; and191 192 b. produce, reproduce, and Share Adapted Material.193 194 2. Exceptions and Limitations. For the avoidance of doubt, where195 Exceptions and Limitations apply to Your use, this Public196 License does not apply, and You do not need to comply with197 its terms and conditions.198 199 3. Term. The term of this Public License is specified in Section200 6(a).201 202 4. Media and formats; technical modifications allowed. The203 Licensor authorizes You to exercise the Licensed Rights in204 all media and formats whether now known or hereafter created,205 and to make technical modifications necessary to do so. The206 Licensor waives and/or agrees not to assert any right or207 authority to forbid You from making technical modifications208 necessary to exercise the Licensed Rights, including209 technical modifications necessary to circumvent Effective210 Technological Measures. For purposes of this Public License,211 simply making modifications authorized by this Section 2(a)212 (4) never produces Adapted Material.213 214 5. Downstream recipients.215 216 a. Offer from the Licensor -- Licensed Material. Every217 recipient of the Licensed Material automatically218 receives an offer from the Licensor to exercise the219 Licensed Rights under the terms and conditions of this220 Public License.221 222 b. No downstream restrictions. You may not offer or impose223 any additional or different terms or conditions on, or224 apply any Effective Technological Measures to, the225 Licensed Material if doing so restricts exercise of the226 Licensed Rights by any recipient of the Licensed227 Material.228 229 6. No endorsement. Nothing in this Public License constitutes or230 may be construed as permission to assert or imply that You231 are, or that Your use of the Licensed Material is, connected232 with, or sponsored, endorsed, or granted official status by,233 the Licensor or others designated to receive attribution as234 provided in Section 3(a)(1)(A)(i).235 236 b. Other rights.237 238 1. Moral rights, such as the right of integrity, are not239 licensed under this Public License, nor are publicity,240 privacy, and/or other similar personality rights; however, to241 the extent possible, the Licensor waives and/or agrees not to242 assert any such rights held by the Licensor to the limited243 extent necessary to allow You to exercise the Licensed244 Rights, but not otherwise.245 246 2. Patent and trademark rights are not licensed under this247 Public License.248 249 3. To the extent possible, the Licensor waives any right to250 collect royalties from You for the exercise of the Licensed251 Rights, whether directly or through a collecting society252 under any voluntary or waivable statutory or compulsory253 licensing scheme. In all other cases the Licensor expressly254 reserves any right to collect such royalties.255 256 257Section 3 -- License Conditions.258 259Your exercise of the Licensed Rights is expressly made subject to the260following conditions.261 262 a. Attribution.263 264 1. If You Share the Licensed Material (including in modified265 form), You must:266 267 a. retain the following if it is supplied by the Licensor268 with the Licensed Material:269 270 i. identification of the creator(s) of the Licensed271 Material and any others designated to receive272 attribution, in any reasonable manner requested by273 the Licensor (including by pseudonym if274 designated);275 276 ii. a copyright notice;277 278 iii. a notice that refers to this Public License;279 280 iv. a notice that refers to the disclaimer of281 warranties;282 283 v. a URI or hyperlink to the Licensed Material to the284 extent reasonably practicable;285 286 b. indicate if You modified the Licensed Material and287 retain an indication of any previous modifications; and288 289 c. indicate the Licensed Material is licensed under this290 Public License, and include the text of, or the URI or291 hyperlink to, this Public License.292 293 2. You may satisfy the conditions in Section 3(a)(1) in any294 reasonable manner based on the medium, means, and context in295 which You Share the Licensed Material. For example, it may be296 reasonable to satisfy the conditions by providing a URI or297 hyperlink to a resource that includes the required298 information.299 300 3. If requested by the Licensor, You must remove any of the301 information required by Section 3(a)(1)(A) to the extent302 reasonably practicable.303 304 4. If You Share Adapted Material You produce, the Adapter's305 License You apply must not prevent recipients of the Adapted306 Material from complying with this Public License.307 308 309Section 4 -- Sui Generis Database Rights.310 311Where the Licensed Rights include Sui Generis Database Rights that312apply to Your use of the Licensed Material:313 314 a. for the avoidance of doubt, Section 2(a)(1) grants You the right315 to extract, reuse, reproduce, and Share all or a substantial316 portion of the contents of the database;317 318 b. if You include all or a substantial portion of the database319 contents in a database in which You have Sui Generis Database320 Rights, then the database in which You have Sui Generis Database321 Rights (but not its individual contents) is Adapted Material; and322 323 c. You must comply with the conditions in Section 3(a) if You Share324 all or a substantial portion of the contents of the database.325 326For the avoidance of doubt, this Section 4 supplements and does not327replace Your obligations under this Public License where the Licensed328Rights include other Copyright and Similar Rights.329 330 331Section 5 -- Disclaimer of Warranties and Limitation of Liability.332 333 a. UNLESS OTHERWISE SEPARATELY UNDERTAKEN BY THE LICENSOR, TO THE334 EXTENT POSSIBLE, THE LICENSOR OFFERS THE LICENSED MATERIAL AS-IS335 AND AS-AVAILABLE, AND MAKES NO REPRESENTATIONS OR WARRANTIES OF336 ANY KIND CONCERNING THE LICENSED MATERIAL, WHETHER EXPRESS,337 IMPLIED, STATUTORY, OR OTHER. THIS INCLUDES, WITHOUT LIMITATION,338 WARRANTIES OF TITLE, MERCHANTABILITY, FITNESS FOR A PARTICULAR339 PURPOSE, NON-INFRINGEMENT, ABSENCE OF LATENT OR OTHER DEFECTS,340 ACCURACY, OR THE PRESENCE OR ABSENCE OF ERRORS, WHETHER OR NOT341 KNOWN OR DISCOVERABLE. WHERE DISCLAIMERS OF WARRANTIES ARE NOT342 ALLOWED IN FULL OR IN PART, THIS DISCLAIMER MAY NOT APPLY TO YOU.343 344 b. TO THE EXTENT POSSIBLE, IN NO EVENT WILL THE LICENSOR BE LIABLE345 TO YOU ON ANY LEGAL THEORY (INCLUDING, WITHOUT LIMITATION,346 NEGLIGENCE) OR OTHERWISE FOR ANY DIRECT, SPECIAL, INDIRECT,347 INCIDENTAL, CONSEQUENTIAL, PUNITIVE, EXEMPLARY, OR OTHER LOSSES,348 COSTS, EXPENSES, OR DAMAGES ARISING OUT OF THIS PUBLIC LICENSE OR349 USE OF THE LICENSED MATERIAL, EVEN IF THE LICENSOR HAS BEEN350 ADVISED OF THE POSSIBILITY OF SUCH LOSSES, COSTS, EXPENSES, OR351 DAMAGES. WHERE A LIMITATION OF LIABILITY IS NOT ALLOWED IN FULL OR352 IN PART, THIS LIMITATION MAY NOT APPLY TO YOU.353 354 c. The disclaimer of warranties and limitation of liability provided355 above shall be interpreted in a manner that, to the extent356 possible, most closely approximates an absolute disclaimer and357 waiver of all liability.358 359 360Section 6 -- Term and Termination.361 362 a. This Public License applies for the term of the Copyright and363 Similar Rights licensed here. However, if You fail to comply with364 this Public License, then Your rights under this Public License365 terminate automatically.366 367 b. Where Your right to use the Licensed Material has terminated under368 Section 6(a), it reinstates:369 370 1. automatically as of the date the violation is cured, provided371 it is cured within 30 days of Your discovery of the372 violation; or373 374 2. upon express reinstatement by the Licensor.375 376 For the avoidance of doubt, this Section 6(b) does not affect any377 right the Licensor may have to seek remedies for Your violations378 of this Public License.379 380 c. For the avoidance of doubt, the Licensor may also offer the381 Licensed Material under separate terms or conditions or stop382 distributing the Licensed Material at any time; however, doing so383 will not terminate this Public License.384 385 d. Sections 1, 5, 6, 7, and 8 survive termination of this Public386 License.387 388 389Section 7 -- Other Terms and Conditions.390 391 a. The Licensor shall not be bound by any additional or different392 terms or conditions communicated by You unless expressly agreed.393 394 b. Any arrangements, understandings, or agreements regarding the395 Licensed Material not stated herein are separate from and396 independent of the terms and conditions of this Public License.397 398 399Section 8 -- Interpretation.400 401 a. For the avoidance of doubt, this Public License does not, and402 shall not be interpreted to, reduce, limit, restrict, or impose403 conditions on any use of the Licensed Material that could lawfully404 be made without permission under this Public License.405 406 b. To the extent possible, if any provision of this Public License is407 deemed unenforceable, it shall be automatically reformed to the408 minimum extent necessary to make it enforceable. If the provision409 cannot be reformed, it shall be severed from this Public License410 without affecting the enforceability of the remaining terms and411 conditions.412 413 c. No term or condition of this Public License will be waived and no414 failure to comply consented to unless expressly agreed to by the415 Licensor.416 417 d. Nothing in this Public License constitutes or may be interpreted418 as a limitation upon, or waiver of, any privileges and immunities419 that apply to the Licensor or You, including from the legal420 processes of any jurisdiction or authority.421 422 423=======================================================================424 425Creative Commons is not a party to its public licenses.426Notwithstanding, Creative Commons may elect to apply one of its public427licenses to material it publishes and in those instances will be428considered the “Licensor.” The text of the Creative Commons public429licenses is dedicated to the public domain under the CC0 Public Domain430Dedication. Except for the limited purpose of indicating that material431is shared under a Creative Commons public license or as otherwise432permitted by the Creative Commons policies published at433creativecommons.org/policies, Creative Commons does not authorize the434use of the trademark "Creative Commons" or any other trademark or logo435of Creative Commons without its prior written consent including,436without limitation, in connection with any unauthorized modifications437to any of its public licenses or any other arrangements,438understandings, or agreements concerning use of licensed material. For439the avoidance of doubt, this paragraph does not form part of the public440licenses.441 442Creative Commons may be contacted at creativecommons.org.443"""444# version 1.0445_URL0 = "https://amazon-massive-nlu-dataset.s3.amazonaws.com/amazon-massive-dataset-1.0.tar.gz"446# version 1.1447_URL1 = "https://amazon-massive-nlu-dataset.s3.amazonaws.com/amazon-massive-dataset-1.1.tar.gz"448 449# version 1.0450_LANGUAGES0 = ['af-ZA', 'am-ET', 'ar-SA', 'az-AZ', 'bn-BD', 'cy-GB', 'da-DK', 'de-DE', 'el-GR', 'en-US',451 'es-ES', 'fa-IR', 'fi-FI', 'fr-FR', 'he-IL', 'hi-IN', 'hu-HU', 'hy-AM', 'id-ID', 'is-IS',452 'it-IT', 'ja-JP', 'jv-ID', 'ka-GE', 'km-KH', 'kn-IN', 'ko-KR', 'lv-LV', 'ml-IN', 'mn-MN',453 'ms-MY', 'my-MM', 'nb-NO', 'nl-NL', 'pl-PL', 'pt-PT', 'ro-RO', 'ru-RU', 'sl-SL', 'sq-AL',454 'sv-SE', 'sw-KE', 'ta-IN', 'te-IN', 'th-TH', 'tl-PH', 'tr-TR', 'ur-PK', 'vi-VN', 'zh-CN',455 'zh-TW']456 457# version 1.1 ('ca-ES' added)458_LANGUAGES1 = sorted(_LANGUAGES0 + ['ca-ES'])459 460_SCENARIOS = ['social', 'transport', 'calendar', 'play', 'news', 'datetime', 'recommendation', 'email',461 'iot', 'general', 'audio', 'lists', 'qa', 'cooking', 'takeaway', 'music', 'alarm', 'weather']462 463_INTENTS = ['datetime_query', 'iot_hue_lightchange', 'transport_ticket', 'takeaway_query', 'qa_stock',464 'general_greet', 'recommendation_events', 'music_dislikeness', 'iot_wemo_off', 'cooking_recipe',465 'qa_currency', 'transport_traffic', 'general_quirky', 'weather_query', 'audio_volume_up',466 'email_addcontact', 'takeaway_order', 'email_querycontact', 'iot_hue_lightup',467 'recommendation_locations', 'play_audiobook', 'lists_createoradd', 'news_query',468 'alarm_query', 'iot_wemo_on', 'general_joke', 'qa_definition', 'social_query',469 'music_settings', 'audio_volume_other', 'calendar_remove', 'iot_hue_lightdim',470 'calendar_query', 'email_sendemail', 'iot_cleaning', 'audio_volume_down',471 'play_radio', 'cooking_query', 'datetime_convert', 'qa_maths', 'iot_hue_lightoff',472 'iot_hue_lighton', 'transport_query', 'music_likeness', 'email_query', 'play_music',473 'audio_volume_mute', 'social_post', 'alarm_set', 'qa_factoid', 'calendar_set',474 'play_game', 'alarm_remove', 'lists_remove', 'transport_taxi', 'recommendation_movies',475 'iot_coffee', 'music_query', 'play_podcasts', 'lists_query']476 477_ALL = "all"478 479 480class MassiveConfig(datasets.BuilderConfig):481 """BuilderConfig for MASSIVE."""482 483 def __init__(self, dataset_version=None, *args, **kwargs):484 """BuilderConfig for MASSIVE.485 Args:486 **kwargs: keyword arguments forwarded to super.487 """488 super(MassiveConfig, self).__init__(*args, **kwargs)489 self.dataset_version = dataset_version if dataset_version else "1.0"490 self.data_url = _URL0 if self.dataset_version == "1.0" else _URL1491 492 493class MASSIVE(datasets.GeneratorBasedBuilder):494 """MASSIVE: A 1M-Example Multilingual Natural Language Understanding Dataset with 51 Typologically-Diverse Languages"""495 496 # All individual locale datasets are served from the latest version.497 BUILDER_CONFIGS = [498 MassiveConfig(499 name = name,500 dataset_version = '1.1',501 version = datasets.Version("1.0.0"),502 description = f"The MASSIVE v1.1 corpora for {name}",503 ) for name in _LANGUAGES1504 ]505 # Version 1.0506 BUILDER_CONFIGS.append(MassiveConfig(507 name = _ALL,508 dataset_version = '1.0',509 version = datasets.Version("1.0.0"),510 description = f"The MASSIVE v1.0 corpora for entire corpus",511 )512 )513 # Version 1.1514 BUILDER_CONFIGS.append(MassiveConfig(515 name = _ALL + '_1.1', # Append '_1.1' to 'all' in order to get the latest version.516 dataset_version = '1.1',517 version = datasets.Version("1.0.0"),518 description = f"The MASSIVE v1.1 corpora for entire corpus",519 )520 )521 522 DEFAULT_CONFIG_NAME = _ALL523 524 def _info(self):525 return datasets.DatasetInfo(526 description=_DESCRIPTION,527 features=datasets.Features(528 {529 "id": datasets.Value("string"),530 "locale": datasets.Value("string"),531 "partition": datasets.Value("string"),532 "scenario": datasets.features.ClassLabel(names=_SCENARIOS),533 "intent": datasets.features.ClassLabel(names=_INTENTS),534 "utt": datasets.Value("string"),535 "annot_utt": datasets.Value("string"),536 "worker_id": datasets.Value("string"),537 "slot_method": datasets.Sequence({538 "slot": datasets.Value("string"),539 "method": datasets.Value("string"),540 }),541 "judgments": datasets.Sequence({542 "worker_id": datasets.Value("string"),543 "intent_score": datasets.Value("int8"),544 "slots_score": datasets.Value("int8"),545 "grammar_score": datasets.Value("int8"),546 "spelling_score": datasets.Value("int8"),547 "language_identification": datasets.Value("string"),548 }),549 },550 ),551 supervised_keys=None,552 homepage="https://github.com/alexa/massive",553 citation=_CITATION,554 license=_LICENSE,555 )556 557 def _split_generators(self, dl_manager):558 559 archive = dl_manager.download(self.config.data_url)560 return [561 datasets.SplitGenerator(562 name=datasets.Split.TRAIN,563 gen_kwargs={564 "files": dl_manager.iter_archive(archive),565 "split": "train",566 "lang": self.config.name,567 }568 ),569 datasets.SplitGenerator(570 name=datasets.Split.VALIDATION,571 gen_kwargs={572 "files": dl_manager.iter_archive(archive),573 "split": "dev",574 "lang": self.config.name,575 }576 ),577 datasets.SplitGenerator(578 name=datasets.Split.TEST,579 gen_kwargs={580 "files": dl_manager.iter_archive(archive),581 "split": "test",582 "lang": self.config.name,583 }584 ),585 ]586 587 def _generate_examples(self, files, split, lang):588 589 key_ = 0590 591 if lang == "all_1.1":592 lang = _LANGUAGES1.copy()593 elif lang == "all":594 lang = _LANGUAGES0.copy()595 else:596 lang = [lang]597 598 logger.info("⏳ Generating examples from = %s", ", ".join(lang))599 600 for path, f in files:601 602 l = path.split("/")[-1].split(".")[0]603 604 if not lang:605 break606 elif l in lang:607 lang.remove(l)608 else:609 continue610 611 # Read the file612 lines = f.read().decode(encoding="utf-8").split("\n")613 614 for line in lines:615 616 data = json.loads(line)617 618 if data["partition"] != split:619 continue620 621 # Slot method622 if "slot_method" in data:623 slot_method = [624 {625 "slot": s["slot"],626 "method": s["method"],627 } for s in data["slot_method"]628 ]629 else:630 slot_method = []631 632 # Judgments633 if "judgments" in data:634 judgments = [635 {636 "worker_id": j["worker_id"],637 "intent_score": j["intent_score"],638 "slots_score": j["slots_score"],639 "grammar_score": j["grammar_score"],640 "spelling_score": j["spelling_score"],641 "language_identification": j["language_identification"] if "language_identification" in j else "target",642 } for j in data["judgments"]643 ]644 else:645 judgments = []646 647 yield key_, {648 "id": data["id"],649 "locale": data["locale"],650 "partition": data["partition"],651 "scenario": data["scenario"],652 "intent": data["intent"],653 "utt": data["utt"],654 "annot_utt": data["annot_utt"],655 "worker_id": data["worker_id"],656 "slot_method": slot_method,657 "judgments": judgments,658 }659 660 key_ += 1661 