Example #1
0
        static void Main(string[] args)
        {
            // Заполняем запись.
            DictionaryArticle article = new DictionaryArticle();

            article.word        = "estar";
            article.translation = null;
            article.signature   = null;
            article.conjugation = Conjugator.CONJUGATION_1;
            article.Group       = Conjugator.GROUP_IRREGULAR_INDIVIDUAL;
            article.index       = 0;


            FileStream   file   = File.Create(@"conjugation.txt");
            StreamWriter writer = new StreamWriter(file);


            for (byte t = 0; t <= 15; t++)
            {
                List <string> result = Conjugator.Conjugate(article, t);

                writer.WriteLine(Grammar.tenses[t]);
                writer.WriteLine();

                foreach (string item in result)
                {
                    writer.WriteLine(item);
                }

                writer.WriteLine();
                writer.WriteLine();
            }

            writer.Close();
        }
Example #2
0
        private void DisplayForms(DictionaryArticle article, byte tense, int left, int top)
        {
            List <string> forms = Conjugator.Conjugate(article, tense);

            Label labelTense = new Label();

            labelTense.Text      = Grammar.tenses[tense];
            labelTense.Width     = 190;
            labelTense.BackColor = Color.FromArgb(230, 230, 230);
            labelTense.Left      = left;
            labelTense.Top       = top;
            this.Controls.Add(labelTense);

            top += 37;

            foreach (String form in forms)
            {
                Label labelForm = new Label();
                labelForm.Text  = form;
                labelForm.Width = 180;
                labelForm.Left  = left;
                labelForm.Top   = top;
                this.Controls.Add(labelForm);

                top += 25;
            }
        }
Example #3
0
        public PersianMaximumLikelihoodTagger(Config config)
        {
            _config = config;

            MaximumLikelihoodTagger.Config baseConfig = new MaximumLikelihoodTagger.Config();
            baseConfig.DictionaryFilename = _config.DictionaryFilename;
            baseConfig.Normalize          = true;
            baseConfig.DefaultTags        = new[] { PersianPartOfSpeech.Unknown };
            baseConfig.DefaultWeights     = new[] { Double.NaN };
            _baseTagger = new MaximumLikelihoodTagger(baseConfig);

            _lemmatizer = new PersianSuffixLemmatizer(false, true);
            _verbs      = new Dictionary <string, List <Conjugator.VerbInfo> >();

            VerbInfoContainer dic = new VerbInfoContainer();

            dic.LoadStemFile(_config.StemFilename);
            Conjugator conjugator = new Conjugator(dic);

            foreach (ENUM_TENSE_PERSON person in Enum.GetValues(typeof(ENUM_TENSE_PERSON)))
            {
                foreach (var verbinfo in conjugator.ConjugateInfo(ENUM_VERB_TYPE.SADE, person))
                {
                    if (!_verbs.ContainsKey(verbinfo.Verb))
                    {
                        _verbs.Add(verbinfo.Verb, new List <Conjugator.VerbInfo>());
                    }
                    if (!_verbs[verbinfo.Verb].Contains(verbinfo))
                    {
                        _verbs[verbinfo.Verb].Add(verbinfo);
                    }
                }

                foreach (var verbinfo in conjugator.ConjugateInfo(ENUM_VERB_TYPE.PISHVANDI, person))
                {
                    if (!_verbs.ContainsKey(verbinfo.Verb))
                    {
                        _verbs.Add(verbinfo.Verb, new List <Conjugator.VerbInfo>());
                    }

                    if (!_verbs[verbinfo.Verb].Contains(verbinfo))
                    {
                        _verbs[verbinfo.Verb].Add(verbinfo);
                    }
                }
            }
        }
Example #4
0
        static void Main(string[] args)
        {
            Console.InputEncoding  = Encoding.Unicode;
            Console.OutputEncoding = Encoding.Unicode;

            Console.WriteLine("Doushi Japanese verb conjugator");
            Console.WriteLine("Type 'exit' to quit");
            Console.WriteLine();

            while (true)
            {
                Console.WriteLine("Dictionary form verb:");
                Console.Write("> ");
                var verb = Console.ReadLine();

                if (string.IsNullOrWhiteSpace(verb))
                {
                    continue;
                }
                else if (verb.Equals("exit", StringComparison.OrdinalIgnoreCase))
                {
                    return;
                }

                if (verb.Length < 2)
                {
                    continue;
                }

                Console.WriteLine("Reading (optional)");
                Console.Write("> ");
                var reading = Console.ReadLine();

                Console.WriteLine("Verb type (Auto detects when the reading is provided (not totally accurate))\n'1': Ichidan\n'2': Godan\n'3': Special Suru/Kuru");
                Console.Write("> ");
                var t    = Console.ReadLine();
                var type = t switch
                {
                    "1" => Doushi.Type.ICHIDAN,
                    "2" => ((Func <Doushi.Type>)(() =>
                    {
                        var t = Conjugator.TryFindType(verb, reading.Length >= 2 ? reading : verb);
                        return(t != Doushi.Type.ICHIDAN ? t : Doushi.Type.GODAN_RU);
                    }))(),
                    "3" => Conjugator.TryFindType(verb, verb),
                    _ => reading.Length >= 2 ? Conjugator.TryFindType(verb, reading) : Doushi.Type.UNKNOWN
                };

                Console.WriteLine();
                Console.WriteLine($" {verb} {type}\n\n Affirmative | Negative\n");

                var conj = Conjugator.Conjugate(verb, type, reading);

                if (conj != null)
                {
                    Console.WriteLine($" -> Non-Past: {conj.NonPast.Affirmative} | {conj.NonPast.Negative}\n");
                    Console.WriteLine($" -> Non-Past Polite: {conj.NonPastPolite.Affirmative} | {conj.NonPastPolite.Negative}\n");
                    Console.WriteLine($" -> Past: {conj.Past.Affirmative} | {conj.Past.Negative}\n");
                    Console.WriteLine($" -> Past Polite: {conj.PastPolite.Affirmative} | {conj.PastPolite.Negative}\n");
                    Console.WriteLine($" -> Te Form: {conj.TeForm.Affirmative} | {conj.TeForm.Negative}\n");
                    Console.WriteLine($" -> Potential: {conj.Potential.Affirmative} | {conj.Potential.Negative}\n");
                    Console.WriteLine($" -> Passive: {conj.Passive.Affirmative} | {conj.Passive.Negative}\n");
                    Console.WriteLine($" -> Causative: {conj.Causative.Affirmative} | {conj.Causative.Negative}\n");
                    Console.WriteLine($" -> Causative Passive: {conj.CausativePassive.Affirmative} | {conj.CausativePassive.Negative}\n");
                    Console.WriteLine($" -> Imperative: {conj.Imperative.Affirmative} | {conj.Imperative.Negative}\n");
                }
                else
                {
                    Console.WriteLine("Invalid input");
                }
                Console.WriteLine();
            }
        }
    }