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);
        }
Example #2
0
        public virtual string GetResultStrByBase(string @base, int baseBy, long category, bool showQuery, string query,
                                                 bool noOutputFlag, string noOutputMsg, bool showTotalRecNum, int lexRecordFormat, string fieldSep)
        {
            LexAccessApiResult lexAccessApiResult = null;

            if ((!ReferenceEquals(@base, null)) && (@base.Length > 0))

            {
                lexAccessApiResult = GetLexRecordsByBase(@base, baseBy);
            }

            List <LexRecord> newLexRecordObjs = new List <LexRecord>();

            if (category < 2047L)

            {
                List <LexRecord> lexRecordObjs = lexAccessApiResult.GetJavaObjs();
                for (int i = 0; i < lexRecordObjs.Count; i++)

                {
                    LexRecord temp     = (LexRecord)lexRecordObjs[i];
                    long      catValue = Category.ToValue(temp.GetCategory());
                    if (BitMaskBase.Contains(category, catValue) == true)

                    {
                        newLexRecordObjs.Add(temp);
                    }
                }

                lexAccessApiResult.SetJavaObjs(newLexRecordObjs);
            }

            return(FormatResultToStr(lexAccessApiResult, @base, showQuery, query, noOutputFlag, noOutputMsg,
                                     showTotalRecNum, lexRecordFormat, fieldSep));
        }
 public static string GetLexRecordInfo(LexRecord lexRecord)
 {
     string eui = lexRecord.GetEui();
     string cat = lexRecord.GetCategory();
     string @base = lexRecord.GetBase();
     string info = eui + "|" + @base + "|" + cat;
     return info;
 }
Example #4
0
        /***********************************************************************************/
        // The following methods map codes in the NIH Specialist Lexicon
        // into the codes used in simplenlg
        /***********************************************************************************/

        /**
         * get the simplenlg LexicalCategory of a record
         *
         * @param cat
         * @return
         */
        private LexicalCategory getSimplenlgCategory(LexRecord record)
        {
            string cat = record.GetCategory();

            if (cat == null)
            {
                return(new LexicalCategory(LexicalCategory.LexicalCategoryEnum.ANY));
            }
            else if (cat.Equals("noun", StringComparison.OrdinalIgnoreCase))
            {
                return(new LexicalCategory(LexicalCategory.LexicalCategoryEnum.NOUN));
            }
            else if (cat.Equals("verb", StringComparison.OrdinalIgnoreCase))
            {
                return(new LexicalCategory(LexicalCategory.LexicalCategoryEnum.VERB));
            }
            else if (cat.Equals("aux", StringComparison.OrdinalIgnoreCase) && string.Equals(record.GetBase(), "be", StringComparison.CurrentCultureIgnoreCase))
            { // return aux "be" as a VERB
                // not needed for other aux "have" and "do", they have a verb entry
                return(new LexicalCategory(LexicalCategory.LexicalCategoryEnum.VERB));
            }
            else if (cat.Equals("adj", StringComparison.OrdinalIgnoreCase))
            {
                return(new LexicalCategory(LexicalCategory.LexicalCategoryEnum.ADJECTIVE));
            }
            else if (cat.Equals("adv", StringComparison.OrdinalIgnoreCase))
            {
                return(new LexicalCategory(LexicalCategory.LexicalCategoryEnum.ADVERB));
            }
            else if (cat.Equals("pron", StringComparison.OrdinalIgnoreCase))
            {
                return(new LexicalCategory(LexicalCategory.LexicalCategoryEnum.PRONOUN));
            }
            else if (cat.Equals("det", StringComparison.OrdinalIgnoreCase))
            {
                return(new LexicalCategory(LexicalCategory.LexicalCategoryEnum.DETERMINER));
            }
            else if (cat.Equals("prep", StringComparison.OrdinalIgnoreCase))
            {
                return(new LexicalCategory(LexicalCategory.LexicalCategoryEnum.PREPOSITION));
            }
            else if (cat.Equals("conj", StringComparison.OrdinalIgnoreCase))
            {
                return(new LexicalCategory(LexicalCategory.LexicalCategoryEnum.CONJUNCTION));
            }
            else if (cat.Equals("compl", StringComparison.OrdinalIgnoreCase))
            {
                return(new LexicalCategory(LexicalCategory.LexicalCategoryEnum.COMPLEMENTISER));
            }
            else if (cat.Equals("modal", StringComparison.OrdinalIgnoreCase))
            {
                return(new LexicalCategory(LexicalCategory.LexicalCategoryEnum.MODAL));
            }
            else
            { // return ANY for other cats
                return(new LexicalCategory(LexicalCategory.LexicalCategoryEnum.ANY));
            }
        }
Example #5
0
        public LexRecordNomObj(LexRecord lexRecord)

        {
            if (lexRecord != null)

            {
                base_            = lexRecord.GetBase();
                eui_             = lexRecord.GetEui();
                category_        = lexRecord.GetCategory();
                nominalizations_ = lexRecord.GetNominalizations();
            }
        }
Example #6
0
        public static bool CheckGlreg(LexRecord lexRecord, string inBase, int contentType)

        {
            bool   validFlag = true;
            string cat       = lexRecord.GetCategory();

            if (cat.Equals(LexRecordUtil.GetCategory(7)))

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

                bool hasGlreg = false;
                for (int i = 0; i < variants.Count; i++)

                {
                    string variant = (string)variants[i];
                    if ((variant.Equals("glreg")) || (variant.Equals("group(glreg)")))


                    {
                        hasGlreg = true;
                        break;
                    }
                }

                if (hasGlreg == true)

                {
                    validFlag = false;
                    for (int j = 0; j < glregEnds_.Count; j++)

                    {
                        string ending = (string)glregEnds_[j];
                        if (inBase.EndsWith(ending, StringComparison.Ordinal) == true)

                        {
                            validFlag = true;
                            break;
                        }
                    }
                }

                if (!validFlag)

                {
                    ErrMsgUtilLexRecord.AddContentErrMsg(contentType, 4, inBase, lexRecord);
                }
            }

            return(validFlag);
        }
        private static bool CheckIllegalCat(LexRecord lexRecord)

        {
            bool   validFlag = true;
            string cat       = lexRecord.GetCategory();

            if (!LexRecordUtil.IsCategory(cat))

            {
                validFlag = false;
                ErrMsgUtilLexRecord.AddContentErrMsg(3, 1, cat, lexRecord);
            }

            return(validFlag);
        }
Example #8
0
        public CatEntryGJdV(LexRecord lexRecord)

        {
            string cat = lexRecord.GetCategory();

            if (cat.Equals("verb"))

            {
                verbEntry_ = new VerbEntry(lexRecord);
            }
            else if (cat.Equals("noun"))

            {
                nounEntry_ = new NounEntry(lexRecord);
            }
            else if (cat.Equals("adj"))

            {
                adjEntry_ = new AdjEntry(lexRecord);
            }
            else if (cat.Equals("adv"))

            {
                advEntry_ = new AdvEntry(lexRecord);
            }
            else if (cat.Equals("aux"))

            {
                auxEntry_ = new AuxEntry(lexRecord);
            }
            else if (cat.Equals("modal"))

            {
                modalEntry_ = new ModalEntry(lexRecord);
            }
            else if (cat.Equals("pron"))

            {
                pronEntry_ = new PronEntry(lexRecord);
            }
            else if (cat.Equals("det"))

            {
                detEntry_ = new DetEntry(lexRecord);
            }
        }
Example #9
0
        private static bool CheckNomCat(LexRecord lexRecord)
        {
            bool          validFlag = true;
            string        cat       = lexRecord.GetCategory();
            List <string> nomList   = lexRecord.GetNominalizations();


            foreach (string nom in nomList)

            {
                if (!IsLegalCat(nom, cat))

                {
                    validFlag = false;
                    ErrMsgUtilLexRecord.AddContentErrMsg(6, 10, nom, lexRecord);
                }
            }

            return(validFlag);
        }
Example #10
0
        //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public static boolean Check(java.util.Vector<gov.nih.nlm.nls.lexCheck.Lib.LexRecord> lexRecords, java.util.Hashtable<String, java.util.HashSet<String>> dupRecExpList, java.io.BufferedWriter out, boolean verbose) throws java.io.IOException
        public static bool Check(List <LexRecord> lexRecords, Dictionary <string, HashSet <string> > dupRecExpList,
                                 System.IO.StreamWriter @out, bool verbose)


        {
            bool validFlag = true;

            int recSize = lexRecords.Count;

            for (int i = 0; i < recSize; i++)

            {
                LexRecord lexRecord = (LexRecord)lexRecords[i];
                string    cit       = lexRecord.GetBase();
                string    cat       = lexRecord.GetCategory();
                string    eui       = lexRecord.GetEui();

                string citCat  = cit + "|" + cat;
                bool   dupFlag = AddToCitCatEuisTable(citCat, eui);
                validFlag = (validFlag) && (dupFlag);


                if (verbose == true)

                {
                    if ((i % 100000 == 0) && (i > 0))

                    {
                        Console.WriteLine("- Loaded " + i + " lexRecords to table");
                    }
                }
            }

            if (verbose == true)

            {
                Console.WriteLine("- Complete loaded " + recSize + " lexRecords to hash table for dupRec check");
            }

            if (!validFlag)

            {
                IEnumerator <string> keys = citCatEuisTable_.Keys.GetEnumerator();
                while (keys.MoveNext() == true)

                {
                    string           key     = (string)keys.Current;
                    HashSet <string> euis    = (HashSet <string>)citCatEuisTable_[key];
                    bool             dupFlag = false;

                    if (euis.Count > 1)

                    {
                        IEnumerator <string> it = euis.GetEnumerator();
                        while (it.MoveNext() == true)

                        {
                            string           eui           = (string)it.Current;
                            HashSet <string> dupRecExpEuis = (HashSet <string>)dupRecExpList[key];
                            if ((dupRecExpEuis == null) || (!dupRecExpEuis.Contains(eui)))


                            {
                                dupFlag = true;
                            }
                        }

                        if (dupFlag == true)

                        {
                            string errMsg            = key;
                            IEnumerator <string> it2 = euis.GetEnumerator();
                            while (it2.MoveNext() == true)

                            {
                                errMsg = errMsg + "|" + (string)it2.Current;
                            }

                            @out.Write(errMsg + "|");
                            @out.WriteLine();
                            ErrMsgUtilLexicon.AddContentErrMsg(2, 2, errMsg);
                        }
                    }
                }
            }


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

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

            if (lexRecordObjs_ != null)

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

                {
                    LexRecord temp = (LexRecord)lexRecordObjs_[i];
                    bases.Add(temp.GetBase() + separator + temp.GetEui() + separator + temp.GetCategory());
                }
            }

            return(bases);
        }
Example #12
0
        /***********************************************************************************/
        // The following methods map codes in the NIH Specialist Lexicon
        // into the codes used in simplenlg
        /***********************************************************************************/

        /**
         * get the simplenlg LexicalCategory of a record
         *
         * @param cat
         * @return
         */

        private LexicalCategory getSimplenlgCategory(LexRecord record)
        {
            string cat = record.GetCategory();

            if (cat == null)
            {
                return(new LexicalCategory_ANY());
            }
            else if (cat.equalsIgnoreCase("noun"))
            {
                return(new LexicalCategory_NOUN());
            }
            else if (cat.equalsIgnoreCase("verb"))
            {
                return(new LexicalCategory_VERB());
            }
            else if (cat.equalsIgnoreCase("aux") &&
                     record.GetBase().equalsIgnoreCase("be"))    // return aux "be"
            // as a VERB
            // not needed for other aux "have" and "do", they have a verb entry
            {
                return(new LexicalCategory_VERB());
            }
            else if (cat.equalsIgnoreCase("adj"))
            {
                return(new LexicalCategory_ADJECTIVE());
            }
            else if (cat.equalsIgnoreCase("adv"))
            {
                return(new LexicalCategory_ADVERB());
            }
            else if (cat.equalsIgnoreCase("pron"))
            {
                return(new LexicalCategory_PRONOUN());
            }
            else if (cat.equalsIgnoreCase("det"))
            {
                return(new LexicalCategory_DETERMINER());
            }
            else if (cat.equalsIgnoreCase("prep"))
            {
                return(new LexicalCategory_PREPOSITION());
            }
            else if (cat.equalsIgnoreCase("conj"))
            {
                return(new LexicalCategory_CONJUNCTION());
            }
            else if (cat.equalsIgnoreCase("compl"))
            {
                return(new LexicalCategory_COMPLEMENTISER());
            }
            else if (cat.equalsIgnoreCase("modal"))
            {
                return(new LexicalCategory_MODAL());
            }

            // return ANY for other cats
            else
            {
                return(new LexicalCategory_ANY());
            }
        }
Example #13
0
        public static bool Check(LineObject lineObject, bool printFlag, CheckSt st, CheckSt catSt, LexRecord lexObj,
                                 int nextState, bool debugFlag)

        {
            bool   flag     = false;
            string category = lexObj.GetCategory();

            if (category.Equals("verb") == true)

            {
                flag = CheckVerb.Check(lineObject, printFlag, catSt, lexObj, debugFlag);
            }
            else if (category.Equals("aux") == true)

            {
                flag = CheckAux.Check(lineObject, printFlag, catSt, lexObj, debugFlag);
            }
            else if (category.Equals("modal") == true)

            {
                flag = CheckModal.Check(lineObject, printFlag, catSt, lexObj, debugFlag);
            }
            else if (category.Equals("noun") == true)

            {
                flag = CheckNoun.Check(lineObject, printFlag, catSt, lexObj, debugFlag);
            }
            else if (category.Equals("pron") == true)

            {
                flag = CheckPron.Check(lineObject, printFlag, catSt, lexObj, debugFlag);
            }
            else if (category.Equals("adj") == true)

            {
                flag = CheckAdj.Check(lineObject, printFlag, catSt, lexObj, debugFlag);
            }
            else if (category.Equals("adv") == true)

            {
                flag = CheckAdv.Check(lineObject, printFlag, catSt, lexObj, debugFlag);
            }
            else if (category.Equals("prep") == true)

            {
                flag = CheckNone(lineObject, catSt, nextState);
            }
            else if (category.Equals("conj") == true)

            {
                flag = CheckNone(lineObject, catSt, nextState);
            }
            else if (category.Equals("compl") == true)

            {
                flag = CheckNone(lineObject, catSt, nextState);
            }
            else if (category.Equals("det") == true)

            {
                flag = CheckDet.Check(lineObject, printFlag, catSt, lexObj, debugFlag);
            }

            if (catSt.GetCurState() == nextState)

            {
                st.SetCurState(nextState);
                catSt.SetCurState(40);
            }

            return(flag);
        }
Example #14
0
        public static bool CheckRegd(LexRecord lexRecord, string inBase, int contentType)

        {
            bool          validFlag = true;
            string        cat       = lexRecord.GetCategory();
            List <string> variants  = new List <string>();

            if (cat.Equals(LexRecordUtil.GetCategory(10)))

            {
                variants = lexRecord.GetCatEntry().GetVerbEntry().GetVariants();
            }
            else if (cat.Equals(LexRecordUtil.GetCategory(0)))

            {
                variants = lexRecord.GetCatEntry().GetAdjEntry().GetVariants();
            }

            if (variants.Count > 0)

            {
                bool hasRegd = false;

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

                {
                    string variant = (string)variants[i];
                    if (variant.Equals("regd") == true)

                    {
                        hasRegd = true;
                        break;
                    }
                }

                if (hasRegd == true)

                {
                    char   lastChar     = InflVarsAndAgreements.GetLastChar(inBase);
                    char   last2Char    = InflVarsAndAgreements.GetLast2Char(inBase);
                    string lastCharStr  = (new char?(lastChar)).ToString();
                    string last2CharStr = (new char?(last2Char)).ToString();


                    if ((!InflVarsAndAgreements.consonants_.Contains(lastCharStr)) ||
                        (!InflVarsAndAgreements.vowels_.Contains(last2CharStr)))


                    {
                        validFlag = false;
                    }
                }

                if (!validFlag)

                {
                    ErrMsgUtilLexRecord.AddContentErrMsg(contentType, 5, inBase, lexRecord);
                }
            }

            return(validFlag);
        }
        public static bool Check(LexRecord lexRecord, HashSet <string> notBaseFormSet)

        {
            bool          validFlag = true;
            List <string> abbList   = lexRecord.GetAbbreviations();
            string        abbCat    = lexRecord.GetCategory();

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

            {
                string abb = (string)abbList[i];

                int    index1 = abb.IndexOf("|", StringComparison.Ordinal);
                string abbCit = "";
                string abbEui = "";
                if (index1 > 0)

                {
                    abbCit = abb.Substring(0, index1);
                    abbEui = abb.Substring(index1 + 1);
                }
                else

                {
                    abbCit = abb;
                }

                string citCat = abbCit + "|" + abbCat;

                HashSet <string> euisByCitCat = CrossCheckDupLexRecords.GetEuisByCitCat(citCat);

                if (euisByCitCat == null)

                {
                    if (abbEui.Length > 0)

                    {
                        abbList[i] = abbCit;

                        validFlag = false;
                        ErrMsgUtilLexicon.AddContentErrMsg(4, 3, abb + " - None", lexRecord);
                    }
                    else

                    {
                        validFlag = false;

                        if (!notBaseFormSet.Contains(citCat))

                        {
                            ErrMsgUtilLexicon.AddContentErrMsg(4, 4, abb + " - New", lexRecord);
                        }
                    }
                }
                else if (euisByCitCat.Count == 1)

                {
                    List <string> euiList = new List <string>(euisByCitCat);
                    string        newEui  = (string)euiList[0];
                    if (abbEui.Length > 0)

                    {
                        if (euisByCitCat.Contains(abbEui) != true)

                        {
                            validFlag = false;
                            ErrMsgUtilLexicon.AddContentErrMsg(4, 6, abb + " - " + newEui, lexRecord);
                        }
                    }
                    else

                    {
                        string newAbb = abb + "|" + newEui;
                        abbList[i] = newAbb;

                        validFlag = false;
                        ErrMsgUtilLexicon.AddContentErrMsg(4, 5, abb + " - " + newEui, lexRecord);
                    }
                }
                else

                {
                    List <string> euiList = new List <string>(euisByCitCat);
                    if (abbEui.Length > 0)

                    {
                        if (euisByCitCat.Contains(abbEui) != true)

                        {
                            validFlag = false;
                            ErrMsgUtilLexicon.AddContentErrMsg(4, 8, abb + " - " + euiList, lexRecord);
                        }
                    }
                    else

                    {
                        validFlag = false;
                        ErrMsgUtilLexicon.AddContentErrMsg(4, 7, abb + " - " + euiList, lexRecord);
                    }
                }
            }


            return(validFlag);
        }