use of edu.uci.ics.textdb.storage.DataWriter in project textdb by TextDB.
the class NlpEntityTest method getNextTupleTest4.
/**
* 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.getRelationManager().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);
}
use of edu.uci.ics.textdb.storage.DataWriter in project textdb by TextDB.
the class NlpEntityTest method getNextTupleTest3.
/**
* Scenario 3: Test getNextTuple with more than one span in the return list
* and with different recognized classes. Text: Microsoft, Google and
* Facebook are organizations and Donald Trump and Barack Obama are persons.
* Search for all NE_ALL entity types
*/
@Test
public void getNextTupleTest3() throws Exception {
List<Tuple> data = NlpEntityTestConstants.getTest3Tuple();
DataWriter oneSentenceDataWriter = RelationManager.getRelationManager().getTableDataWriter(ONE_SENTENCE_TABLE);
oneSentenceDataWriter.open();
for (Tuple tuple : data) {
oneSentenceDataWriter.insertTuple(tuple);
}
oneSentenceDataWriter.close();
String attribute1 = NlpEntityTestConstants.SENTENCE_ONE;
List<String> attributeNames = new ArrayList<>();
attributeNames.add(attribute1);
List<Tuple> returnedResults = getQueryResults(ONE_SENTENCE_TABLE, attributeNames, NlpEntityType.NE_ALL);
List<Tuple> expectedResults = NlpEntityTestConstants.getTest3ResultTuples();
boolean contains = TestUtils.equals(expectedResults, returnedResults);
Assert.assertTrue(contains);
}
use of edu.uci.ics.textdb.storage.DataWriter in project textdb by TextDB.
the class NlpEntityTest method getNextTupleTest2.
/**
* Scenario 2: Test getNextTuple with more than one span in the return list
* Text: Microsoft, Google and Facebook are organizations Search for all
* NE_ALL entity types
*/
@Test
public void getNextTupleTest2() throws Exception {
List<Tuple> data = NlpEntityTestConstants.getTest2Tuple();
DataWriter oneSentenceDataWriter = RelationManager.getRelationManager().getTableDataWriter(ONE_SENTENCE_TABLE);
oneSentenceDataWriter.open();
for (Tuple tuple : data) {
oneSentenceDataWriter.insertTuple(tuple);
}
oneSentenceDataWriter.close();
String attribute1 = NlpEntityTestConstants.SENTENCE_ONE;
List<String> attributeNames = new ArrayList<>();
attributeNames.add(attribute1);
List<Tuple> returnedResults = getQueryResults(ONE_SENTENCE_TABLE, attributeNames, NlpEntityType.NE_ALL);
List<Tuple> expectedResults = NlpEntityTestConstants.getTest2ResultTuples();
boolean contains = TestUtils.equals(expectedResults, returnedResults);
Assert.assertTrue(contains);
}
use of edu.uci.ics.textdb.storage.DataWriter in project textdb by TextDB.
the class NlpEntityTest method getNextTupleTestWithLimitOffset.
public void getNextTupleTestWithLimitOffset() throws Exception {
List<Tuple> data = NlpEntityTestConstants.getOneSentenceTestTuple();
DataWriter oneSentenceDataWriter = RelationManager.getRelationManager().getTableDataWriter(ONE_SENTENCE_TABLE);
oneSentenceDataWriter.open();
for (Tuple tuple : data) {
oneSentenceDataWriter.insertTuple(tuple);
}
oneSentenceDataWriter.close();
String attribute1 = NlpEntityTestConstants.SENTENCE_ONE;
List<String> attributeNames = Arrays.asList(attribute1);
List<Tuple> returnedResults = getQueryResults(ONE_SENTENCE_TABLE, attributeNames, NlpEntityType.NE_ALL, 2, 2);
List<Tuple> expectedResults = NlpEntityTestConstants.getTest10ResultTuples();
Assert.assertEquals(returnedResults.size(), 2);
Assert.assertTrue(TestUtils.containsAll(expectedResults, returnedResults));
}
use of edu.uci.ics.textdb.storage.DataWriter in project textdb by TextDB.
the class FuzzyTokenMatcherTestHelper method writeTestTables.
/*
* Creates the test table(s) and writes data into it(them).
*/
public static void writeTestTables() throws TextDBException {
RelationManager relationManager = RelationManager.getRelationManager();
// create the people table and write tuples
relationManager.createTable(PEOPLE_TABLE, "../index/test_tables/" + PEOPLE_TABLE, TestConstants.SCHEMA_PEOPLE, LuceneAnalyzerConstants.standardAnalyzerString());
DataWriter peopleDataWriter = relationManager.getTableDataWriter(PEOPLE_TABLE);
peopleDataWriter.open();
for (Tuple tuple : TestConstants.getSamplePeopleTuples()) {
peopleDataWriter.insertTuple(tuple);
}
peopleDataWriter.close();
}
Aggregations