use of edu.uci.ics.texera.storage.DataWriter in project textdb by TextDB.
the class NlpEntityTest method getNextTupleTest10.
@Test
public void getNextTupleTest10() throws Exception {
List<Tuple> data = NlpEntityTestConstants.getOneSentenceTestTuple();
DataWriter oneSentenceDataWriter = RelationManager.getInstance().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);
List<Tuple> expectedResults = NlpEntityTestConstants.getTest10ResultTuples();
boolean contains = TestUtils.equals(expectedResults, returnedResults);
Assert.assertTrue(contains);
}
use of edu.uci.ics.texera.storage.DataWriter in project textdb by TextDB.
the class NlpEntityTest method getNextTupleTest11.
@Test
public void getNextTupleTest11() throws Exception {
List<Tuple> data = NlpEntityTestConstants.getTwoSentenceTestTuple();
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 = Arrays.asList(attribute1, attribute2);
List<Tuple> returnedResults = getQueryResults(TWO_SENTENCE_TABLE, attributeNames, NlpEntityType.NE_ALL);
List<Tuple> expectedResults = NlpEntityTestConstants.getTest11ResultTuple();
boolean contains = TestUtils.equals(expectedResults, returnedResults);
Assert.assertTrue(contains);
}
use of edu.uci.ics.texera.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.getInstance().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.texera.storage.DataWriter in project textdb by TextDB.
the class NlpEntityTest method getNextTupleTest6.
/**
* 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);
}
use of edu.uci.ics.texera.storage.DataWriter in project textdb by TextDB.
the class ComparableMatcherTest method setUp.
@BeforeClass
public static void setUp() throws TexeraException {
RelationManager relationManager = RelationManager.getInstance();
// create the people table and write tuples
relationManager.createTable(PEOPLE_TABLE, TestUtils.getDefaultTestIndex().resolve(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();
// create the people table 2 and write tuples
relationManager.createTable(PEOPLE_TABLE_2, TestUtils.getDefaultTestIndex().resolve(PEOPLE_TABLE_2), TestConstantsRegexSplit.SCHEMA_PEOPLE, LuceneAnalyzerConstants.standardAnalyzerString());
DataWriter people2DataWriter = relationManager.getTableDataWriter(PEOPLE_TABLE_2);
people2DataWriter.open();
for (Tuple tuple : TestConstantsRegexSplit.constructSamplePeopleTuples()) {
people2DataWriter.insertTuple(tuple);
}
people2DataWriter.close();
}
Aggregations