class_docstr: Intent parser using pattern matching in a deterministic manner
  
  This intent parser is very strict by nature, and tends to have a very good
  precision but a low recall. For this reason, it is interesting to use it
  first before potentially falling back to another parser.
class_docstr_tok: ["Intent","parser","using","pattern","matching","in","a","deterministic","manner","This","intent","parser","is","very","strict","by","nature",",","and","tends","to","have","a","very","good","precision","but","a","low","recall",".","For","this","reason",",","it","is","interesting","to","use","it","first","before","potentially","falling","back","to","another","parser","."]
code: def _parse_top_intents(self, text, top_n, intents=None):
      if isinstance(intents, str):
          intents = {intents}
      elif isinstance(intents, list):
          intents = set(intents)
  
      if top_n < 1:
          raise ValueError(
              "top_n argument must be greater or equal to 1, but got: %s"
              % top_n
          )
  
      def placeholder_fn(entity_name):
          return _get_entity_name_placeholder(
              entity_name, self.language
          )
  
      results = []
  
      for intent, entity_scope in iteritems(self.entity_scopes):
          if intents is not None and intent not in intents:
              continue
          builtin_entities = self.builtin_entity_parser.parse(
              text, scope=entity_scope["builtin"], use_cache=True
          )
          custom_entities = self.custom_entity_parser.parse(
              text, scope=entity_scope["custom"], use_cache=True
          )
          all_entities = builtin_entities + custom_entities
          mapping, processed_text = replace_entities_with_placeholders(
              text, all_entities, placeholder_fn=placeholder_fn
          )
          cleaned_text = self._preprocess_text(text, intent)
          cleaned_processed_text = self._preprocess_text(
              processed_text, intent
          )
          for regex in self.regexes_per_intent[intent]:
              res = self._get_matching_result(
                  text, cleaned_text, regex, intent
              )
              if res is None and cleaned_text != cleaned_processed_text:
                  res = self._get_matching_result(
                      text,
                      cleaned_processed_text,
                      regex,
                      intent,
                      mapping,
                  )
  
              if res is not None:
                  results.append(res)
                  break
  
      # In some rare cases there can be multiple ambiguous intents
      # In such cases, priority is given to results containing fewer slots
      weights = [1.0 / (1.0 + len(res[RES_SLOTS])) for res in results]
      total_weight = sum(weights)
  
      for res, weight in zip(results, weights):
          res[RES_INTENT][RES_PROBA] = weight / total_weight
  
      results = sorted(results, key=lambda r: -r[RES_INTENT][RES_PROBA])
  
      return results[:top_n]
  
imports: from __future__ import unicode_literals
  import json
  import logging
  import re
  from builtins import str
  from collections import defaultdict
  from pathlib import Path
  from future.utils import iteritems, itervalues
  from snips_nlu.common.dataset_utils import get_slot_name_mappings
  from snips_nlu.common.log_utils import log_elapsed_time, log_result
  from snips_nlu.common.utils import check_persisted_path, deduplicate_overlapping_items, fitted_required, json_string, ranges_overlap, regex_escape, replace_entities_with_placeholders
  from snips_nlu.constants import DATA, END, ENTITIES, ENTITY, INTENTS, LANGUAGE, RES_INTENT, RES_INTENT_NAME, RES_MATCH_RANGE, RES_SLOTS, RES_VALUE, SLOT_NAME, START, TEXT, UTTERANCES, RES_PROBA
  from snips_nlu.dataset import validate_and_format_dataset
  from snips_nlu.dataset.utils import get_stop_words_whitelist
  from snips_nlu.entity_parser.builtin_entity_parser import is_builtin_entity
  from snips_nlu.exceptions import IntentNotFoundError, LoadingError
  from snips_nlu.intent_parser.intent_parser import IntentParser
  from snips_nlu.pipeline.configs import DeterministicIntentParserConfig
  from snips_nlu.preprocessing import normalize_token, tokenize, tokenize_light
  from snips_nlu.resources import get_stop_words
  from snips_nlu.result import empty_result, extraction_result, intent_classification_result, parsing_result, unresolved_slot
label_desc: Use image node_id 13 for calling the DeterministicIntentParser obj's underlying member method code with example usage: obj._parse_top_intents(text, top_n, intents) and returns: results, _get_entity_name_placeholder