class_docstr: Dataset used in the main NLU training API
  
  Consists of intents and entities data. This object can be built either from
  text files (:meth:`.Dataset.from_files`) or from YAML files
  (:meth:`.Dataset.from_yaml_files`).
  
  Attributes:
      language (str): language of the intents
      intents (list of :class:`.Intent`): intents data
      entities (list of :class:`.Entity`): entities data
docstr: Creates a :class:`.Dataset` from a language and a list of YAML files
  or streams containing intents and entities data
  
  Each file need not correspond to a single entity nor intent. They can
  consist in several entities and intents merged together in a single
  file.
  
  Args:
      language (str): language of the dataset (ISO639-1)
      filenames (iterable): filenames or stream objects corresponding to
          intents and entities data.
  
  Example:
  
      A dataset can be defined with a YAML document following the schema
      illustrated in the example below:
  
      >>> import io
      >>> from snips_nlu.common.utils import json_string
      >>> dataset_yaml = io.StringIO('''
      ... # searchFlight Intent
      ... ---
      ... type: intent
      ... name: searchFlight
      ... slots:
      ...   - name: origin
      ...     entity: city
      ...   - name: destination
      ...     entity: city
      ...   - name: date
      ...     entity: snips/datetime
      ... utterances:
      ...   - find me a flight from [origin](Oslo) to [destination](Lima)
      ...   - I need a flight leaving to [destination](Berlin)
      ...
      ... # City Entity
      ... ---
      ... type: entity
      ... name: city
      ... values:
      ...   - london
      ...   - [paris, city of lights]''')
      >>> dataset = Dataset.from_yaml_files("en", [dataset_yaml])
      >>> print(json_string(dataset.json, indent=4, sort_keys=True))
      {
          "entities": {
              "city": {
                  "automatically_extensible": true,
                  "data": [
                      {
                          "synonyms": [],
                          "value": "london"
                      },
                      {
                          "synonyms": [
                              "city of lights"
                          ],
                          "value": "paris"
                      }
                  ],
                  "matching_strictness": 1.0,
                  "use_synonyms": true
              }
          },
          "intents": {
              "searchFlight": {
                  "utterances": [
                      {
                          "data": [
                              {
                                  "text": "find me a flight from "
                              },
                              {
                                  "entity": "city",
                                  "slot_name": "origin",
                                  "text": "Oslo"
                              },
                              {
                                  "text": " to "
                              },
                              {
                                  "entity": "city",
                                  "slot_name": "destination",
                                  "text": "Lima"
                              }
                          ]
                      },
                      {
                          "data": [
                              {
                                  "text": "I need a flight leaving to "
                              },
                              {
                                  "entity": "city",
                                  "slot_name": "destination",
                                  "text": "Berlin"
                              }
                          ]
                      }
                  ]
              }
          },
          "language": "en"
      }
  
  Raises:
      DatasetFormatError: When one of the documents present in the YAML
          files has a wrong 'type' attribute, which is not 'entity' nor
          'intent'
      IntentFormatError: When the YAML document of an intent does not
          correspond to the
          :ref:`expected intent format <yaml_intent_format>`
      EntityFormatError: When the YAML document of an entity does not
          correspond to the
          :ref:`expected entity format <yaml_entity_format>`
docstr_tok: ["Creates","a",":","class",":","`",".Dataset","`","from","a","language","and","a","list","of","YAML","files","or","streams","containing","intents","and","entities","data","Each","file","need","not","correspond","to","a","single","entity","nor","intent",".","They","can","consist","in","several","entities","and","intents","merged","together","in","a","single","file",".","Args",":","language","(","str",")",":","language","of","the","dataset","(","ISO639-1",")","filenames","(","iterable",")",":","filenames","or","stream","objects","corresponding","to","intents","and","entities","data",".","Example",":","A","dataset","can","be","defined","with","a","YAML","document","following","the","schema","illustrated","in","the","example","below",":",">",">",">","import","io",">",">",">","from","snips_nlu.common.utils","import","json_string",">",">",">","dataset_yaml","=","io.StringIO","(","``","'","...","#","searchFlight","Intent","...","--","-","...","type",":","intent","...","name",":","searchFlight","...","slots",":","...","-","name",":","origin","...","entity",":","city","...","-","name",":","destination","...","entity",":","city","...","-","name",":","date","...","entity",":","snips\/datetime","...","utterances",":","...","-","find","me","a","flight","from","[","origin","]","(","Oslo",")","to","[","destination","]","(","Lima",")","...","-","I","need","a","flight","leaving","to","[","destination","]","(","Berlin",")","...","...","#","City","Entity","...","--","-","...","type",":","entity","...","name",":","city","...","values",":","...","-","london","...","-","[","paris",",","city","of","lights","]","''","'",")",">",">",">","dataset","=","Dataset.from_yaml_files","(","``","en","''",",","[","dataset_yaml","]",")",">",">",">","print","(","json_string","(","dataset.json",",","indent=4",",","sort_keys=True",")",")","{","``","entities","''",":","{","``","city","''",":","{","``","automatically_extensible","''",":","true",",","``","data","''",":","[","{","``","synonyms","''",":","[","]",",","``","value","''",":","``","london","''","}",",","{","``","synonyms","''",":","[","``","city","of","lights","''","]",",","``","value","''",":","``","paris","''","}","]",",","``","matching_strictness","''",":","1.0",",","``","use_synonyms","''",":","true","}","}",",","``","intents","''",":","{","``","searchFlight","''",":","{","``","utterances","''",":","[","{","``","data","''",":","[","{","``","text","''",":","``","find","me","a","flight","from","``","}",",","{","``","entity","''",":","``","city","''",",","``","slot_name","''",":","``","origin","''",",","``","text","''",":","``","Oslo","''","}",",","{","``","text","''",":","``","to","``","}",",","{","``","entity","''",":","``","city","''",",","``","slot_name","''",":","``","destination","''",",","``","text","''",":","``","Lima","''","}","]","}",",","{","``","data","''",":","[","{","``","text","''",":","``","I","need","a","flight","leaving","to","``","}",",","{","``","entity","''",":","``","city","''",",","``","slot_name","''",":","``","destination","''",",","``","text","''",":","``","Berlin","''","}","]","}","]","}","}",",","``","language","''",":","``","en","''","}","Raises",":","DatasetFormatError",":","When","one","of","the","documents","present","in","the","YAML","files","has","a","wrong","'type","'","attribute",",","which","is","not","'entity","'","nor","'intent'","IntentFormatError",":","When","the","YAML","document","of","an","intent","does","not","correspond","to","the",":","ref",":","`","expected","intent","format","<","yaml_intent_format",">","`","EntityFormatError",":","When","the","YAML","document","of","an","entity","does","not","correspond","to","the",":","ref",":","`","expected","entity","format","<","yaml_entity_format",">","`"]
code: def from_yaml_files(cls, language, filenames):
      """Creates a :class:`.Dataset` from a language and a list of YAML files
      or streams containing intents and entities data
  
      Each file need not correspond to a single entity nor intent. They can
      consist in several entities and intents merged together in a single
      file.
  
      Args:
          language (str): language of the dataset (ISO639-1)
          filenames (iterable): filenames or stream objects corresponding to
              intents and entities data.
  
      Example:
  
          A dataset can be defined with a YAML document following the schema
          illustrated in the example below:
  
          >>> import io
          >>> from snips_nlu.common.utils import json_string
          >>> dataset_yaml = io.StringIO('''
          ... # searchFlight Intent
          ... ---
          ... type: intent
          ... name: searchFlight
          ... slots:
          ...   - name: origin
          ...     entity: city
          ...   - name: destination
          ...     entity: city
          ...   - name: date
          ...     entity: snips/datetime
          ... utterances:
          ...   - find me a flight from [origin](Oslo) to [destination](Lima)
          ...   - I need a flight leaving to [destination](Berlin)
          ...
          ... # City Entity
          ... ---
          ... type: entity
          ... name: city
          ... values:
          ...   - london
          ...   - [paris, city of lights]''')
          >>> dataset = Dataset.from_yaml_files("en", [dataset_yaml])
          >>> print(json_string(dataset.json, indent=4, sort_keys=True))
          {
              "entities": {
                  "city": {
                      "automatically_extensible": true,
                      "data": [
                          {
                              "synonyms": [],
                              "value": "london"
                          },
                          {
                              "synonyms": [
                                  "city of lights"
                              ],
                              "value": "paris"
                          }
                      ],
                      "matching_strictness": 1.0,
                      "use_synonyms": true
                  }
              },
              "intents": {
                  "searchFlight": {
                      "utterances": [
                          {
                              "data": [
                                  {
                                      "text": "find me a flight from "
                                  },
                                  {
                                      "entity": "city",
                                      "slot_name": "origin",
                                      "text": "Oslo"
                                  },
                                  {
                                      "text": " to "
                                  },
                                  {
                                      "entity": "city",
                                      "slot_name": "destination",
                                      "text": "Lima"
                                  }
                              ]
                          },
                          {
                              "data": [
                                  {
                                      "text": "I need a flight leaving to "
                                  },
                                  {
                                      "entity": "city",
                                      "slot_name": "destination",
                                      "text": "Berlin"
                                  }
                              ]
                          }
                      ]
                  }
              },
              "language": "en"
          }
  
      Raises:
          DatasetFormatError: When one of the documents present in the YAML
              files has a wrong 'type' attribute, which is not 'entity' nor
              'intent'
          IntentFormatError: When the YAML document of an intent does not
              correspond to the
              :ref:`expected intent format <yaml_intent_format>`
          EntityFormatError: When the YAML document of an entity does not
              correspond to the
              :ref:`expected entity format <yaml_entity_format>`
      """
      language = unicode_string(language)
      entities = []
      intents = []
      for filename in filenames:
          if isinstance(filename, io.IOBase):
              intents_, entities_ = cls._load_dataset_parts(
                  filename, "stream object"
              )
          else:
              with io.open(filename, encoding="utf8") as f:
                  intents_, entities_ = cls._load_dataset_parts(
                      f, filename
                  )
          intents += intents_
          entities += entities_
      return cls(language, intents, entities)
  
file_path: snips-nlu/snips_nlu/dataset/dataset.py
imports: from __future__ import print_function, unicode_literals
  import io
  from itertools import cycle
  from snips_nlu.common.utils import unicode_string
  from snips_nlu.dataset.entity import Entity
  from snips_nlu.dataset.intent import Intent
  from snips_nlu.exceptions import DatasetFormatError
label_desc: Use image node_id 2 for calling the Dataset obj's underlying member method code with example usage: obj.from_yaml_files(cls, language, filenames) and returns: cls