# Path: grafeno/transformers/pos_extract.py
# class Transformer (Base):
# 
#     def __init__ (self, sempos = default_sempos, **kwds):
#         super().__init__(**kwds)
#         self.__list = sempos.keys()
#         self.__dict = sempos
# 
#     def transform_node (self, msnode):
#         sem = super().transform_node(msnode)
#         pos = msnode.get('pos')
#         if pos in self.__list:
#             sem['concept'] = msnode.get('lemma')
#             sem['sempos'] = self.__dict[pos]
#         return sem


from grafeno.transformers.pos_extract import Transformer as PosExtract
default_main_argument = [ 'dobj', 'iobj', 'ncmod' ]

class Transformer (PosExtract):

    def __init__ (self, sempos={}, main_argument=default_main_argument, **kwds):
        sempos['verb'] = 'v'
        super().__init__(sempos=sempos, **kwds)
        self.__main = main_argument

    def transform_dep (self, dep, parent, child):
        edge = super().transform_dep(dep, parent, child)
        p = self.nodes[parent]
        if p.get('sempos') == 'v':
            if dep == 'ncsubj':
                p['subj_edge'] = edge
                f = p.get('concept')
                edge['functor'] = 'ATTR' if f == 'be' else 'REL'
                edge['class'] = f
                edge['child'], edge['parent'] = edge['parent'], edge['child']
            elif dep in self.__main:
                try:
                    a = p['args']
                except KeyError:
                    a = dict()
                    p['args'] = a
                a[dep] = edge
        return edge

    def post_process (self):
        super().post_process()

# Path: grafeno/transformers/pos_extract.py
# class Transformer (Base):
# 
#     def __init__ (self, sempos = default_sempos, **kwds):
#         super().__init__(**kwds)
#         self.__list = sempos.keys()
#         self.__dict = sempos
# 
#     def transform_node (self, msnode):
#         sem = super().transform_node(msnode)
#         pos = msnode.get('pos')
#         if pos in self.__list:
#             sem['concept'] = msnode.get('lemma')
#             sem['sempos'] = self.__dict[pos]
#         return sem


# Path: grafeno/transformers/verb_collapse.py
from grafeno.transformers.pos_extract import Transformer as PosExtract

default_main_argument = [ 'dobj', 'iobj', 'ncmod' ]

class Transformer (PosExtract):

    def __init__ (self, sempos={}, main_argument=default_main_argument, **kwds):
        sempos['verb'] = 'v'
        super().__init__(sempos=sempos, **kwds)
        self.__main = main_argument

    def transform_dep (self, dep, parent, child):
        edge = super().transform_dep(dep, parent, child)
        p = self.nodes[parent]
        if p.get('sempos') == 'v':
            if dep == 'ncsubj':
                p['subj_edge'] = edge
                f = p.get('concept')
                edge['functor'] = 'ATTR' if f == 'be' else 'REL'
                edge['class'] = f
                edge['child'], edge['parent'] = edge['parent'], edge['child']
            elif dep in self.__main:
                try:
                    a = p['args']
                except KeyError:
                    a = dict()
                    p['args'] = a
                a[dep] = edge
        return edge

    def post_process (self):
        super().post_process()

        for nid, node in list(self.nodes.items()):