class_docstr: Intent data of a :class:`.Dataset`
  
  Attributes:
      intent_name (str): name of the intent
      utterances (list of :class:`.IntentUtterance`): annotated intent
          utterances
      slot_mapping (dict): mapping between slot names and entities
class_docstr_tok: ["Intent","data","of","a",":","class",":","`",".Dataset","`","Attributes",":","intent_name","(","str",")",":","name","of","the","intent","utterances","(","list","of",":","class",":","`",".IntentUtterance","`",")",":","annotated","intent","utterances","slot_mapping","(","dict",")",":","mapping","between","slot","names","and","entities"]
docstr: Build an :class:`.Intent` from its YAML definition object
  
  Args:
      yaml_dict (dict or :class:`.IOBase`): object containing the YAML
          definition of the intent. It can be either a stream, or the
          corresponding python dict.
  
  Examples:
      An intent 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
      >>> intent_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)''')
      >>> intent = Intent.from_yaml(intent_yaml)
      >>> print(json_string(intent.json, indent=4, sort_keys=True))
      {
          "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"
                      }
                  ]
              }
          ]
      }
  
  Raises:
      IntentFormatError: When the YAML dict does not correspond to the
          :ref:`expected intent format <yaml_intent_format>`
docstr_tok: ["Build","an",":","class",":","`",".Intent","`","from","its","YAML","definition","object","Args",":","yaml_dict","(","dict","or",":","class",":","`",".IOBase","`",")",":","object","containing","the","YAML","definition","of","the","intent",".","It","can","be","either","a","stream",",","or","the","corresponding","python","dict",".","Examples",":","An","intent","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",">",">",">","intent_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",")","''","'",")",">",">",">","intent","=","Intent.from_yaml","(","intent_yaml",")",">",">",">","print","(","json_string","(","intent.json",",","indent=4",",","sort_keys=True",")",")","{","``","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","''","}","]","}","]","}","Raises",":","IntentFormatError",":","When","the","YAML","dict","does","not","correspond","to","the",":","ref",":","`","expected","intent","format","<","yaml_intent_format",">","`"]
code: def from_yaml(cls, yaml_dict):
      """Build an :class:`.Intent` from its YAML definition object
  
      Args:
          yaml_dict (dict or :class:`.IOBase`): object containing the YAML
              definition of the intent. It can be either a stream, or the
              corresponding python dict.
  
      Examples:
          An intent 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
          >>> intent_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)''')
          >>> intent = Intent.from_yaml(intent_yaml)
          >>> print(json_string(intent.json, indent=4, sort_keys=True))
          {
              "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"
                          }
                      ]
                  }
              ]
          }
  
      Raises:
          IntentFormatError: When the YAML dict does not correspond to the
              :ref:`expected intent format <yaml_intent_format>`
      """
  
      if isinstance(yaml_dict, IOBase):
          from snips_nlu.dataset.yaml_wrapper import yaml
  
          yaml_dict = yaml.safe_load(yaml_dict)
  
      object_type = yaml_dict.get("type")
      if object_type and object_type != "intent":
          raise IntentFormatError("Wrong type: '%s'" % object_type)
      intent_name = yaml_dict.get("name")
      if not intent_name:
          raise IntentFormatError("Missing 'name' attribute")
      slot_mapping = dict()
      for slot in yaml_dict.get("slots", []):
          slot_mapping[slot["name"]] = slot["entity"]
      utterances = [
          IntentUtterance.parse(u.strip())
          for u in yaml_dict["utterances"]
          if u.strip()
      ]
      if not utterances:
          raise IntentFormatError(
              "Intent must contain at least one utterance"
          )
      return cls(intent_name, utterances, slot_mapping)
  
imports: from __future__ import absolute_import, print_function, unicode_literals
  from abc import ABCMeta, abstractmethod
  from builtins import object
  from io import IOBase
  from future.utils import with_metaclass
  from snips_nlu.constants import DATA, ENTITY, SLOT_NAME, TEXT, UTTERANCES
  from snips_nlu.exceptions import IntentFormatError
label_desc: Use image node_id 2 for calling the Intent obj's underlying member method code with example usage: obj.from_yaml(cls, yaml_dict) and returns: cls