public virtual List <string> GetSpellingVars(string separator)

        {
            List <string> spellingVars = new List <string>();

            if (lexRecordObjs_ != null)

            {
                for (int i = 0; i < lexRecordObjs_.Count; i++)

                {
                    LexRecord temp     = (LexRecord)lexRecordObjs_[i];
                    string    eui      = temp.GetEui();
                    string    category = temp.GetCategory();
                    spellingVars.Add(temp.GetBase() + separator + eui + separator + category);

                    List <string> tempSpellVars = temp.GetSpellingVars();
                    for (int j = 0; j < tempSpellVars.Count; j++)

                    {
                        string tempSpellVar = (string)tempSpellVars[j];
                        spellingVars.Add(tempSpellVar + separator + eui + separator + category);
                    }
                }
            }

            return(spellingVars);
        }
        public static List<string> GetListFromLexRecord(LexRecord lexRecord, int contentType)
        {
            List<string> outList = new List<string>();
            switch (contentType)

            {
                case 2:
                    outList = lexRecord.GetSpellingVars();
                    break;
                case 5:
                    outList = lexRecord.GetVariants();
                    break;
                case 6:
                    outList = lexRecord.GetNominalizations();
                    break;
                case 7:
                    outList = lexRecord.GetAbbreviations();
                    break;
                case 8:
                    outList = lexRecord.GetAcronyms();
                    break;
            }

            return outList;
        }
Example #3
0
        ///**
        // * Extract info about the spelling variants of a word from an NIH record,
        // * and add to the simplenlg Woordelement.
        // *
        // * <P>
        // * Spelling variants are represented as lists of strings, retrievable via
        // * {@link LexicalFeature#SPELL_VARS}
        // *
        // * @param wordElement
        // * @param record
        // */
        private void addSpellingVariants(WordElement wordElement, LexRecord record)
        {
            List <string> vars = record.GetSpellingVars();

            if (vars != null && vars.Count > 0)
            {
                wordElement.setFeature(LexicalFeature.SPELL_VARS, vars);
            }

            // we set the default spelling var as the baseForm
            wordElement.setFeature(LexicalFeature.DEFAULT_SPELL, wordElement.BaseForm);
        }
Example #4
0
        /**
         * Extract info about the spelling variants of a word from an NIH record,
         * and add to the simplenlg Woordelement.
         *
         * <P>
         * Spelling variants are represented as lists of strings, retrievable via
         * {@link LexicalFeature#SPELL_VARS}
         *
         * @param wordElement
         * @param record
         */

        private void addSpellingVariants(WordElement wordElement, LexRecord record)
        {
            Vector <string> vars = record.GetSpellingVars();

            if (vars != null && !vars.isEmpty())
            {
                var wordVars = new List <string>();
                wordVars.addAll(vars);
                wordElement.setFeature(LexicalFeature.SPELL_VARS, wordVars);
            }

            // we set the default spelling var as the baseForm
            wordElement.setFeature(LexicalFeature.DEFAULT_SPELL, wordElement
                                   .getBaseForm());
        }
Example #5
0
        private static bool CheckGlreg(LexRecord lexRecord)

        {
            List <string> spList    = lexRecord.GetSpellingVars();
            bool          validFlag = true;

            foreach (string spItem in spList)

            {
                bool glregFlag = CheckEntry.CheckGlreg(lexRecord, spItem, 2);

                validFlag = (glregFlag) && (validFlag);
            }

            return(validFlag);
        }
        public virtual List <string> GetSpellingVars()

        {
            List <string> spellingVars = new List <string>();

            if (lexRecordObjs_ != null)

            {
                for (int i = 0; i < lexRecordObjs_.Count; i++)

                {
                    LexRecord temp = (LexRecord)lexRecordObjs_[i];
                    spellingVars.Add(temp.GetBase());
                    spellingVars.AddRange(temp.GetSpellingVars());
                }
            }

            return(spellingVars);
        }
        private static bool CheckOrder(LexRecord lexRecord)

        {
            bool validFlag   = true;
            int  contentType = 1;

            string        citation = lexRecord.GetBase();
            List <string> spVars   = lexRecord.GetSpellingVars();
            List <string> bases    = new List <string>();

            bases.Add(citation);
            foreach (string spVar in spVars)

            {
                bases.Add(spVar);
            }

            BaseComparator <string> bc = new BaseComparator <string>();

            bases.Sort(bc);

            if (!citation.Equals(bases[0]))

            {
                lexRecord.SetBase((string)bases[0]);
                validFlag = false;
            }

            bases.RemoveAt(0);
            lexRecord.SetSpellingVars(bases);

            if (!validFlag)

            {
                ErrMsgUtilLexRecord.AddContentErrMsg(contentType, 6, citation, lexRecord);
            }

            return(validFlag);
        }
        public static void SetItemInListInLexRecordAt(LexRecord lexRecord, int contentType, string item, int index)
        {
            switch (contentType)

            {
                case 2:
                    lexRecord.GetSpellingVars()[index] = item;
                    break;
                case 5:
                    lexRecord.GetVariants()[index] = item;
                    break;
                case 6:
                    lexRecord.GetNominalizations()[index] = item;
                    break;
                case 7:
                    lexRecord.GetAbbreviations()[index] = item;
                    break;
                case 8:
                    lexRecord.GetAcronyms()[index] = item;
                    break;
            }
        }
Example #9
0
        private static bool CheckDuplicates(LexRecord lexRecord)

        {
            bool          validFlag   = true;
            int           contentType = 2;
            string        @base       = lexRecord.GetBase();
            List <string> svList      = lexRecord.GetSpellingVars();
            List <string> uSvList     = new List <string>();

            for (int i = 0; i < svList.Count; i++)

            {
                string sv = (string)svList[i];

                if ((sv.Equals(@base) == true) || (uSvList.Contains(sv) == true))


                {
                    validFlag = false;
                    ErrMsgUtilLexRecord.AddContentErrMsg(contentType, 2, sv, lexRecord);
                }
                else

                {
                    uSvList.Add(sv);
                }
            }

            if (!validFlag)

            {
                lexRecord.SetSpellingVars(uSvList);
            }

            return(validFlag);
        }
Example #10
0
        private static bool CheckIrreg(LexRecord lexRecord, HashSet <string> irregExpEuiList)

        {
            bool validFlag = true;

            List <string> variants = lexRecord.GetVariants();

            string           citation = lexRecord.GetBase();
            List <string>    svList   = lexRecord.GetSpellingVars();
            HashSet <string> baseList = new HashSet <string>(svList);

            baseList.Add(citation);

            HashSet <string> irregBases = new HashSet <string>();
            string           variant;

            for (System.Collections.IEnumerator localIterator = variants.GetEnumerator(); localIterator.MoveNext();)
            {
                variant = (string)localIterator.Current;

                if ((variant.StartsWith("irreg|")) || (variant.StartsWith("group(irreg|")))


                {
                    string irregBase = GetIrregBase(variant);
                    if (!baseList.Contains(irregBase))

                    {
                        validFlag = false;
                        ErrMsgUtilLexRecord.AddContentErrMsg(5, 8, variant, lexRecord);
                    }
                    else

                    {
                        irregBases.Add(irregBase);
                    }
                }
            }

            if (!validFlag)

            {
                return(validFlag);
            }

            if (irregBases.Count > 0)

            {
                string eui = lexRecord.GetEui();
                if ((baseList.Count != irregBases.Count) && (!irregExpEuiList.Contains(eui)))


                {
                    validFlag = false;
                    foreach (string @base in baseList)

                    {
                        if (!irregBases.Contains(@base))

                        {
                            ErrMsgUtilLexRecord.AddContentErrMsg(5, 9, @base, lexRecord);
                        }
                    }
                }
            }

            return(validFlag);
        }