use of edu.uci.ics.texera.storage.DataWriter in project textdb by TextDB.
the class NlpEntityTest method getNextTupleTest1.
/**
* Scenario 1: Test getNextTuple with only one span in the return list Text
* : Microsoft is a organization. Search for all NE_ALL entity types
*
* @throws Exception
*/
@Test
public void getNextTupleTest1() throws Exception {
List<Tuple> data = NlpEntityTestConstants.getTest1Tuple();
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.getTest1ResultTuples();
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 getNextTupleTest7.
/**
* Scenario 7:Test getNextTuple using sentence: Sentence1: Feeling the warm
* sun rays beaming steadily down, the girl decided there was no need to
* wear a coat. Search for Adjective.
*/
@Test
public void getNextTupleTest7() throws Exception {
List<Tuple> data = NlpEntityTestConstants.getTest7Tuple();
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.ADJECTIVE);
List<Tuple> expectedResults = NlpEntityTestConstants.getTest7ResultTuples();
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 getNextTupleTest5.
/**
* 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);
}
use of edu.uci.ics.texera.storage.DataWriter in project textdb by TextDB.
the class NlpEntityTest method getNextTupleTest8.
@Test
public void getNextTupleTest8() throws Exception {
List<Tuple> data = NlpEntityTestConstants.getTest8Tuple();
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.MONEY);
List<Tuple> expectedResults = NlpEntityTestConstants.getTest8ResultTuples();
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 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.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.getTest2ResultTuples();
boolean contains = TestUtils.equals(expectedResults, returnedResults);
Assert.assertTrue(contains);
}
Aggregations