code: def bspan_to_constraint_dict(self, bspan, bspn_mode="bspn"):
      bspan = bspan.split() if isinstance(bspan, str) else bspan
      constraint_dict = {}
      domain = None
      conslen = len(bspan)
      for idx, cons in enumerate(bspan):
          cons = (
              self.vocab.decode(cons) if type(cons) is not str else cons
          )
          if cons == "<eos_b>":
              break
          if "[" in cons:
              if cons[1:-1] not in ontology.all_domains:
                  continue
              domain = cons[1:-1]
          elif cons in ontology.get_slot:
              if domain is None:
                  continue
              if cons == "people":
                  # handle confusion of value name "people's portraits..." and slot people
                  try:
                      ns = bspan[idx + 1]
                      ns = (
                          self.vocab.decode(ns)
                          if type(ns) is not str
                          else ns
                      )
                      if ns == "'s":
                          continue
                  except:
                      continue
              if not constraint_dict.get(domain):
                  constraint_dict[domain] = {}
              if bspn_mode == "bsdx":
                  constraint_dict[domain][cons] = 1
                  continue
              vidx = idx + 1
              if vidx == conslen:
                  break
              vt_collect = []
              vt = bspan[vidx]
              vt = self.vocab.decode(vt) if type(vt) is not str else vt
              while (
                  vidx < conslen
                  and vt != "<eos_b>"
                  and "[" not in vt
                  and vt not in ontology.get_slot
              ):
                  vt_collect.append(vt)
                  vidx += 1
                  if vidx == conslen:
                      break
                  vt = bspan[vidx]
                  vt = (
                      self.vocab.decode(vt)
                      if type(vt) is not str
                      else vt
                  )
              if vt_collect:
                  constraint_dict[domain][cons] = " ".join(vt_collect)
  
      return constraint_dict
  
file_path: TextBox/textbox/evaluator/utils/multiwoz/reader.py
imports: import logging
  import json
  import spacy
  from collections import OrderedDict
  from .None import utils
  from .None import ontology
  from .db_ops import MultiWozDB
label_desc: Use image node_id 4 for calling the MultiWozReader obj's underlying member method code with example usage: obj.bspan_to_constraint_dict(bspan, bspn_mode) and returns: constraint_dict