SynonymGenerationTools implements TermGenieScriptFunctionsSynonyms { @Override public List<ISynonym> synonyms(String prefix, OWLObject x, OWLGraphWrapper ontology, String suffix, String defaultScope, String label) { List<ISynonym> synonyms = getSynonyms(x, ontology, null, false); if (synonyms == null || synonyms.isEmpty()) { return null; } List<ISynonym> results = new ArrayList<ISynonym>(); for (ISynonym synonym : synonyms) { StringBuilder sb = new StringBuilder(); if (prefix != null) { sb.append(prefix); } sb.append(synonym.getLabel()); if (suffix != null) { sb.append(suffix); } String scope = synonym.getScope(); if (defaultScope != null) { if (defaultScope.equals(OboFormatTag.TAG_BROAD.getTag())) { scope = OboFormatTag.TAG_BROAD.getTag(); } else { scope = matchScopes(defaultScope, scope).getTwo(); } } addSynonym(results, scope, sb.toString(), label); } return results; } SynonymGenerationTools(boolean filterNonAsciiSynonyms); @Override List<ISynonym> synonyms(String prefix,
			OWLObject x,
			OWLGraphWrapper ontology,
			String suffix,
			String defaultScope,
			String label); @Override List<ISynonym> synonyms(String[] prefixes,
			String[] scopes,
			OWLObject x,
			OWLGraphWrapper ontology,
			String[] suffixes,
			String label); @Override List<ISynonym> addSynonym(String label,
			List<ISynonym> results,
			String prefix,
			String infix,
			String suffix,
			String scope); @Override List<ISynonym> synonyms(String prefix,
			OWLObject x1,
			OWLGraphWrapper ontology1,
			String infix,
			OWLObject x2,
			OWLGraphWrapper ontology2,
			String suffix,
			String defaultScope,
			String label); @Override List<ISynonym> synonyms(String prefix,
			OWLObject x1,
			OWLGraphWrapper ontology1,
			String infix,
			OWLObject x2,
			OWLGraphWrapper ontology2,
			String suffix,
			String defaultScope,
			String label,
			String requiredPrefixLeft,
			boolean ignoreSynonymsRight); @Override List<ISynonym> synonyms(String prefix,
			OWLObject[] terms,
			String[] defaultScopes,
			OWLGraphWrapper ontology,
			String infix,
			String suffix,
			String label); @Override void setSynonymFilters(boolean requireCategories,
			boolean removeCategories,
			String[] categories); @Override void resetSynonymFilters();  }
@Test public void testSynonymsPair() { String defaultScope = null; List<ISynonym> synonyms = tool.synonyms("prefix-", t1, null, "-infix-", t2, null, "-suffix", defaultScope, "prefix-t1-infix-t2-suffix"); assertEquals(6, synonyms.size()); Iterator<ISynonym> it = synonyms.iterator(); assertSynonym("prefix-s11-infix-s21-suffix", OboFormatTag.TAG_NARROW, it.next()); assertSynonym("prefix-s11-infix-s22-suffix", OboFormatTag.TAG_EXACT, it.next()); assertSynonym("prefix-s11-infix-t2-suffix", OboFormatTag.TAG_EXACT, it.next()); assertSynonym("prefix-s12-infix-s23-suffix", OboFormatTag.TAG_BROAD, it.next()); assertSynonym("prefix-t1-infix-s21-suffix", OboFormatTag.TAG_NARROW, it.next()); assertSynonym("prefix-t1-infix-s22-suffix", OboFormatTag.TAG_EXACT, it.next()); }
@Test public void testSynonymsList() { OWLObject[] terms = {t1, t2, t4}; String[] defaultScopes = null; List<ISynonym> synonyms = tool.synonyms("prefix-", terms, defaultScopes, null, "-infix-", "-suffix", "prefix-t1-infix-t2-infix-t4-suffix"); assertEquals(12, synonyms.size()); Iterator<ISynonym> it = synonyms.iterator(); assertSynonym("prefix-s11-infix-s21-infix-s41-suffix", OboFormatTag.TAG_NARROW, it.next()); assertSynonym("prefix-s11-infix-s21-infix-t4-suffix", OboFormatTag.TAG_NARROW, it.next()); assertSynonym("prefix-s11-infix-s22-infix-s41-suffix", OboFormatTag.TAG_NARROW, it.next()); assertSynonym("prefix-s11-infix-s22-infix-t4-suffix", OboFormatTag.TAG_EXACT, it.next()); assertSynonym("prefix-s11-infix-t2-infix-s41-suffix", OboFormatTag.TAG_NARROW, it.next()); assertSynonym("prefix-s11-infix-t2-infix-t4-suffix", OboFormatTag.TAG_EXACT, it.next()); assertSynonym("prefix-s12-infix-s23-infix-s42-suffix", OboFormatTag.TAG_BROAD, it.next()); assertSynonym("prefix-t1-infix-s21-infix-s41-suffix", OboFormatTag.TAG_NARROW, it.next()); assertSynonym("prefix-t1-infix-s21-infix-t4-suffix", OboFormatTag.TAG_NARROW, it.next()); assertSynonym("prefix-t1-infix-s22-infix-s41-suffix", OboFormatTag.TAG_NARROW, it.next()); assertSynonym("prefix-t1-infix-s22-infix-t4-suffix", OboFormatTag.TAG_EXACT, it.next()); assertSynonym("prefix-t1-infix-t2-infix-s41-suffix", OboFormatTag.TAG_NARROW, it.next()); }