Exemplo n.º 1
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;
        }