コード例 #1
0
        public IpadicEntry(string surfaceForm, Option <string> feature)
        {
            SurfaceForm = surfaceForm;
            IsRegular   = feature.HasValue;
            if (!IsRegular)
            {
                return;
            }
            var features = feature
                           .Map(f => f.Split(','))
                           .ValueOr(Array.Empty <string>());

            PartOfSpeech         = MeCabEntryParser.PartOfSpeechFromString(MeCabEntryParser.OrNull(features, 0));
            ConjugatedForm       = MeCabEntryParser.OrNull(features, 4);
            Type                 = MeCabEntryParser.TypeFromString(ConjugatedForm);
            Inflection           = MeCabEntryParser.OrNull(features, 5);
            DictionaryForm       = MeCabEntryParser.OrNull(features, 6);
            Reading              = MeCabEntryParser.OrNull(features, 7);
            Pronunciation        = MeCabEntryParser.OrNull(features, 8);
            PartOfSpeechSections = features
                                   .Take(4)
                                   .Where(f => f != "*")
                                   .ToList()
                                   .AsReadOnly();
        }
コード例 #2
0
        public UnidicEntry(string surfaceForm, Option <string> feature)
        {
            SurfaceForm = surfaceForm;
            IsRegular   = feature.HasValue;
            if (!IsRegular)
            {
                return;
            }

            var features = feature
                           .Map(f => StringExt.SplitWithQuotes(f, ',', '"').ToArray())
                           .ValueOr(Array.Empty <string>());

            PartOfSpeech          = MeCabEntryParser.PartOfSpeechFromString(MeCabEntryParser.OrNull(features, 0)); // f[0]:  pos1
            ConjugatedForm        = MeCabEntryParser.OrNull(features, 5);                                          // ; f[5]:  cForm
            DictionaryForm        = MeCabEntryParser.OrNull(features,  10);                                        // ; f[10]: orthBase
            Pronunciation         = MeCabEntryParser.OrNull(features, 9);                                          // ; f[9]:  pron
            Reading               = MeCabEntryParser.OrNull(features, 20);                                         // ; f[20]: kana
            DictionaryFormReading = MeCabEntryParser.OrNull(features, 21);                                         // ; f[21]: kanaBase
            Type = MeCabEntryParser.TypeFromString(ConjugatedForm);
            // ; f[1]:  pos2
            // ; f[2]:  pos3
            // ; f[3]:  pos4
            PartOfSpeechSections = features
                                   .Skip(1)
                                   .Take(3)
                                   .Where(f => f != "*")
                                   .ToList()
                                   .AsReadOnly();
        }
コード例 #3
0
        public UnidicMeCabEntry(string originalForm, Option <string> feature)
        {
            OriginalForm = originalForm;
            IsRegular    = feature.HasValue;
            if (!IsRegular)
            {
                return;
            }

            var features = feature
                           .Map(f => StringExt.SplitWithQuotes(f, ',', '"').ToArray())
                           .ValueOr(Array.Empty <string>());

            PartOfSpeech         = MeCabEntryParser.PartOfSpeechFromString(MeCabEntryParser.OrNull(features, 0));
            ConjugatedForm       = MeCabEntryParser.OrNull(features, 5);
            NotInflected         = MeCabEntryParser.OrNull(features, 7);
            Type                 = MeCabEntryParser.TypeFromString(ConjugatedForm);
            PartOfSpeechSections = features
                                   .Skip(1)
                                   .Take(3)
                                   .Where(f => f != "*")
                                   .ToList()
                                   .AsReadOnly();
            IsIndependent = MeCabEntryParser.IsIndependentFromSections(PartOfSpeechSections);
        }