From dd904f01fa42216019ddc36d37b55cb97138d6cd Mon Sep 17 00:00:00 2001 From: Heiko Dietze Date: Mon, 23 Nov 2015 17:32:12 -0800 Subject: [PATCH] Full synonym cross-products for TO eq template * allow non-ASCII (i.e. Japanese) synonyms * see issue #80 --- .../TermGenieWebAppTOContextListener.java | 3 ++- .../src/main/resources/rules/to/eq_simple.js | 4 +--- .../rules/SimpleEntityQualityPatternTest.java | 20 +++++++++++++------ 3 files changed, 17 insertions(+), 10 deletions(-) diff --git a/TermGenie/WebApplications/TermGenieWebAppTO/src/main/java/org/bbop/termgenie/servlets/TermGenieWebAppTOContextListener.java b/TermGenie/WebApplications/TermGenieWebAppTO/src/main/java/org/bbop/termgenie/servlets/TermGenieWebAppTOContextListener.java index f8f835cf..fc038d42 100644 --- a/TermGenie/WebApplications/TermGenieWebAppTO/src/main/java/org/bbop/termgenie/servlets/TermGenieWebAppTOContextListener.java +++ b/TermGenie/WebApplications/TermGenieWebAppTO/src/main/java/org/bbop/termgenie/servlets/TermGenieWebAppTOContextListener.java @@ -67,7 +67,8 @@ protected IOCModule getCommitModule() { @Override protected IOCModule getRulesModule() { - return new XMLDynamicRulesModule("termgenie_rules_to.xml", false, true, true, applicationProperties); + boolean filterNonAsciiSynonyms = false; // allow japanese synonyms + return new XMLDynamicRulesModule("termgenie_rules_to.xml", false, true, filterNonAsciiSynonyms, applicationProperties); } @Override diff --git a/TermGenie/WebApplications/TermGenieWebAppTO/src/main/resources/rules/to/eq_simple.js b/TermGenie/WebApplications/TermGenieWebAppTO/src/main/resources/rules/to/eq_simple.js index 0306051c..e55d7507 100644 --- a/TermGenie/WebApplications/TermGenieWebAppTO/src/main/resources/rules/to/eq_simple.js +++ b/TermGenie/WebApplications/TermGenieWebAppTO/src/main/resources/rules/to/eq_simple.js @@ -8,9 +8,7 @@ function eq_simple() { var definition = "A trait which is associated with the " + termname(q, TO) + " of " + refname(e, TO) + "."; - var synonyms = null; - // String label, List results, String prefix, String infix, String suffix, String scope - synonyms = termgenie.addSynonym(label, synonyms, null, label, ' trait', 'EXACT'); + var synonyms = termgenie.synonyms(null, e, TO, " ", q, TO, "", null, label); var mdef = createMDef("?Q and 'inheres in' some ?E"); mdef.addParameter('E', e, TO); diff --git a/TermGenie/WebApplications/TermGenieWebAppTO/src/test/java/org/bbop/termgenie/rules/SimpleEntityQualityPatternTest.java b/TermGenie/WebApplications/TermGenieWebAppTO/src/test/java/org/bbop/termgenie/rules/SimpleEntityQualityPatternTest.java index 583c7cb6..4325d86b 100644 --- a/TermGenie/WebApplications/TermGenieWebAppTO/src/test/java/org/bbop/termgenie/rules/SimpleEntityQualityPatternTest.java +++ b/TermGenie/WebApplications/TermGenieWebAppTO/src/test/java/org/bbop/termgenie/rules/SimpleEntityQualityPatternTest.java @@ -1,13 +1,11 @@ package org.bbop.termgenie.rules; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.fail; +import static org.junit.Assert.*; import java.io.File; import java.io.IOException; import java.util.Arrays; +import java.util.Collection; import java.util.Collections; import java.util.List; @@ -29,6 +27,8 @@ import org.junit.BeforeClass; import org.junit.Test; import org.obolibrary.macro.ManchesterSyntaxTool; +import org.obolibrary.oboformat.model.Clause; +import org.obolibrary.oboformat.model.Frame; import org.obolibrary.oboformat.parser.OBOFormatConstants.OboFormatTag; import org.semanticweb.owlapi.model.OWLClassExpression; @@ -55,8 +55,9 @@ private static IOCModule getOntologyModule() throws IOException { @BeforeClass public static void beforeClass() throws IOException { + boolean filterNonAsciiSynonyms = false; // allow japanese synonyms IOCModule ontologyModule = getOntologyModule(); - Injector injector = TermGenieGuice.createInjector(new XMLDynamicRulesModule("termgenie_rules_to.xml", false, true, true, null), + Injector injector = TermGenieGuice.createInjector(new XMLDynamicRulesModule("termgenie_rules_to.xml", false, true, filterNonAsciiSynonyms, null), ontologyModule, new ReasonerModule(null)); @@ -111,7 +112,14 @@ public void test_eq_simple_1() { assertEquals(1, list.size()); TermGenerationOutput output = list.get(0); assertNull(output.getError(), output.getError()); - assertEquals("root cap permeability", output.getTerm().getTagValue(OboFormatTag.TAG_NAME)); + Frame term = output.getTerm(); + assertEquals("root cap permeability", term.getTagValue(OboFormatTag.TAG_NAME)); + Collection synonymClauses = term.getClauses(OboFormatTag.TAG_SYNONYM); + System.out.println(synonymClauses.size()); + for (Clause clause : synonymClauses) { + System.out.println(clause); + } + assertFalse(synonymClauses.isEmpty()); } private List createEQSimpleTask(String entity, String quality) {