Exemplo n.º 1
0
    def __init__(self):
        conj_f = 'panoptes/ling/verb/conjugations.csv'
        verb_f = 'data/verbs.json'
        verb_mgr = VerbManager.from_files(conj_f, verb_f)

        syllable_counter = SyllableCounter.default()
        comparative_mgr = ComparativeManager.default(syllable_counter)
        det_pronoun_mgr = DetPronounManager()
        pro_adverb_mgr = ProAdverbManager()
        time_of_day_mgr = TimeOfDayManager()

        inflection_mgr = InflectionManager()
        personal_mgr = PersonalManager(inflection_mgr)
        plural_mgr = PluralManager.default()

        self.say_state = SayState(comparative_mgr, det_pronoun_mgr,
                                  inflection_mgr, personal_mgr, plural_mgr,
                                  pro_adverb_mgr, time_of_day_mgr, verb_mgr)

        # The SayContext is needed for conjugation.  None of its fields affect
        # conjugation for any object.
        arbitrary_say_context = SayContext(prep=None,
                                           has_left=False,
                                           has_right=False,
                                           is_possessive=False)
        purpose_mgr = PurposeManager()
        relation_mgr = RelationManager()
        self.transform_state = \
            TransformState(arbitrary_say_context, purpose_mgr, relation_mgr)

        # Text -> surface structure -> deep structure.
        self.text_to_parse = TextToParse()
        self.parse_to_surface = ParseToSurface(comparative_mgr,
                                               det_pronoun_mgr, personal_mgr,
                                               plural_mgr, pro_adverb_mgr,
                                               self.say_state, time_of_day_mgr,
                                               verb_mgr)
        self.surface_to_deep = SurfaceToDeep(purpose_mgr, relation_mgr)

        self.joiner = Joiner()
Exemplo n.º 2
0
    def __init__(self):
        conj_f = 'panoptes/ling/verb/conjugations.csv'
        verb_f = 'data/verbs.json'
        verb_mgr = VerbManager.from_files(conj_f, verb_f)

        syllable_counter = SyllableCounter.default()
        comparative_mgr = ComparativeManager.default(syllable_counter)
        det_pronoun_mgr = DetPronounManager()
        pro_adverb_mgr = ProAdverbManager()
        time_of_day_mgr = TimeOfDayManager()

        inflection_mgr = InflectionManager()
        personal_mgr = PersonalManager(inflection_mgr)
        plural_mgr = PluralManager.default()

        self.say_state = SayState(
            comparative_mgr, det_pronoun_mgr, inflection_mgr, personal_mgr,
            plural_mgr, pro_adverb_mgr, time_of_day_mgr, verb_mgr)

        # The SayContext is needed for conjugation.  None of its fields affect
        # conjugation for any object.
        arbitrary_say_context = SayContext(
            prep=None, has_left=False, has_right=False, is_possessive=False)
        purpose_mgr = PurposeManager()
        relation_mgr = RelationManager()
        self.transform_state = \
            TransformState(arbitrary_say_context, purpose_mgr, relation_mgr)

        # Text -> surface structure -> deep structure.
        self.text_to_parse = TextToParse()
        self.parse_to_surface = ParseToSurface(
            comparative_mgr, det_pronoun_mgr, personal_mgr, plural_mgr,
            pro_adverb_mgr, self.say_state, time_of_day_mgr, verb_mgr)
        self.surface_to_deep = SurfaceToDeep(purpose_mgr, relation_mgr)

        self.joiner = Joiner()
Exemplo n.º 3
0
def main():
    conj_f = 'panoptes/ling/verb/conjugations.csv'
    verb_f = 'data/verbs.json'
    m = VerbManager.from_files(conj_f, verb_f)

    j = {
        'sbj_handling': 'WERE_SBJ',
        'relative_cont': 'NOT_REL',
        'contract_not': True,
        'intrinsics': {
            'polarity': {
                'tf': True,
                'is_contrary': False
            },
            'verb_form': 'FINITE',
            'lemma': 'go',
            'tense': 'PRESENT',
            'aspect': {
                'is_prog': False,
                'is_perf': False
            },
            'is_pro_verb': False,
            'modality': {
                'is_cond': False,
                'flavor': 'IMPERATIVE'
            }
        },
        'split_inf': True,
        'is_split': False,
        'conj': 'S2',
        'voice': 'ACTIVE'
    }
    v_to_say = SurfaceVerb.load(j)

    assert m.say(v_to_say) == ([], ['go'])

    sss = ((), ('go',))
    vv = m.parse(sss)
    assert any(map(lambda v: v.may_match(v_to_say), vv))

    text = """
        sbj_handling: WERE_SBJ
        relative_cont: NOT_REL
        contract_not: true
        split_inf: true
        is_split: true
        conj: S2
        voice: ACTIVE
        intrinsics:
            lemma: go
            polarity:
                tf: true
                is_contrary: false
            tense: PRESENT
            aspect:
                is_perf: true
                is_prog: false
            modality:
                flavor: INDICATIVE
                is_cond: true
            verb_form: FINITE
            is_pro_verb: false
    """
    j = yaml.load(text)
    v = SurfaceVerb.load(j)

    assert m.say(v) == (['would'], ['[AUX]have', 'gone'])