# Path: props/graph_representation/graphParsingException.py
# class GraphParsingException(Exception):
#     """
#     Exception to identify errors coming from the graph parsing process
#     """
#     pass
# 
# Path: props/graph_representation/word.py
# class Word:
#     """
#     word container class, to add the index of the word in addition to the word 
#     
#     @type index: int
#     @var  index: the index of the word within the sentence
#     
#     @type text: string
#     @var  text: the text contained within this word
#     """
#     
#     def __init__(self,index,word):
#         """
#         initialize a word container object
#         """
#         self.index = index
#         self.word = word
#     
#     def to_conll_like(self):
#         return ",".join([str(self.index),self.word])
#     
#     def __str__(self):
#         ret = cgi.escape(self.word)
#         if self.index != NO_INDEX:
#             ret += '<FONT POINT-SIZE="7">[{0}]</FONT>'.format(self.index)
#         return ret
#     
#     def __eq__(self,other_word):
#         return (self.index == other_word.index) and (self.word == other_word.word)
#     
#     def __hash__(self):
#         return self.__str__().__hash__()
# 
# Path: props/constituency_tree/my_definitions.py
# ADVERBIALS = ["ADV", "VOC", "BNF", "DIR", "EXT", "LOC", "MNR", "TMP", "CLR","PRP"]


from __builtin__ import dir
from props.graph_representation.graphParsingException import GraphParsingException
from nltk.tree import Tree
from props.graph_representation.word import Word
from props.dependency_tree.definitions import *
from props.constituency_tree.definitions import *
from props.constituency_tree.my_definitions import any_in
from Tense import tense_rules
        from nltk import Tree
        from nltk.stem.wordnet import WordNetLemmatizer
import copy,os

    
    # get a dictionary of [list] of children by their parent relation (if there's several)
    def _get_child_dic(self):
        d = {}
        for c in self.children:
            if c.parent_relation not in d:
                d[c.parent_relation] = []
            d[c.parent_relation].append(c)
        return d
        

    # return rooted subtree word dictionary by self.id
    def _get_subtree_nodes(self,includeHead = False):
        def inner(node):
            ret = {node.id:node}
            for child in node.children:
                ret.update(inner(child))
            return ret
        d = inner(self)
        if not includeHead: d.pop(self.id)
        return d

    # return True if the node is a predicate - deprecated
    def is_predicate(self):
        if self.is_verbal_predicate():
            return True
        return False
    
    # returns [self] if the node is an possesive predicate
    def is_possesive_predicate(self):

# Path: props/graph_representation/graphParsingException.py
# class GraphParsingException(Exception):
#     """
#     Exception to identify errors coming from the graph parsing process
#     """
#     pass
# 
# Path: props/graph_representation/word.py
# class Word:
#     """
#     word container class, to add the index of the word in addition to the word 
#     
#     @type index: int
#     @var  index: the index of the word within the sentence
#     
#     @type text: string
#     @var  text: the text contained within this word
#     """
#     
#     def __init__(self,index,word):
#         """
#         initialize a word container object
#         """
#         self.index = index
#         self.word = word
#     
#     def to_conll_like(self):
#         return ",".join([str(self.index),self.word])
#     
#     def __str__(self):
#         ret = cgi.escape(self.word)
#         if self.index != NO_INDEX:
#             ret += '<FONT POINT-SIZE="7">[{0}]</FONT>'.format(self.index)
#         return ret
#     
#     def __eq__(self,other_word):
#         return (self.index == other_word.index) and (self.word == other_word.word)
#     
#     def __hash__(self):
#         return self.__str__().__hash__()
# 
# Path: props/constituency_tree/my_definitions.py
# ADVERBIALS = ["ADV", "VOC", "BNF", "DIR", "EXT", "LOC", "MNR", "TMP", "CLR","PRP"]


# Path: props/dependency_tree/tree.py
from __builtin__ import dir
from props.graph_representation.graphParsingException import GraphParsingException
from nltk.tree import Tree
from props.graph_representation.word import Word
from props.dependency_tree.definitions import *
from props.constituency_tree.definitions import *
from props.constituency_tree.my_definitions import any_in
from Tense import tense_rules
        from nltk import Tree
        from nltk.stem.wordnet import WordNetLemmatizer
import copy,os

    
    # get a dictionary of [list] of children by their parent relation (if there's several)
    def _get_child_dic(self):
        d = {}
        for c in self.children:
            if c.parent_relation not in d:
                d[c.parent_relation] = []
            d[c.parent_relation].append(c)
        return d
        

    # return rooted subtree word dictionary by self.id
    def _get_subtree_nodes(self,includeHead = False):
        def inner(node):
            ret = {node.id:node}
            for child in node.children:
                ret.update(inner(child))
            return ret
        d = inner(self)
        if not includeHead: d.pop(self.id)
        return d

    # return True if the node is a predicate - deprecated
    def is_predicate(self):
        if self.is_verbal_predicate():
            return True
        return False
    
    # returns [self] if the node is an possesive predicate
    def is_possesive_predicate(self):

        possChildList = any_in([c.parent_relation for c in self.children], [POSS_LABEL])
