예제 #1
0
def main():
    mgr = PluralManager.default()
    assert mgr.to_plural('cat') == 'cats'
    assert mgr.to_plural('box') == 'boxes'
    assert mgr.to_plural('ox') == 'oxen'
    assert mgr.to_plural('ax') == 'axes'
    assert mgr.to_plural('axis') == 'axes'
예제 #2
0
파일: english.py 프로젝트: knighton/babi
    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()
예제 #3
0
파일: english.py 프로젝트: knighton/babi
    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()