# Path: latin/LatinObject.py
# class LatinObject:
#     def __init__(self):
#         self.negated = False
# 
#     def detail(self):
#         return '[NOT IMPLEMENTED]'
# 
#     def surface_utf8(self):
#         return self.surface.encode('utf-8')
# 
#     def translate(self):
#         return ('*', False)
# 
# Path: latin/Item.py
# class Item:
#     def __init__(self, item):
#         self.item = item
#         self.surface = item['surface']
#         self.pos = item['pos']
#         self.ja = item['ja']
# 
#         self._ = item.get('_', None)
#         self.dominates = item.get('dominates', None)
#         self.target = []
#         self.modifiers = []
# 
#     def attrib(self, name, default=None):
#         return self.item.get(name, default)
# 
#     def match_case(self, pos, case):
#         return self.pos in pos and any([it[0] == case for it in self._])
# 
#     def can_be_genitive(self):
#         return self._ and any([it[0] == 'Gen' for it in self._])
# 
#     # itemをレンダリング
#     def description(self):
#         name = {
#             # tense
#             'present':'現在', 'imperfect':'未完了', 'future':'未来', # 'past':'過去',
#             'perfect':'完了', 'past-perfect': '過去完了', 'future-perfect': '未来完了',
#             # mode
#             'indicative':'直説法', 'subjunctive':'接続法', 'imperative':'命令法', 'infinitive':'不定法',
#             #
#             'participle':'分詞', 'gerundium':'動名詞',
#             # 数
#             'sg':'単数', 'pl':'複数',
#             # (態:Genus)
#             'active':'能動', 'passive':'受動',
#             '-':'-'}
#         # pos = item['pos']
#         def short_(_):
#             return '|'.join(map(lambda s:'.'.join(s), _))
# 
#         def get_base(key):
#             base = self.item.get(key)
#             if base is None: return ''
#             return ansi_color.ANSI_FGCOLOR_YELLOW + '(' + base.encode('utf-8') + ')' + ansi_color.ANSI_FGCOLOR_DEFAULT + ' '
# 
#         if self.pos == 'noun':
#             return get_base('base') + '%s [%s]' % (self.ja, short_(self._)) +' // '+ util.render(self.modifiers)
#         elif self.pos in ['adj', 'participle']:
#             return get_base('base') + '%s.%s [%s]' % (self.pos[0], self.ja, short_(self._))
#         elif self.pos == 'verb':
#             return get_base('pres1sg') + 'v.%s %s%s %s.%s.%s' % (self.ja,
#                                                                  self.item.get('person', 0),
#                                                                  self.item.get('number', '-'),
#                                                                  name[self.item.get('mood', 'indicative')],
#                                                                  name[self.item.get('voice', 'active')],
#                                                                  name[self.item.get('tense', 'present')],
#                                                                  )
#         elif self.pos == 'preposition':
#             return 'prep<%s> %s' % (self.dominates, self.ja)
#         else:
#             if len(self.item) > 0:
#                 item_ = self.item.copy()
#                 del item_['surface'], item_['pos'], item_['ja']
#                 return '%s %s %s' % (self.pos, self.ja, util.render(item_))
#             else:
#                 return '%s %s' % (self.pos, self.ja)


import latin.util as util # render
from latin.LatinObject import LatinObject
from latin.Item import Item
        self.genitives.append(word)

    def has_subst_case(self, case):
        # subst = ['noun','pronoun','adj','participle']
        subst = ['noun','pronoun']

        if not self.items: return False
        elif any([item.match_case(subst,case) for item in self.items]): return True
        elif any([item.pos == 'preposition' and item.dominates == case for item in self.items]): return True
        else: return False

    # 活用動詞ならtrue
    def is_verb(self):
        if self._is_verb is None: # memoize
            if self.items is None:
                self._is_verb = False
            else:
                self._is_verb = len(self.items) > 0 and all([item.pos == 'verb' and item.attrib('mood') == 'indicative' for item in self.items])
        return self._is_verb

    # 接続法動詞ならtrue
    def is_subj_verb(self):
        if self._is_subj_verb is None: # memoize
            if self.items is None:
                self._is_subj_verb = False
            else:
                self._is_subj_verb = len(self.items) > 0 and all([item.pos == 'verb' and item.attrib('mood') == 'subjunctive' for item in self.items])
        return self._is_subj_verb

    def description(self):

# Path: latin/LatinObject.py
# class LatinObject:
#     def __init__(self):
#         self.negated = False
# 
#     def detail(self):
#         return '[NOT IMPLEMENTED]'
# 
#     def surface_utf8(self):
#         return self.surface.encode('utf-8')
# 
#     def translate(self):
#         return ('*', False)
# 
# Path: latin/Item.py
# class Item:
#     def __init__(self, item):
#         self.item = item
#         self.surface = item['surface']
#         self.pos = item['pos']
#         self.ja = item['ja']
# 
#         self._ = item.get('_', None)
#         self.dominates = item.get('dominates', None)
#         self.target = []
#         self.modifiers = []
# 
#     def attrib(self, name, default=None):
#         return self.item.get(name, default)
# 
#     def match_case(self, pos, case):
#         return self.pos in pos and any([it[0] == case for it in self._])
# 
#     def can_be_genitive(self):
#         return self._ and any([it[0] == 'Gen' for it in self._])
# 
#     # itemをレンダリング
#     def description(self):
#         name = {
#             # tense
#             'present':'現在', 'imperfect':'未完了', 'future':'未来', # 'past':'過去',
#             'perfect':'完了', 'past-perfect': '過去完了', 'future-perfect': '未来完了',
#             # mode
#             'indicative':'直説法', 'subjunctive':'接続法', 'imperative':'命令法', 'infinitive':'不定法',
#             #
#             'participle':'分詞', 'gerundium':'動名詞',
#             # 数
#             'sg':'単数', 'pl':'複数',
#             # (態:Genus)
#             'active':'能動', 'passive':'受動',
#             '-':'-'}
#         # pos = item['pos']
#         def short_(_):
#             return '|'.join(map(lambda s:'.'.join(s), _))
# 
#         def get_base(key):
#             base = self.item.get(key)
#             if base is None: return ''
#             return ansi_color.ANSI_FGCOLOR_YELLOW + '(' + base.encode('utf-8') + ')' + ansi_color.ANSI_FGCOLOR_DEFAULT + ' '
# 
#         if self.pos == 'noun':
#             return get_base('base') + '%s [%s]' % (self.ja, short_(self._)) +' // '+ util.render(self.modifiers)
#         elif self.pos in ['adj', 'participle']:
#             return get_base('base') + '%s.%s [%s]' % (self.pos[0], self.ja, short_(self._))
#         elif self.pos == 'verb':
#             return get_base('pres1sg') + 'v.%s %s%s %s.%s.%s' % (self.ja,
#                                                                  self.item.get('person', 0),
#                                                                  self.item.get('number', '-'),
#                                                                  name[self.item.get('mood', 'indicative')],
#                                                                  name[self.item.get('voice', 'active')],
#                                                                  name[self.item.get('tense', 'present')],
#                                                                  )
#         elif self.pos == 'preposition':
#             return 'prep<%s> %s' % (self.dominates, self.ja)
#         else:
#             if len(self.item) > 0:
#                 item_ = self.item.copy()
#                 del item_['surface'], item_['pos'], item_['ja']
#                 return '%s %s %s' % (self.pos, self.ja, util.render(item_))
#             else:
#                 return '%s %s' % (self.pos, self.ja)


# Path: latin/Word.py
import latin.util as util # render
from latin.LatinObject import LatinObject
from latin.Item import Item

        self.genitives.append(word)

    def has_subst_case(self, case):
        # subst = ['noun','pronoun','adj','participle']
        subst = ['noun','pronoun']

        if not self.items: return False
        elif any([item.match_case(subst,case) for item in self.items]): return True
        elif any([item.pos == 'preposition' and item.dominates == case for item in self.items]): return True
        else: return False

    # 活用動詞ならtrue
    def is_verb(self):
        if self._is_verb is None: # memoize
            if self.items is None:
                self._is_verb = False
            else:
                self._is_verb = len(self.items) > 0 and all([item.pos == 'verb' and item.attrib('mood') == 'indicative' for item in self.items])
        return self._is_verb

    # 接続法動詞ならtrue
    def is_subj_verb(self):
        if self._is_subj_verb is None: # memoize
            if self.items is None:
                self._is_subj_verb = False
            else:
                self._is_subj_verb = len(self.items) > 0 and all([item.pos == 'verb' and item.attrib('mood') == 'subjunctive' for item in self.items])
        return self._is_subj_verb

    def description(self):

        if not self.items: return ''