Пример #1
0
        public void InitializeVerbs(PluginEnvironment env, string basedir)
        {
            VerbsData        verbsData  = new VerbsData(basedir);
            ConjugateHandler conjugator = new ConjugateHandler(verbsData);

            env.AddAction(conjugator);
            env.AddAction(new TransitiveTestHandler(verbsData, conjugator));
            env.AddAction(new InflectionTestHandler(verbsData, conjugator));

            char[] tokenizer = new char[] { '\n' };
            int    key_len   = 256;

            IDataSource <string, Verbs.VerbType> transitiveSource      = new AlphabeticFileSet <Verbs.VerbType>(basedir + "verb_transitive.txt", tokenizer, key_len, Verbs.VerbType.VT);
            IDataSource <string, Verbs.VerbType> intransitiveSource    = new AlphabeticFileSet <Verbs.VerbType>(basedir + "verb_intransitive.txt", tokenizer, key_len, Verbs.VerbType.VI);
            IDataSource <string, Verbs.VerbType> eitherSource          = new AlphabeticFileSet <Verbs.VerbType>(basedir + "verb_either.txt", tokenizer, key_len, Verbs.VerbType.VE);
            IDataSource <string, Verbs.VerbType> advTransitiveSource   = new AlphabeticFileSet <Verbs.VerbType>(basedir + "verb_adv_transitive.txt", tokenizer, key_len, Verbs.VerbType.VT);
            IDataSource <string, Verbs.VerbType> advIntransitiveSource = new AlphabeticFileSet <Verbs.VerbType>(basedir + "verb_adv_intransitive.txt", tokenizer, key_len, Verbs.VerbType.VI);
            IDataSource <string, Verbs.VerbType> advEitherSource       = new AlphabeticFileSet <Verbs.VerbType>(basedir + "verb_adv_either.txt", tokenizer, key_len, Verbs.VerbType.VE);
            IDataSource <string, Verbs.VerbType> advPrepSource         = new AlphabeticFileSet <Verbs.VerbType>(basedir + "verb_adv_prep.txt", tokenizer, key_len, Verbs.VerbType.VT);

            env.SetDataSource <string, Verbs.VerbType>(Verbs.VerbTypeSourceName, new ComboSource <string, Verbs.VerbType>(new ComboSource <string, Verbs.VerbType>(
                                                                                                                              new ComboSource <string, Verbs.VerbType>(transitiveSource, intransitiveSource),
                                                                                                                              new ComboSource <string, Verbs.VerbType>(eitherSource, advTransitiveSource)),
                                                                                                                          new ComboSource <string, Verbs.VerbType>(
                                                                                                                              new ComboSource <string, Verbs.VerbType>(advIntransitiveSource, advEitherSource), advPrepSource)));
        }
Пример #2
0
        public void InitializeNouns(PluginEnvironment env, string basedir)
        {
            int key_len = 256;

            char[] tokenizer = new char[] { ' ' };

            // Noun type source
            IDataSource <string, Nouns.NounType> ambigSource   = new AlphabeticFileSet <Nouns.NounType>(basedir + "person_ambig.txt", tokenizer, key_len, Nouns.NounType.ProperEither);
            IDataSource <string, Nouns.NounType> femaleSource  = new AlphabeticFileSet <Nouns.NounType>(basedir + "person_female.txt", tokenizer, key_len, Nouns.NounType.ProperFemale);
            IDataSource <string, Nouns.NounType> maleSource    = new AlphabeticFileSet <Nouns.NounType>(basedir + "person_male.txt", tokenizer, key_len, Nouns.NounType.ProperMale);
            IDataSource <string, Nouns.NounType> citySource    = new AlphabeticFileSet <Nouns.NounType>(basedir + "city.txt", tokenizer, key_len, Nouns.NounType.ProperCity);
            IDataSource <string, Nouns.NounType> countrySource = new AlphabeticFileSet <Nouns.NounType>(basedir + "country.txt", tokenizer, key_len, Nouns.NounType.ProperCountry);
            IDataSource <string, Nouns.NounType> regionSource  = new AlphabeticFileSet <Nouns.NounType>(basedir + "region.txt", tokenizer, key_len, Nouns.NounType.ProperProvince);
            IDataSource <string, Nouns.NounType> countSource   = new AlphabeticFileSet <Nouns.NounType>(basedir + "count_nouns.txt", tokenizer, key_len, Nouns.NounType.Count);
            IDataSource <string, Nouns.NounType> massSource    = new AlphabeticFileSet <Nouns.NounType>(basedir + "mass_nouns.txt", tokenizer, key_len, Nouns.NounType.Mass);
            IDataSource <string, Nouns.NounType> theSource     = new AlphabeticFileSet <Nouns.NounType>(basedir + "the_nouns.txt", tokenizer, key_len, Nouns.NounType.The);

            env.SetDataSource <string, Nouns.NounType>(Nouns.NounTypeSourceName, new ComboSource <string, Nouns.NounType>(new ComboSource <string, Nouns.NounType>(
                                                                                                                              new ComboSource <string, Nouns.NounType>(new ComboSource <string, Nouns.NounType>(ambigSource, femaleSource), maleSource),
                                                                                                                              new ComboSource <string, Nouns.NounType>(new ComboSource <string, Nouns.NounType>(citySource, countrySource), regionSource)),
                                                                                                                          new ComboSource <string, Nouns.NounType>(new ComboSource <string, Nouns.NounType>(countSource, massSource), theSource)));

            IDataSource <string, Nouns.Gender> feminineSource  = new AlphabeticFileSet <Nouns.Gender>(basedir + "nouns_female.txt", tokenizer, key_len, Nouns.Gender.Female);
            IDataSource <string, Nouns.Gender> masculineSource = new AlphabeticFileSet <Nouns.Gender>(basedir + "nouns_male.txt", tokenizer, key_len, Nouns.Gender.Male);
            IDataSource <string, Nouns.Gender> eitherSource    = new AlphabeticFileSet <Nouns.Gender>(basedir + "nouns_malefem.txt", tokenizer, key_len, Nouns.Gender.Either);

            env.SetDataSource <string, Nouns.Gender>(Nouns.GenderSourceName,
                                                     new ComboSource <string, Nouns.Gender>(new ComboSource <string, Nouns.Gender>(feminineSource, masculineSource), eitherSource));

            MemorySource <string, string> toSingular = new MemorySource <string, string>();
            MemorySource <string, string> toPlural   = new MemorySource <string, string>();

            ReadNounNumber(basedir + "nouns_number.txt", toSingular, toPlural);

            env.SetDataSource <string, Nouns.Number>(Nouns.NumberSourceName,
                                                     new ComboSource <string, Nouns.Number>(new MapDataSource <string, string, Nouns.Number>(toSingular, ToShared, Nouns.Number.Plural),
                                                                                            new MapDataSource <string, string, Nouns.Number>(toPlural, ToShared, Nouns.Number.Singular)));

            env.AddAction(new ChangeNounHandler(Nouns.Number.Singular, toSingular));
            env.AddAction(new ChangeNounHandler(Nouns.Number.Plural, toPlural));
        }
        public void InitializeNouns(PluginEnvironment env, string basedir)
        {
            int key_len = 256;
            char[] tokenizer = new char[] { ' ' };

            // Noun type source
            IDataSource<string, Nouns.NounType> ambigSource = new AlphabeticFileSet<Nouns.NounType>(basedir + "person_ambig.txt", tokenizer, key_len, Nouns.NounType.ProperEither);
            IDataSource<string, Nouns.NounType> femaleSource = new AlphabeticFileSet<Nouns.NounType>(basedir + "person_female.txt", tokenizer, key_len, Nouns.NounType.ProperFemale);
            IDataSource<string, Nouns.NounType> maleSource = new AlphabeticFileSet<Nouns.NounType>(basedir + "person_male.txt", tokenizer, key_len, Nouns.NounType.ProperMale);
            IDataSource<string, Nouns.NounType> citySource = new AlphabeticFileSet<Nouns.NounType>(basedir + "city.txt", tokenizer, key_len, Nouns.NounType.ProperCity);
            IDataSource<string, Nouns.NounType> countrySource = new AlphabeticFileSet<Nouns.NounType>(basedir + "country.txt", tokenizer, key_len, Nouns.NounType.ProperCountry);
            IDataSource<string, Nouns.NounType> regionSource = new AlphabeticFileSet<Nouns.NounType>(basedir + "region.txt", tokenizer, key_len, Nouns.NounType.ProperProvince);
            IDataSource<string, Nouns.NounType> countSource = new AlphabeticFileSet<Nouns.NounType>(basedir + "count_nouns.txt", tokenizer, key_len, Nouns.NounType.Count);
            IDataSource<string, Nouns.NounType> massSource = new AlphabeticFileSet<Nouns.NounType>(basedir + "mass_nouns.txt", tokenizer, key_len, Nouns.NounType.Mass);
            IDataSource<string, Nouns.NounType> theSource = new AlphabeticFileSet<Nouns.NounType>(basedir + "the_nouns.txt", tokenizer, key_len, Nouns.NounType.The);

            env.SetDataSource<string, Nouns.NounType>(Nouns.NounTypeSourceName, new ComboSource<string, Nouns.NounType>(new ComboSource<string, Nouns.NounType>(
                                                      new ComboSource<string, Nouns.NounType>(new ComboSource<string, Nouns.NounType>(ambigSource, femaleSource), maleSource),
                                                      new ComboSource<string, Nouns.NounType>(new ComboSource<string, Nouns.NounType>(citySource, countrySource), regionSource)),
                                                      new ComboSource<string, Nouns.NounType>(new ComboSource<string, Nouns.NounType>(countSource, massSource), theSource)));

            IDataSource<string, Nouns.Gender> feminineSource = new AlphabeticFileSet<Nouns.Gender>(basedir + "nouns_female.txt", tokenizer, key_len, Nouns.Gender.Female);
            IDataSource<string, Nouns.Gender> masculineSource = new AlphabeticFileSet<Nouns.Gender>(basedir + "nouns_male.txt", tokenizer, key_len, Nouns.Gender.Male);
            IDataSource<string, Nouns.Gender> eitherSource = new AlphabeticFileSet<Nouns.Gender>(basedir + "nouns_malefem.txt", tokenizer, key_len, Nouns.Gender.Either);

            env.SetDataSource<string, Nouns.Gender>(Nouns.GenderSourceName,
                                                    new ComboSource<string, Nouns.Gender>(new ComboSource<string, Nouns.Gender>(feminineSource, masculineSource), eitherSource));

            MemorySource<string, string> toSingular = new MemorySource<string, string>();
            MemorySource<string, string> toPlural = new MemorySource<string, string>();
            ReadNounNumber(basedir + "nouns_number.txt", toSingular, toPlural);

            env.SetDataSource<string, Nouns.Number>(Nouns.NumberSourceName,
                                                    new ComboSource<string, Nouns.Number>(new MapDataSource<string, string, Nouns.Number>(toSingular, ToShared, Nouns.Number.Plural),
                                                                                          new MapDataSource<string, string, Nouns.Number>(toPlural, ToShared, Nouns.Number.Singular)));

            env.AddAction(new ChangeNounHandler(Nouns.Number.Singular, toSingular));
            env.AddAction(new ChangeNounHandler(Nouns.Number.Plural, toPlural));
        }
        public void InitializeVerbs(PluginEnvironment env, string basedir)
        {
            VerbsData verbsData = new VerbsData(basedir);
            ConjugateHandler conjugator = new ConjugateHandler(verbsData);

            env.AddAction(conjugator);
            env.AddAction(new TransitiveTestHandler(verbsData, conjugator));
            env.AddAction(new InflectionTestHandler(verbsData, conjugator));

            char[] tokenizer = new char[] { '\n' };
            int key_len = 256;

            IDataSource<string, Verbs.VerbType> transitiveSource = new AlphabeticFileSet<Verbs.VerbType>(basedir + "verb_transitive.txt", tokenizer, key_len, Verbs.VerbType.VT);
            IDataSource<string, Verbs.VerbType> intransitiveSource = new AlphabeticFileSet<Verbs.VerbType>(basedir + "verb_intransitive.txt", tokenizer, key_len, Verbs.VerbType.VI);
            IDataSource<string, Verbs.VerbType> eitherSource = new AlphabeticFileSet<Verbs.VerbType>(basedir + "verb_either.txt", tokenizer, key_len, Verbs.VerbType.VE);
            IDataSource<string, Verbs.VerbType> advTransitiveSource = new AlphabeticFileSet<Verbs.VerbType>(basedir + "verb_adv_transitive.txt", tokenizer, key_len, Verbs.VerbType.VT);
            IDataSource<string, Verbs.VerbType> advIntransitiveSource = new AlphabeticFileSet<Verbs.VerbType>(basedir + "verb_adv_intransitive.txt", tokenizer, key_len, Verbs.VerbType.VI);
            IDataSource<string, Verbs.VerbType> advEitherSource = new AlphabeticFileSet<Verbs.VerbType>(basedir + "verb_adv_either.txt", tokenizer, key_len, Verbs.VerbType.VE);
            IDataSource<string, Verbs.VerbType> advPrepSource = new AlphabeticFileSet<Verbs.VerbType>(basedir + "verb_adv_prep.txt", tokenizer, key_len, Verbs.VerbType.VT);

            env.SetDataSource<string, Verbs.VerbType>(Verbs.VerbTypeSourceName, new ComboSource<string, Verbs.VerbType>(new ComboSource<string, Verbs.VerbType>(
                                                      new ComboSource<string, Verbs.VerbType>(transitiveSource, intransitiveSource),
                                                      new ComboSource<string, Verbs.VerbType>(eitherSource, advTransitiveSource)),
                                                                                                                        new ComboSource<string, Verbs.VerbType>(
                                                      new ComboSource<string, Verbs.VerbType>(advIntransitiveSource, advEitherSource), advPrepSource)));
        }