/** * Scenario 6:Test getNextTuple using two fields: * <p> * Sentence1: Microsoft, Google and Facebook are organizations. Sentence2: * Donald Trump and Barack Obama are persons. * <p> * Only search for Organization for all fields. */ @Test public void getNextTupleTest6() throws Exception { List<Tuple> data = NlpEntityTestConstants.getTest4Tuple(); DataWriter twoSentenceDataWriter = RelationManager.getInstance().getTableDataWriter(TWO_SENTENCE_TABLE); twoSentenceDataWriter.open(); for (Tuple tuple : data) { twoSentenceDataWriter.insertTuple(tuple); } twoSentenceDataWriter.close(); String attribute1 = NlpEntityTestConstants.SENTENCE_ONE; String attribute2 = NlpEntityTestConstants.SENTENCE_TWO; List<String> attributeNames = new ArrayList<>(); attributeNames.add(attribute1); attributeNames.add(attribute2); List<Tuple> returnedResults = getQueryResults(TWO_SENTENCE_TABLE, attributeNames, NlpEntityType.ORGANIZATION); List<Tuple> expectedResults = NlpEntityTestConstants.getTest6ResultTuples(); boolean contains = TestUtils.equals(expectedResults, returnedResults); Assert.assertTrue(contains); }
/** * Scenario 4:Test getNextTuple with more than one span in the return list * and with different recognized classes and more than one fields in the * source tuple. * <p> * Sentence1: Microsoft, Google and Facebook are organizations. Sentence2: * Donald Trump and Barack Obama are persons. Search for all NE_ALL entity * types */ @Test public void getNextTupleTest4() throws Exception { List<Tuple> data = NlpEntityTestConstants.getTest4Tuple(); DataWriter twoSentenceDataWriter = RelationManager.getInstance().getTableDataWriter(TWO_SENTENCE_TABLE); twoSentenceDataWriter.open(); for (Tuple tuple : data) { twoSentenceDataWriter.insertTuple(tuple); } twoSentenceDataWriter.close(); String attribute1 = NlpEntityTestConstants.SENTENCE_ONE; String attribute2 = NlpEntityTestConstants.SENTENCE_TWO; List<String> attributeNames = new ArrayList<>(); attributeNames.add(attribute1); attributeNames.add(attribute2); List<Tuple> returnedResults = getQueryResults(TWO_SENTENCE_TABLE, attributeNames, NlpEntityType.NE_ALL); List<Tuple> expectedResults = NlpEntityTestConstants.getTest4ResultTuples(); boolean contains = TestUtils.equals(expectedResults, returnedResults); Assert.assertTrue(contains); }
/** * Scenario 5:Test getNextTuple using two fields: * <p> * Sentence1: Microsoft, Google and Facebook are organizations. Sentence2: * Donald Trump and Barack Obama are persons. * <p> * Only search the second field for all NE_ALL entity types */ @Test public void getNextTupleTest5() throws Exception { List<Tuple> data = NlpEntityTestConstants.getTest4Tuple(); DataWriter twoSentenceDataWriter = RelationManager.getInstance().getTableDataWriter(TWO_SENTENCE_TABLE); twoSentenceDataWriter.open(); for (Tuple tuple : data) { twoSentenceDataWriter.insertTuple(tuple); } twoSentenceDataWriter.close(); String attribute = NlpEntityTestConstants.SENTENCE_TWO; List<String> attributeNames = new ArrayList<>(); attributeNames.add(attribute); List<Tuple> returnedResults = getQueryResults(TWO_SENTENCE_TABLE, attributeNames, NlpEntityType.NE_ALL); List<Tuple> expectedResults = NlpEntityTestConstants.getTest5ResultTuples(); boolean contains = TestUtils.equals(expectedResults, returnedResults); Assert.assertTrue(contains); }