示例#1
0
        public static List<string> GetListFromLexRecord(LexRecord lexRecord, int contentType)
        {
            List<string> outList = new List<string>();
            switch (contentType)

            {
                case 2:
                    outList = lexRecord.GetSpellingVars();
                    break;
                case 5:
                    outList = lexRecord.GetVariants();
                    break;
                case 6:
                    outList = lexRecord.GetNominalizations();
                    break;
                case 7:
                    outList = lexRecord.GetAbbreviations();
                    break;
                case 8:
                    outList = lexRecord.GetAcronyms();
                    break;
            }

            return outList;
        }
示例#2
0
        /**
         * extract information about acronyms from NIH record, and add to a
         * simplenlg WordElement.
         *
         * <P>
         * Acronyms are represented as lists of word elements. Any acronym will have
         * a list of full form word elements, retrievable via
         * {@link LexicalFeature#ACRONYM_OF}
         *
         * @param wordElement
         * @param record
         */

        private void addAcronymInfo(WordElement wordElement, LexRecord record)
        {
            // NB: the acronyms are actually the full forms of which the word is an
            // acronym
            List <string> acronyms = record.GetAcronyms();

            if (!acronyms.isEmpty())
            {
                // the list of full forms of which this word is an acronym
                List <INLGElement> acronymOf = wordElement
                                               .getFeatureAsElementList(LexicalFeature.ACRONYM_OF);

                // keep all acronym full forms and set them up as wordElements
                foreach (var fullForm in acronyms)
                {
                    if (fullForm.contains("|"))
                    {
                        // get the acronym id
                        string acronymID = fullForm.substring(
                            fullForm.indexOf("|") + 1, fullForm.length());
                        // create the full form element
                        WordElement fullFormWE = this.getWordByID(acronymID);

                        if (fullForm != null)
                        {
                            // add as full form of this acronym
                            acronymOf.add(fullFormWE);

                            // List<NLGElement> fullFormAcronyms = fullFormWE
                            // .getFeatureAsElementList(LexicalFeature.ACRONYMS);
                            // fullFormAcronyms.add(wordElement);
                            // fullFormWE.setFeature(LexicalFeature.ACRONYMS,
                            // fullFormAcronyms);
                        }
                    }
                }

                // set all the full forms for this acronym
                wordElement.setFeature(LexicalFeature.ACRONYM_OF, acronymOf);
            }

            // if (!acronyms.isEmpty()) {
            //
            // string acronym = acronyms.get(0);
            // // remove anything after a |, this will be an NIH ID
            // if (acronym.contains("|"))
            // acronym = acronym.substring(0, acronym.indexOf("|"));
            // wordElement.setFeature(LexicalFeature.ACRONYM_OF, acronym);
            // }

            return;
        }
示例#3
0
        public static void SetItemInListInLexRecordAt(LexRecord lexRecord, int contentType, string item, int index)
        {
            switch (contentType)

            {
                case 2:
                    lexRecord.GetSpellingVars()[index] = item;
                    break;
                case 5:
                    lexRecord.GetVariants()[index] = item;
                    break;
                case 6:
                    lexRecord.GetNominalizations()[index] = item;
                    break;
                case 7:
                    lexRecord.GetAbbreviations()[index] = item;
                    break;
                case 8:
                    lexRecord.GetAcronyms()[index] = item;
                    break;
            }
        }
示例#4
0
        private static void GetLexRecord(Node node, LexRecord lexRecord, CatEntry catEntry)


        {
            if (node.NodeType == XmlNodeType.Element)

            {
                if (node.Name.Equals("base"))

                {
                    lexRecord.SetBase(getValue(node));
                }
                else if (node.Name.Equals("eui"))

                {
                    lexRecord.SetEui(getValue(node));
                }
                else if (node.Name.Equals("cat"))
                {
                    lexRecord.SetCat(getValue(node));
                }
                else if (node.Name.Equals("spellingVars"))

                {
                    lexRecord.SetSpellingVar(getValue(node));
                }
                else if (node.Name.Equals("acronyms"))

                {
                    lexRecord.GetAcronyms().Add(getValue(node));
                }
                else if (node.Name.Equals("abbreviations"))

                {
                    lexRecord.GetAbbreviations().Add(getValue(node));
                }
                else if (node.Name.Equals("annotations"))

                {
                    lexRecord.GetAnnotations().Add(getValue(node));
                }
                else if (node.Name.Equals("signature"))

                {
                    lexRecord.SetSignature(getValue(node));
                }
                else if (node.Name.Equals("verbEntry"))

                {
                    catEntry = getVerbValues(node);
                    lexRecord.SetCatEntry(catEntry);
                }
                else if (node.Name.Equals("auxEntry"))

                {
                    catEntry = getAuxValues(node);
                    lexRecord.SetCatEntry(catEntry);
                }
                else if (node.Name.Equals("modalEntry"))

                {
                    catEntry = getModalValues(node);
                    lexRecord.SetCatEntry(catEntry);
                }
                else if (node.Name.Equals("nounEntry"))

                {
                    catEntry = getNounValues(node);
                    lexRecord.SetCatEntry(catEntry);
                }
                else if (node.Name.Equals("pronEntry"))

                {
                    catEntry = getPronValues(node);
                    lexRecord.SetCatEntry(catEntry);
                }
                else if (node.Name.Equals("adjEntry"))

                {
                    catEntry = getAdjValues(node);
                    lexRecord.SetCatEntry(catEntry);
                }
                else if (node.Name.Equals("advEntry"))

                {
                    catEntry = getAdvValues(node);
                    lexRecord.SetCatEntry(catEntry);
                }
                else if (node.Name.Equals("detEntry"))

                {
                    catEntry = getDetValues(node);
                    lexRecord.SetCatEntry(catEntry);
                }
            }

            for (Node child = node.FirstChild; child != null; child = child.NextSibling)


            {
                GetLexRecord(child, lexRecord, catEntry);
            }
        }
        public static bool Check(LexRecord lexRecord, HashSet <string> notBaseFormSet)

        {
            bool          validFlag = true;
            List <string> acrList   = lexRecord.GetAcronyms();
            string        acrCat    = lexRecord.GetCategory();

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

            {
                string acr = (string)acrList[i];

                int    index1 = acr.IndexOf("|", StringComparison.Ordinal);
                string acrCit = "";
                string acrEui = "";
                if (index1 > 0)

                {
                    acrCit = acr.Substring(0, index1);
                    acrEui = acr.Substring(index1 + 1);
                }
                else

                {
                    acrCit = acr;
                }

                string citCat = acrCit + "|" + acrCat;

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

                if (euisByCit == null)

                {
                    if (acrEui.Length > 0)

                    {
                        acrList[i] = acrCit;

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

                    {
                        validFlag = false;

                        if (!notBaseFormSet.Contains(citCat))

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

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

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

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

                    {
                        string newAcr = acr + "|" + newEui;
                        acrList[i] = newAcr;

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

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

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

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

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


            return(validFlag);
        }