Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        public static void AddContentErrMsg(int contentType, int errType, string curItem, LexRecord lexRecord,
                                            string[][] errTypeStrs, int[] errTypeNos, bool crossRefFlag)

        {
            string contentTypeStr = LexRecordUtil.GetContentTypeStr(contentType);

            if (crossRefFlag == true)

            {
                contentTypeStr = LexRecordUtil.GetCrossRefTypeStr(contentType);
            }

            string errTypeStr = GetErrTypeStr(errType, errTypeStrs);
            string errFixStr  = GetErrFixStr(errType, errTypeStrs);


            string errMsg = "** Content Err in " + contentTypeStr + " - " + errTypeStr + " (" + curItem + "): @ [" +
                            LexRecordUtil.GetLexRecordInfo(lexRecord) + "]" + errFixStr + GlobalVars.LS_STR;


            if (errType == 9)

            {
                errMsg = errMsg + "=> Add EUI (" + lexRecord.GetEui() +
                         ") to irregExcetions.data if this Err is an OK exception." + GlobalVars.LS_STR;
            }


            errMsg_ += errMsg;

            AddErrTypeNo(errType, errTypeNos);
        }
Ejemplo n.º 3
0
 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;
 }
Ejemplo n.º 4
0
        //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public static void CheckLexRecords(java.util.Vector<gov.nih.nlm.nls.lexCheck.Lib.LexRecord> lexRecords, java.io.BufferedWriter out, boolean verbose, java.util.HashSet<String> irregExpEuiList) throws Exception
        public static void CheckLexRecords(List <LexRecord> lexRecords, System.IO.StreamWriter @out, bool verbose,
                                           HashSet <string> irregExpEuiList)


        {
            int errRecordNo = 0;
            int okRecordNo  = 0;
            int recSize     = lexRecords.Count;

            if (verbose == true)

            {
                Console.WriteLine("===== Check LexRecord Contents =====");
            }

            if (lexRecords.Count > 0)

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

                {
                    LexRecord lexRecord = (LexRecord)lexRecords[i];
                    if (verbose == true)

                    {
                        Console.WriteLine("--- Checking: " + lexRecord.GetEui() + " ---");
                    }

                    if (!StaticCheckLexRecord(lexRecord, irregExpEuiList))

                    {
                        Console.WriteLine(ErrMsgUtil.GetErrMsg());
                        errRecordNo++;
                    }
                    else

                    {
                        okRecordNo++;
                    }

                    if (@out != null)

                    {
                        string text = lexRecord.GetText();
                        @out.Write(text);
                    }
                }
            }

            Console.WriteLine("----- Total lexRecords checked: " + recSize);

            Console.WriteLine("--- lexRecord has no error: " + okRecordNo);
            Console.WriteLine("--- lexRecord has error(s): " + errRecordNo);
            Console.WriteLine("----- content error type stats -----");
            Console.WriteLine(ErrMsgUtilLexRecord.GetErrStats());
        }
Ejemplo n.º 5
0
        public LexRecordNomObj(LexRecord lexRecord)

        {
            if (lexRecord != null)

            {
                base_            = lexRecord.GetBase();
                eui_             = lexRecord.GetEui();
                category_        = lexRecord.GetCategory();
                nominalizations_ = lexRecord.GetNominalizations();
            }
        }
Ejemplo n.º 6
0
        private static bool CheckIllegalEui(LexRecord lexRecord)

        {
            bool   validFlag = true;
            string eui       = lexRecord.GetEui();

            if (eui.Equals("E0000000") == true)

            {
                validFlag = false;
                ErrMsgUtilLexRecord.AddContentErrMsg(4, 1, eui, lexRecord);
            }

            return(validFlag);
        }
Ejemplo n.º 7
0
        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);
        }
Ejemplo n.º 8
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) throws java.io.IOException
        public static bool Check(List <LexRecord> lexRecords)


        {
            bool             validFlag = true;
            HashSet <string> euiList   = new HashSet <string>();

            int recSize = lexRecords.Count;

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

            {
                LexRecord lexRecord = (LexRecord)lexRecords[i];
                string    eui       = lexRecord.GetEui();
                if (!euiList.Add(eui))

                {
                    validFlag = false;
                    ErrMsgUtilLexicon.AddContentErrMsg(1, 1, eui, lexRecord);
                }
            }

            return(validFlag);
        }
Ejemplo n.º 9
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);
        }
Ejemplo n.º 10
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);
        }
Ejemplo n.º 11
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);
        }