Exemplo n.º 1
0
        public WordForms_t GetWordFormsByPartOfSpeech(string word, PartOfSpeechEnum partOfSpeechFilter)
        {
            var result    = new WordForms_t(word);
            var wordUpper = StringsHelper.ToUpperInvariant(word);

            if (_MorphoModel.GetWordForms(wordUpper, _WordForms))
            {
                FillUniqueWordFormsDictionary(partOfSpeechFilter);

                #region [.fill word-forms list.]
                _WordForms.Clear();
                foreach (var p in _UniqueWordFormsDictionary)
                {
                    var form         = p.Key;
                    var partOfSpeech = p.Value;

                    var wf = new WordForm_t(form, partOfSpeech);
                    _WordForms.Add(wf);
                }
                result.Forms = _WordForms;
                #endregion
            }

            return(result);
        }
Exemplo n.º 2
0
        private static PosTaggerOutputType ToPosTaggerOutputType(PartOfSpeechEnum singlePartOfSpeech)
        {
            switch (singlePartOfSpeech)
            {
            case PartOfSpeechEnum.Adjective: return(PosTaggerOutputType.Adjective);

            case PartOfSpeechEnum.Adverb: return(PosTaggerOutputType.Adverb);

            case PartOfSpeechEnum.Article: return(PosTaggerOutputType.Article);

            case PartOfSpeechEnum.Conjunction: return(PosTaggerOutputType.Conjunction);

            case PartOfSpeechEnum.Interjection: return(PosTaggerOutputType.Interjection);

            case PartOfSpeechEnum.Noun: return(PosTaggerOutputType.Noun);

            case PartOfSpeechEnum.Numeral: return(PosTaggerOutputType.Numeral);

            case PartOfSpeechEnum.Other: return(PosTaggerOutputType.Other);

            case PartOfSpeechEnum.Particle: return(PosTaggerOutputType.Particle);

            case PartOfSpeechEnum.Predicate: return(PosTaggerOutputType.Predicate);

            case PartOfSpeechEnum.Preposition: return(PosTaggerOutputType.Preposition);

            case PartOfSpeechEnum.Pronoun: return(PosTaggerOutputType.Pronoun);

            case PartOfSpeechEnum.Verb: return(PosTaggerOutputType.Verb);

            default:
                throw new ArgumentException(singlePartOfSpeech.ToString());
            }
        }
Exemplo n.º 3
0
        public BaseMorphoFormNative(char *_base, MorphoTypeNative morphoType)
        {
            _Base         = _base;
            _PartOfSpeech = morphoType.PartOfSpeech;

            Debug.Assert(morphoType.HasMorphoForms, "morphoType.MorphoForms.Length <= 0");

            _MorphoFormEndings = morphoType.MorphoFormEndings;

            #region commented

            /*
             * for ( int i = 0, len = morphoType.MorphoForms.Length; i < len; i++ )
             * {
             *  tempBufferHS.Add( (IntPtr) morphoType.MorphoForms[ i ].Ending );
             * }
             * _MorphoFormEndings = new char*[ tempBufferHS.Count ];
             * fixed ( char** morphoFormEndingsBase = _MorphoFormEndings )
             * {
             *  var morphoFormEndings_ptr = morphoFormEndingsBase;
             *  foreach ( var intptr in tempBufferHS )
             *  {
             *(morphoFormEndings_ptr++) = (char*) intptr;
             *  }
             * }
             * tempBufferHS.Clear();
             */
            #endregion

            //_GlobalCount++;
            //_GlobalHashsetBase.Add( _Base );
            //_GlobalHashsetNormalForm.Add( _NormalForm );
        }
Exemplo n.º 4
0
 internal MorphoTypeNative(PartOfSpeechBase partOfSpeechBase)
 {
     _morphoAttributeGroup = partOfSpeechBase.MorphoAttributeGroup;
     _partOfSpeech         = partOfSpeechBase.PartOfSpeech;
     _morphoFormEndings    = EMPTY_ENDINGS;
     _morphoFormEndingUpperAndMorphoAttributes = EMPTY_MFUEMA;
 }
Exemplo n.º 5
0
        /// получение уникальных форм
        /// pForms - все формы
        /// uniqueForms [out] - уникальные формы
        /// pos - часть речи
        /// result - общее число уникальных форм
        private void FillUniqueWordFormsDictionary(PartOfSpeechEnum partOfSpeechFilter)
        {
            _uniqueWordFormsDictionary.Clear();

            for (int i = 0, len = _wordForms.Count; i < len; i++)
            {
                var wordForm = _wordForms[i];
                PartOfSpeechEnum partOfSpeechForm = wordForm.PartOfSpeech;
                if ((partOfSpeechForm & partOfSpeechFilter) != partOfSpeechFilter)
                {
                    continue;
                }

                var wordFormString = wordForm.Form;

                if (_uniqueWordFormsDictionary.TryGetValue(wordFormString, out PartOfSpeechEnum partOfSpeechExists))
                {
                    if ((partOfSpeechExists & partOfSpeechForm) != partOfSpeechForm)
                    {
                        partOfSpeechExists |= partOfSpeechForm;
                        _uniqueWordFormsDictionary[wordFormString] = partOfSpeechExists;
                    }
                }
                else
                {
                    _uniqueWordFormsDictionary.Add(wordFormString, partOfSpeechForm);
                }
            }
        }
Exemplo n.º 6
0
 /// Получение части речи по ее названию
 public PartOfSpeechBase GetPartOfSpeech(PartOfSpeechEnum partOfSpeech)
 {
     if (_Dictionary.TryGetValue(partOfSpeech, out PartOfSpeechBase value))
     {
         return(value);
     }
     return(null);
 }
Exemplo n.º 7
0
        public BaseMorphoFormNative(char *_base, MorphoTypeNative morphoType)
        {
            this._base    = _base;
            _partOfSpeech = morphoType.PartOfSpeech;

            Debug.Assert(morphoType.HasMorphoForms, "morphoType.MorphoForms.Length <= 0");

            _morphoFormEndings = morphoType.MorphoFormEndings;
        }
        private WordFormMorphology_t[] TryGetByPosTaggerOutputType(ref WordMorphology_t wordMorphology
                                                                   , PartOfSpeechEnum filterPartOfSpeech)
        {
            if ((wordMorphology.PartOfSpeech & filterPartOfSpeech) == filterPartOfSpeech)
            {
                var morphologies = TryGetByPosTaggerOutputType(wordMorphology.WordFormMorphologies, filterPartOfSpeech);
                return(morphologies);
            }

            return(null);
        }
Exemplo n.º 9
0
        private WordFormMorphology[] TryGetByPosTaggerOutputType(ref WordMorphology wordMorphology,
                                                                 PartOfSpeechEnum filterPartOfSpeech_1, PartOfSpeechEnum filterPartOfSpeech_2)
        {
            if ((wordMorphology.PartOfSpeech & filterPartOfSpeech_1) == filterPartOfSpeech_1)
            {
                var morphologies = TryGetByPosTaggerOutputType(wordMorphology.WordFormMorphologies, filterPartOfSpeech_1);
                if (morphologies != null)
                {
                    return(morphologies);
                }
            }

            if ((wordMorphology.PartOfSpeech & filterPartOfSpeech_2) == filterPartOfSpeech_2)
            {
                var morphologies = TryGetByPosTaggerOutputType(wordMorphology.WordFormMorphologies, filterPartOfSpeech_2);

                return(morphologies);
            }

            return(null);
        }
Exemplo n.º 10
0
        public WordForms GetWordFormsByPartOfSpeech_NoToUpper(string wordUpper, PartOfSpeechEnum partOfSpeechFilter)
        {
            var result = new WordForms(wordUpper);

            if (_morphoModel.GetWordForms(wordUpper, _wordForms))
            {
                FillUniqueWordFormsDictionary(partOfSpeechFilter);

                _wordForms.Clear();
                foreach (var p in _uniqueWordFormsDictionary)
                {
                    var form         = p.Key;
                    var partOfSpeech = p.Value;

                    var wf = new WordForm(form, partOfSpeech);
                    _wordForms.Add(wf);
                }
                result.Forms = _wordForms;
            }

            return(result);
        }
        private WordFormMorphology_t[] TryGetByPosTaggerOutputType(List <WordFormMorphology_t> wordFormMorphologies
                                                                   , PartOfSpeechEnum filterPartOfSpeech)
        {
            _wordFormMorphologies_Buffer.Clear();

            for (int i = 0, len = wordFormMorphologies.Count; i < len; i++)
            {
                var wordFormMorphology = wordFormMorphologies[i];
                if ((wordFormMorphology.PartOfSpeech & filterPartOfSpeech) == filterPartOfSpeech)
                {
                    //if ( FilterByLetterCase( ref wordFormMorphology, _WordFirstCharIsUpper ) )
                    //{
                    _wordFormMorphologies_Buffer.Add(wordFormMorphology);
                    //}
                }
            }

            if (_wordFormMorphologies_Buffer.Count != 0)
            {
                var result = _wordFormMorphologies_Buffer.ToArray(); //FilterByLetterCase( _FilteredWordFormMorphologies ); //
                return(result);
            }
            return(null);
        }
Exemplo n.º 12
0
        private WordFormMorphology[] TryGetByPosTaggerOutputType(List <WordFormMorphology> wordFormMorphologies, PartOfSpeechEnum filterPartOfSpeech)
        {
            _wordFormMorphologies_Buffer.Clear();

            for (int i = 0, len = wordFormMorphologies.Count; i < len; i++)
            {
                var wordFormMorphology = wordFormMorphologies[i];
                if ((wordFormMorphology.PartOfSpeech & filterPartOfSpeech) == filterPartOfSpeech)
                {
                    _wordFormMorphologies_Buffer.Add(wordFormMorphology);
                }
            }

            if (_wordFormMorphologies_Buffer.Count != 0)
            {
                var result = _wordFormMorphologies_Buffer.ToArray();
                return(result);
            }
            return(null);
        }
Exemplo n.º 13
0
 public WordFormMorphology(PartOfSpeechEnum partOfSpeech)
     : this()
 {
     PartOfSpeech = partOfSpeech;
 }
Exemplo n.º 14
0
 public WordForm(string form, PartOfSpeechEnum partOfSpeech)
 {
     Form         = form;
     PartOfSpeech = partOfSpeech;
 }
Exemplo n.º 15
0
 public WordFormMorphology(PartOfSpeechEnum partOfSpeech, MorphoAttributeEnum morphoAttribute)
     : this()
 {
     PartOfSpeech    = partOfSpeech;
     MorphoAttribute = morphoAttribute;
 }
Exemplo n.º 16
0
        /*
         * морфоанализатор::{PartOfSpeechEnum}  PoS-tagger::{PosTaggerOutputType}
         * PartOfSpeechEnum.Adjective	    PosTaggerOutputType.Adjective
         *                              PosTaggerOutputType.AdjectivePronoun
         * PartOfSpeechEnum.Adverb	        PosTaggerOutputType.Adverb
         *                              PosTaggerOutputType.AdverbialPronoun
         * PartOfSpeechEnum.Article	    PosTaggerOutputType.Article
         * PartOfSpeechEnum.Conjunction	PosTaggerOutputType.Conjunction
         * PartOfSpeechEnum.Interjection	PosTaggerOutputType.Interjection
         * PartOfSpeechEnum.Noun	        PosTaggerOutputType.Noun
         * PartOfSpeechEnum.Numeral	    PosTaggerOutputType.Numeral
         * PartOfSpeechEnum.Other	        PosTaggerOutputType.Other
         * PartOfSpeechEnum.Particle	    PosTaggerOutputType.Particle
         * PartOfSpeechEnum.Predicate	    PosTaggerOutputType.Predicate
         * PartOfSpeechEnum.Preposition	PosTaggerOutputType.Preposition
         * PartOfSpeechEnum.Pronoun	    PosTaggerOutputType.Pronoun 
         *                                  PosTaggerOutputType.PossessivePronoun
         *                                  PosTaggerOutputType.AdjectivePronoun  
         *                                  PosTaggerOutputType.AdverbialPronoun
         * PartOfSpeechEnum.Verb	        PosTaggerOutputType.Verb
         *                                  PosTaggerOutputType.Infinitive
         *                                  PosTaggerOutputType.AdverbialParticiple
         *                                  PosTaggerOutputType.AuxiliaryVerb
         *                                  PosTaggerOutputType.Participle
         * -	                            PosTaggerOutputType.Punctuation
         */
        #endregion

        private static void CorrectPosTaggerOutputType(Word word, PartOfSpeechEnum singlePartOfSpeech)
        {
            switch (singlePartOfSpeech)
            {
            case PartOfSpeechEnum.Adjective:
                switch (word.posTaggerOutputType)
                {
                case PosTaggerOutputType.Adjective:
                case PosTaggerOutputType.AdjectivePronoun:
                    break;

                default:
                    word.posTaggerOutputType = PosTaggerOutputType.Adjective;
                    break;
                }
                break;

            case PartOfSpeechEnum.Adverb:
                switch (word.posTaggerOutputType)
                {
                case PosTaggerOutputType.Adverb:
                case PosTaggerOutputType.AdverbialPronoun:
                    break;

                default:
                    word.posTaggerOutputType = PosTaggerOutputType.Adverb;
                    break;
                }
                break;

            case PartOfSpeechEnum.Article: word.posTaggerOutputType = PosTaggerOutputType.Article; break;

            case PartOfSpeechEnum.Conjunction: word.posTaggerOutputType = PosTaggerOutputType.Conjunction; break;

            case PartOfSpeechEnum.Interjection: word.posTaggerOutputType = PosTaggerOutputType.Interjection; break;

            case PartOfSpeechEnum.Noun: word.posTaggerOutputType = PosTaggerOutputType.Noun; break;

            case PartOfSpeechEnum.Numeral: word.posTaggerOutputType = PosTaggerOutputType.Numeral; break;

            case PartOfSpeechEnum.Other: word.posTaggerOutputType = PosTaggerOutputType.Other; break;

            case PartOfSpeechEnum.Particle: word.posTaggerOutputType = PosTaggerOutputType.Particle; break;

            case PartOfSpeechEnum.Predicate: word.posTaggerOutputType = PosTaggerOutputType.Predicate; break;

            case PartOfSpeechEnum.Preposition: word.posTaggerOutputType = PosTaggerOutputType.Preposition; break;

            case PartOfSpeechEnum.Pronoun:
                switch (word.posTaggerOutputType)
                {
                case PosTaggerOutputType.Pronoun:
                case PosTaggerOutputType.PossessivePronoun:
                case PosTaggerOutputType.AdjectivePronoun:
                case PosTaggerOutputType.AdverbialPronoun:
                    break;

                default:
                    word.posTaggerOutputType = PosTaggerOutputType.Pronoun;
                    break;
                }
                break;

            case PartOfSpeechEnum.Verb:
                switch (word.posTaggerOutputType)
                {
                case PosTaggerOutputType.Verb:
                case PosTaggerOutputType.Infinitive:
                case PosTaggerOutputType.AdverbialParticiple:
                case PosTaggerOutputType.AuxiliaryVerb:
                case PosTaggerOutputType.Participle:
                    break;

                default:
                    word.posTaggerOutputType = PosTaggerOutputType.Verb;
                    break;
                }
                break;

            default:
                throw new ArgumentException(singlePartOfSpeech.ToString());
            }
        }
Exemplo n.º 17
0
 public IntPtr this[PartOfSpeechEnum partOfSpeech]
 {
     get { return(_Dictionary[partOfSpeech]); }
 }
Exemplo n.º 18
0
 internal MorphoType(PartOfSpeechBase partOfSpeechBase)
 {
     _MorphoForms          = EMPTY;
     _MorphoAttributeGroup = partOfSpeechBase.MorphoAttributeGroup;
     _PartOfSpeech         = partOfSpeechBase.PartOfSpeech;
 }
Exemplo n.º 19
0
 public WordFormMorphology_t(PartOfSpeechEnum partOfSpeech) : this() => PartOfSpeech = partOfSpeech;