public virtual void acronymsTests() { WordElement uk = lexicon.getWord("UK"); WordElement unitedKingdom = lexicon.getWord("United Kingdom"); IList <NLGElement> fullForms = uk.getFeatureAsElementList(LexicalFeature.ACRONYM_OF); Assert.AreEqual(3, fullForms.Count); Assert.IsTrue(fullForms.Contains(unitedKingdom)); }
///** // * convenience method to test that a list is not null and not empty // * // * @param list // * @return // */ //private bool notEmpty<T1>(IList<T1> list) //{ // return list != null && list.Count > 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.Count > 0) { // the list of full forms of which this word is an acronym List <NLGElement> acronymOf = wordElement.getFeatureAsElementList(LexicalFeature.ACRONYM_OF); // keep all acronym full forms and set them up as wordElements foreach (string fullForm in acronyms) { if (fullForm.Contains("|")) { // get the acronym id string acronymID = fullForm.SubstringSpecial(fullForm.IndexOf("|", StringComparison.Ordinal) + 1, fullForm.Length); // create the full form element WordElement fullFormWE = 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); // } }