Esempio n. 1
0
    def init_slots(self):
        """skill name

        :return: <dict> slots dict
        """
        return {
            Tag.name(): Tag(),
            TimeInterval.name(): TimeInterval(),
            Company.name(): Company()
        }
Esempio n. 2
0
 def transform(self, context):
     entities = context["entities"]
     rst = []
     if Company.name() in entities.keys():
         for alias in entities[Company.name()]:
             c = Company()
             c["alias"] = alias
             c["id"] = self.alias2id[alias]
             rst.append(c)
         return rst
     else:
         return None
Esempio n. 3
0
    def extract(self, context):
        """
        :param context: context["query"]
        :return: <dict of list>
        {"TimeInterval": ["", ""]}

        """
        rst = {}
        ext_time = self.ner_time.extract(context)
        ext_location = self.ner_loc.extract(context)
        ext_company = self.ner_company.extract(context)
        ext_tag = self.ner_tag.extract(context)
        if ext_time is not None:
            rst[TimeInterval.name()] = ext_time
            logger.debug("extract time %s" % " ".join(ext_time))
        if ext_location is not None:
            rst[Location.name()] = ext_location
            logger.debug("extract loc {}".format(ext_location))
        if ext_company is not None:
            rst[Company.name()] = ext_company
            logger.debug("extract company %s" % " ".join(ext_company))
        if ext_tag is not None:
            rst[Tag.name()] = ext_tag
            # logger.debug("extract tag %s" % " ".join(ext_tag))
        return rst
Esempio n. 4
0
 def __call__(self, context):
     t = context["slots"][context["intent"]][TimeInterval.name()]
     p = context["slots"][context["intent"]][Company.name()]
     return "您在查询{}至{}的,{}用电数据".format(
         t["start"],
         t["end"],
         p["alias"]
     )
Esempio n. 5
0
 def transform(self, context):
     """
     :param context: context['query']
     :return: dict of list
     [{'end':'2018-06-13','start':'2018-06-13'}]
     """
     rst = {}
     trans_time = self.ner_time.transform(context)
     trans_location = self.ner_loc.transform(context)
     trans_company = self.ner_company.transform(context)
     trans_tag = self.ner_tag.transform(context)
     if trans_time is not None:
         rst[TimeInterval.name()] = trans_time
     if trans_location is not None:
         rst[Location.name()] = trans_location
     if trans_company is not None:
         rst[Company.name()] = trans_company
     if trans_tag is not None:
         rst[Tag.name()] = trans_tag
     return rst
 def init_slots(self):
     return {TimeInterval.name(): TimeInterval(), Company.name(): Company()}