//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, java.io.BufferedWriter dupOut, boolean verbose, java.util.Hashtable<String, java.util.HashSet<String>> dupRecExpList, java.util.HashSet<String> notBaseFormSet) throws java.io.IOException
        public static void CheckLexRecords(List <LexRecord> lexRecords, System.IO.StreamWriter @out,
                                           System.IO.StreamWriter dupOut, bool verbose, Dictionary <string, HashSet <string> > dupRecExpList,
                                           HashSet <string> notBaseFormSet)


        {
            if (verbose == true)

            {
                Console.WriteLine("===== Check Lexicon Cross-Ref Contents =====");
            }

            ErrMsgUtil.ResetErrMsg();
            bool validFlag = true;

            bool dupEuiFlag = CrossCheckDupEuis.Check(lexRecords);

            bool dupRecFlag = CrossCheckDupLexRecords.Check(lexRecords, dupRecExpList, dupOut, verbose);

            validFlag = (dupEuiFlag) && (dupRecFlag);

            int recSize = lexRecords.Count;

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

            {
                LexRecord lexRecord = (LexRecord)lexRecords[i];

                bool nomFlag = CrossCheckNomEui.Check(lexRecord);


                bool abbFlag = CrossCheckAbbEui.Check(lexRecord, notBaseFormSet);

                bool acrFlag = CrossCheckAcrEui.Check(lexRecord, notBaseFormSet);
                validFlag = (validFlag) && (nomFlag) && (abbFlag) && (acrFlag);

                if (@out != null)

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

            bool symFlag = CrossCheckNomSym.Check(lexRecords);

            validFlag = (symFlag) && (validFlag);


            if (!validFlag)

            {
                Console.WriteLine(ErrMsgUtil.GetErrMsg());
            }

            Console.WriteLine("----- Total lexRecords checked: " + recSize);
            Console.WriteLine("----- cross-ref content error type stats -----");
            Console.WriteLine(ErrMsgUtilLexicon.GetErrStats());
        }
        //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);
        }
Exemple #3
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 static bool Check(LexRecord lexRecord)

        {
            bool          validFlag = true;
            List <string> nomList   = lexRecord.GetNominalizations();

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

            {
                string nom = (string)nomList[i];

                int    index1 = nom.IndexOf("|", StringComparison.Ordinal);
                int    index2 = nom.IndexOf("|", index1 + 1, StringComparison.Ordinal);
                string nomCit = nom.Substring(0, index1);
                string nomCat = "";
                string nomEui = "";
                if (index2 > 0)

                {
                    nomCat = nom.Substring(index1 + 1, index2 - (index1 + 1));
                    nomEui = nom.Substring(index2 + 1);
                }
                else

                {
                    nomCat = nom.Substring(index1 + 1);
                }

                string citCat = nomCit + "|" + nomCat;

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

                if (euisByCit == null)

                {
                    if (nomEui.Length > 0)

                    {
                        nomList[i] = citCat;

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

                    {
                        validFlag = false;
                        ErrMsgUtilLexicon.AddContentErrMsg(3, 4, nom + " - New", lexRecord);
                    }
                }
                else if (euisByCit.Count == 1)

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

                    {
                        if (euisByCit.Contains(nomEui) != true)

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

                    {
                        string newNom = nom + "|" + newEui;
                        nomList[i] = newNom;

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

                {
                    List <string> euiList = new List <string>(euisByCit);
                    if (nomEui.Length > 0)

                    {
                        if (euisByCit.Contains(nomEui) != true)

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

                    {
                        validFlag = false;
                        ErrMsgUtilLexicon.AddContentErrMsg(3, 7, nom + " - " + euiList, 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);
        }
Exemple #6
0
        public static bool Check(List <LexRecord> lexRecords)

        {
            LoadEuiNomObjTable(lexRecords);

            bool validFlag            = true;
            IEnumerator <string> euis = euiNomObjTable_.Keys.GetEnumerator();

            while (euis.MoveNext() == true)

            {
                string          eui             = (string)euis.Current;
                LexRecordNomObj lexRecordNomObj = (LexRecordNomObj)euiNomObjTable_[eui];
                string          cit             = lexRecordNomObj.GetBase();
                string          cat             = lexRecordNomObj.GetCategory();
                string          tarNom          = cit + "|" + cat + "|" + eui;

                List <string> nomList = lexRecordNomObj.GetNominalizations();
                for (int i = 0; i < nomList.Count; i++)

                {
                    string nom = (string)nomList[i];

                    int    index1 = nom.IndexOf("|", StringComparison.Ordinal);
                    int    index2 = nom.IndexOf("|", index1 + 1, StringComparison.Ordinal);
                    string nomCit = nom.Substring(0, index1);
                    string nomCat = "";
                    string nomEui = "";
                    if (index2 > 0)

                    {
                        nomCat = nom.Substring(index1 + 1, index2 - (index1 + 1));
                        nomEui = nom.Substring(index2 + 1);


                        LexRecordNomObj tarLexRecordNomObj = (LexRecordNomObj)euiNomObjTable_[nomEui];

                        if (tarLexRecordNomObj == null)

                        {
                            validFlag = false;
                            ErrMsgUtilLexicon.AddContentErrMsg(3, 11, tarNom + ": " + nom);
                        }
                        else

                        {
                            List <string> tarNomList = tarLexRecordNomObj.GetNominalizations();

                            if (!nomCat.Equals(tarLexRecordNomObj.GetCategory()))

                            {
                                validFlag = false;
                                ErrMsgUtilLexicon.AddContentErrMsg(3, 10, tarNom + ": " + nom);
                            }
                            else if (!nomCit.Equals(tarLexRecordNomObj.GetBase()))

                            {
                                validFlag = false;
                                ErrMsgUtilLexicon.AddContentErrMsg(3, 9, tarNom + ": " + nom);
                            }
                            else if (tarNomList.Count == 0)

                            {
                                validFlag = false;
                                ErrMsgUtilLexicon.AddContentErrMsg(3, 11, tarNom + ": " + nom);
                            }
                            else if (!tarNomList.Contains(tarNom))

                            {
                                validFlag = false;
                                ErrMsgUtilLexicon.AddContentErrMsg(3, 11, tarNom + ": " + nom);
                            }
                        }
                    }
                }
            }


            return(validFlag);
        }