Ejemplo n.º 1
0
        public static bool CheckSpacesForList(LexRecord lexRecord, int contentType)

        {
            bool validFlag = true;


            List <string> inList = LexRecordUtil.GetListFromLexRecord(lexRecord, contentType);

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

            {
                string inItem    = (string)inList[i];
                string newInItem = StringTrim(inItem);
                if (!newInItem.Equals(inItem))

                {
                    validFlag = false;
                    ErrMsgUtilLexRecord.AddContentErrMsg(contentType, 7, inItem, lexRecord);


                    LexRecordUtil.SetItemInListInLexRecordAt(lexRecord, contentType, newInItem, i);
                }
            }

            return(validFlag);
        }
Ejemplo n.º 2
0
        public static bool CheckDuplicatesForList(LexRecord lexRecord, int contentType)

        {
            bool validFlag = true;


            List <string> inList = LexRecordUtil.GetListFromLexRecord(lexRecord, contentType);
            List <string> uList  = new List <string>();

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

            {
                string inItem = (string)inList[i];

                if (uList.Contains(inItem) == true)

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

                {
                    uList.Add(inItem);
                }
            }

            if (!validFlag)

            {
                LexRecordUtil.SetListInLexRecord(lexRecord, contentType, uList);
            }

            return(validFlag);
        }
Ejemplo n.º 3
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.º 4
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);
        }
Ejemplo n.º 5
0
        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);
        }
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 static bool CheckSpacesForItem(LexRecord lexRecord, int contentType)

        {
            bool   validFlag = true;
            string inItem    = LexRecordUtil.GetItemFromLexRecord(lexRecord, contentType);

            string newInItem = StringTrim(inItem);

            if (!newInItem.Equals(inItem))

            {
                validFlag = false;
                ErrMsgUtilLexRecord.AddContentErrMsg(contentType, 7, inItem, lexRecord);


                LexRecordUtil.SetItemInLexRecord(lexRecord, contentType, newInItem);
            }

            return(validFlag);
        }
Ejemplo n.º 8
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);
        }
Ejemplo n.º 9
0
        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);
        }
Ejemplo n.º 10
0
        public static bool CheckDoublePipesForList(LexRecord lexRecord, int contentType)

        {
            bool validFlag = true;


            List <string> inList = LexRecordUtil.GetListFromLexRecord(lexRecord, contentType);

            foreach (string inItem in inList)

            {
                if (inItem.IndexOf("||", StringComparison.Ordinal) >= 0)

                {
                    ErrMsgUtilLexRecord.AddContentErrMsg(contentType, 3, inItem, lexRecord);

                    validFlag = false;
                }
            }

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