How to use the nlu.messages.msgutils.extract_junction function in nlu

To help you get started, we’ve selected a few nlu examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github JoshRosen / cmps140_creative_cooking_assistant / nlu / messages / search_message.py View on Github external
frameItem = {}
            frameItem['id'] = i
            frameItem['name'] = meal
            frameItem['descriptor'] = [] # TODO: siblings JJ
            frameItem['preference'] = 0 # TODO: RB = not or n't
            frameItem['relationship'] = extract_junction(parseTree, meal)
            self.frame['meal'].append(frameItem)
            
        # Cuisine
        for i, cuisine in get_cuisines(tokenized_string, enum=True):
            frameItem = {}
            frameItem['id'] = i
            frameItem['name'] = cuisine
            frameItem['descriptor'] = [] # TODO: siblings JJ
            frameItem['preference'] = 0 # TODO: RB = not or n't
            frameItem['relationship'] = extract_junction(parseTree, cuisine)
            self.frame['cuisine'].append(frameItem)
            
        # Dish
        dishesSet = []
        # add sentence subjects which aren't already ingredients or meals
        #TODO: Set extract_subject_nodes to hanle multiple phrases by splitting on and/or
        # write a function to parse tree into and/or sub trees
        for i, dish in extract_subjects(parseTree):
            duplicate = False
            ignoreFrames = ['cuisine', 'ingredient', 'meal']
            for frameKey in ignoreFrames:
                for item in self.frame[frameKey]:
                    if dish in item['name']: duplicate = True
            if not duplicate: dishesSet.append((i, dish))
                          
        for i, dish in dishesSet:
github JoshRosen / cmps140_creative_cooking_assistant / nlu / messages / search_message.py View on Github external
Fills out message meta and frame attributes.
        """
        tokenizer = nltk.WordPunctTokenizer()
        tokenized_string = tokenizer.tokenize(raw_input_string)
        tagger = utils.combined_taggers
        tagged_string = tagger.tag(tokenized_string)
        parseTree = get_parse_tree(tokenized_string)
        
        # Ingredients
        for i, ingredient in get_ingredients(tokenized_string, enum=True):
            frameItem = {}
            frameItem['id'] = i
            frameItem['name'] =ingredient
            frameItem['descriptor'] = [] # TODO: siblings JJ
            frameItem['preference'] = 0 # TODO: RB = not or n't
            frameItem['relationship'] = extract_junction(parseTree, ingredient)
            self.frame['ingredient'].append(frameItem)
            
        # Meals
        for i, meal in get_meals(tokenized_string, enum=True):
            meal = tokenized_string[i]
            frameItem = {}
            frameItem['id'] = i
            frameItem['name'] = meal
            frameItem['descriptor'] = [] # TODO: siblings JJ
            frameItem['preference'] = 0 # TODO: RB = not or n't
            frameItem['relationship'] = extract_junction(parseTree, meal)
            self.frame['meal'].append(frameItem)
            
        # Cuisine
        for i, cuisine in get_cuisines(tokenized_string, enum=True):
            frameItem = {}
github JoshRosen / cmps140_creative_cooking_assistant / nlu / messages / search_message.py View on Github external
frameItem['id'] = i
            frameItem['name'] =ingredient
            frameItem['descriptor'] = [] # TODO: siblings JJ
            frameItem['preference'] = 0 # TODO: RB = not or n't
            frameItem['relationship'] = extract_junction(parseTree, ingredient)
            self.frame['ingredient'].append(frameItem)
            
        # Meals
        for i, meal in get_meals(tokenized_string, enum=True):
            meal = tokenized_string[i]
            frameItem = {}
            frameItem['id'] = i
            frameItem['name'] = meal
            frameItem['descriptor'] = [] # TODO: siblings JJ
            frameItem['preference'] = 0 # TODO: RB = not or n't
            frameItem['relationship'] = extract_junction(parseTree, meal)
            self.frame['meal'].append(frameItem)
            
        # Cuisine
        for i, cuisine in get_cuisines(tokenized_string, enum=True):
            frameItem = {}
            frameItem['id'] = i
            frameItem['name'] = cuisine
            frameItem['descriptor'] = [] # TODO: siblings JJ
            frameItem['preference'] = 0 # TODO: RB = not or n't
            frameItem['relationship'] = extract_junction(parseTree, cuisine)
            self.frame['cuisine'].append(frameItem)
            
        # Dish
        dishesSet = []
        # add sentence subjects which aren't already ingredients or meals
        #TODO: Set extract_subject_nodes to hanle multiple phrases by splitting on and/or
github JoshRosen / cmps140_creative_cooking_assistant / nlu / messages / search_message.py View on Github external
# write a function to parse tree into and/or sub trees
        for i, dish in extract_subjects(parseTree):
            duplicate = False
            ignoreFrames = ['cuisine', 'ingredient', 'meal']
            for frameKey in ignoreFrames:
                for item in self.frame[frameKey]:
                    if dish in item['name']: duplicate = True
            if not duplicate: dishesSet.append((i, dish))
                          
        for i, dish in dishesSet:
            frameItem = {}
            frameItem['id'] = i
            frameItem['name'] = dish
            frameItem['descriptor'] = [] # TODO: siblings JJ
            frameItem['preference'] = 0 # TODO: RB = not or n't
            frameItem['relationship'] = extract_junction(parseTree, dish)
            self.frame['dish'].append(frameItem)