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);
        }
        private static bool CheckGlreg(LexRecord lexRecord)

        {
            string @base     = lexRecord.GetBase();
            bool   validFlag = CheckEntry.CheckGlreg(lexRecord, @base, 1);

            return(validFlag);
        }
 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
        public LexRecordNomObj(LexRecord lexRecord)

        {
            if (lexRecord != null)

            {
                base_            = lexRecord.GetBase();
                eui_             = lexRecord.GetEui();
                category_        = lexRecord.GetCategory();
                nominalizations_ = lexRecord.GetNominalizations();
            }
        }
        public static string GetItemFromLexRecord(LexRecord lexRecord, int contentType)
        {
            string outItem = "";
            switch (contentType)

            {
                case 1:
                    outItem = lexRecord.GetBase();
                    break;
            }

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

        {
            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());
                }
            }

            return(bases);
        }
        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);
        }
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
        //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);
        }
Example #11
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 #12
0
        /**
         * make a WordElement from a lexical record. Currently just specifies basic
         * params and inflections Should do more in the future!
         *
         * @param record
         * @return
         */
        private WordElement makeWord(LexRecord record) // LexRecord
        {
            // get basic data
            String          baseForm = record.GetBase();
            LexicalCategory category = record.GetSimpleNLGCategory(record);
            String          id       = record.GetEui();

            // create word class
            WordElement wordElement = new WordElement(baseForm, category, id);

            // now add type information
            switch (category.GetLexicalCategory())
            {
            case LexicalCategory.LexicalCategoryEnum.ADJECTIVE:
                addAdjectiveInfo(wordElement, record.GetCatEntry().GetAdjEntry());
                break;

            case LexicalCategory.LexicalCategoryEnum.ADVERB:
                addAdverbInfo(wordElement, record.GetCatEntry().GetAdvEntry());
                break;

            case LexicalCategory.LexicalCategoryEnum.NOUN:
                addNounInfo(wordElement, record.GetCatEntry().GetNounEntry());
                break;

            case LexicalCategory.LexicalCategoryEnum.VERB:
                addVerbInfo(wordElement, record.GetCatEntry().GetVerbEntry());
                break;
                // ignore closed class words
            }

            Inflection?defaultInfl = wordElement.getDefaultInflectionalVariant();

            // now add inflected forms
            // if (keepStandardInflections || !standardInflections(record,
            // category)) {
            foreach (InflVar inflection in record.GetInflVarsAndAgreements().GetInflValues())
            {
                String simplenlgInflection = getSimplenlgInflection(inflection
                                                                    .GetInflection());

                if (simplenlgInflection != null)
                {
                    String     inflectedForm = inflection.GetVar();
                    Inflection?inflType      = Inflection.REGULAR.getInflCode(inflection.GetType());

                    // store all inflectional variants, except for regular ones
                    // unless explicitly set
                    if (inflType != null &&
                        !(Inflection.REGULAR == inflType && !keepStandardInflections))
                    {
                        wordElement.addInflectionalVariant((Inflection)inflType,
                                                           simplenlgInflection, inflectedForm);
                    }

                    // if the infl variant is the default, also set this feature on
                    // the word
                    if (defaultInfl == null ||
                        (defaultInfl.Equals(inflType) && !(Inflection.REGULAR.Equals(inflType) && !keepStandardInflections)))
                    {
                        wordElement.setFeature(simplenlgInflection, inflectedForm);
                    }

                    // wordElement
                    // .setFeature(simplenlgInflection, inflection.GetVar());
                }
            }
            // }

            // add acronym info
            addAcronymInfo(wordElement, record);

            // now add spelling variants
            addSpellingVariants(wordElement, record);

            return(wordElement);
        }
Example #13
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 #14
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);
        }