How to use the nlu.stanford_utils.get_node_string 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 / preference_message.py View on Github external
def _parse(self, raw_input_string, g):
        """
        Fills out message meta and frame attributes.
        """
        tokenized_string = g.generate_tokenized_string(raw_input_string)
        parseTree = g.generate_stanford_parse_tree(raw_input_string)
        
        subjects = extract_subject_nodes(parseTree)
        if subjects:
            self.frame['subject'] = [get_node_string(subject)
                                     for subject in subjects]
        words_temporary_pos = extract_close_keywords(
                                       PreferenceMessage.keywords_temporary_pos,
                                       tokenized_string,
                                       2)
        words_temporary_neg = extract_close_keywords(
                                       PreferenceMessage.keywords_temporary_neg,
                                       tokenized_string,
                                       2)
        words_permanent_pos = extract_close_keywords(
                                       PreferenceMessage.keywords_permanent_pos,
                                       tokenized_string,
                                       2)
        words_permanent_neg = extract_close_keywords(
                                       PreferenceMessage.keywords_permanent_neg,
                                       tokenized_string,
github JoshRosen / cmps140_creative_cooking_assistant / nlu / messages / msgutils.py View on Github external
'and'
    >>> extract_junction(tree, 'children')
    'and'
    >>> extract_junction(tree, 'celery')
    'or'
    >>> extract_junction(tree, 'rats') == None
    True
    """
    # locate the word node
    for node in parse_tree.getLeaves():
        if node.value() == word:
            # extract the junction node
            node = extract_junction_node(parse_tree, node)
            # return the node junction type
            if node:
                nodeString = get_node_string(node)
                if 'and' in nodeString:
                    return 'and'
                elif 'or' in nodeString:
                    return 'or'
            else:
                return 'and'
    return None
github JoshRosen / cmps140_creative_cooking_assistant / nlu / messages / msgutils.py View on Github external
def extract_subjects(parse_tree, enum=True):
    """
    Returns a list of subject words.
    """
    for node in extract_subject_nodes(parse_tree):
        word = get_node_string(node)
        if enum:
            yield (parse_tree.indexOf(node), word)
        else:
            yield word