c1ba10f9e950fadde16a1c621d97a863d9366038,custom_intent_parser/intent_parser/regex_intent_parser.py,RegexIntentParser,_update_cache,#RegexIntentParser#Any#,43

Before Change


        entities = self.entity_extractor.get_entities(text)

        if len(entities) == 0:
            res = {
                "text": text,
                "entities": [],
                "intent": None
            }
            self._cache[text] = res
            return

        intent_probs = defaultdict(int)
        num_intents = 0.
        for e in entities:
            intent_probs[e["intent"]] += 1.
            num_intents += 1.

        for k, v in intent_probs.iteritems():
            intent_probs[k] /= num_intents

        top_intent, top_prob = sorted(intent_probs.items(),
                                      key=operator.itemgetter(1),
                                      reverse=True)[0]
        result = {
            "text": text,
            "entities": entities,
            "intent": {
                "name": top_intent,
                "prob": top_prob,
            }
        }
        self._cache[text] = result

After Change


        entities = self.entity_extractor.get_entities(text)

        if len(entities) == 0:
            res = result(text)
            self._cache[text] = res
            return

        intent_probs = defaultdict(int)
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 3

Instances


Project Name: snipsco/snips-nlu
Commit Name: c1ba10f9e950fadde16a1c621d97a863d9366038
Time: 2017-02-24
Author: clement.doumouro@snips.ai
File Name: custom_intent_parser/intent_parser/regex_intent_parser.py
Class Name: RegexIntentParser
Method Name: _update_cache


Project Name: snipsco/snips-nlu
Commit Name: 2e2e8d2ca323ab447656cdda755ee2e8b018c901
Time: 2017-03-24
Author: adrien.ball@snips.net
File Name: snips_nlu/tests/test_regex_intent_parser.py
Class Name: TestRegexIntentParser
Method Name: test_should_parse


Project Name: snipsco/snips-nlu
Commit Name: 09124c74cc53726a4ae873e91c060979f9fdaeb7
Time: 2017-03-24
Author: tristan.deleu@gmail.com
File Name: snips_nlu/intent_parser/builtin_intent_parser.py
Class Name: BuiltinIntentParser
Method Name: _parse


Project Name: snipsco/snips-nlu
Commit Name: c1ba10f9e950fadde16a1c621d97a863d9366038
Time: 2017-02-24
Author: clement.doumouro@snips.ai
File Name: custom_intent_parser/intent_parser/regex_intent_parser.py
Class Name: RegexIntentParser
Method Name: _update_cache