use of edu.uci.ics.texera.api.field.ListField in project textdb by TextDB.
the class RegexMatcherTest method testRegexText3.
@Test
public void testRegexText3() throws Exception {
String query = "([a-zA-Z])+o[a-z]a[a-z]o";
List<Tuple> exactResults = RegexMatcherTestHelper.getQueryResults(TEXT_TABLE, query, Arrays.asList(RegexTestConstantsText.CONTENT));
List<Tuple> expectedResults = new ArrayList<Tuple>();
// expected to match "Tomato" & "tomato"
List<Tuple> data = RegexTestConstantsText.getSampleTextTuples();
Schema spanSchema = new Schema.Builder().add(RegexTestConstantsText.SCHEMA_TEXT).add(RESULTS, AttributeType.LIST).build();
List<Span> spans = new ArrayList<Span>();
spans.add(new Span(RegexTestConstantsText.CONTENT, 0, 6, query, "Tomato"));
spans.add(new Span(RegexTestConstantsText.CONTENT, 94, 100, query, "tomato"));
IField spanField = new ListField<Span>(new ArrayList<Span>(spans));
List<IField> fields = new ArrayList<IField>(data.get(7).getFields());
fields.add(spanField);
expectedResults.add(new Tuple(spanSchema, fields.toArray(new IField[fields.size()])));
// expected to match "Potato"
spans.clear();
spans.add(new Span(RegexTestConstantsText.CONTENT, 0, 6, query, "Potato"));
spanField = new ListField<Span>(new ArrayList<Span>(spans));
fields = new ArrayList<IField>(data.get(8).getFields());
fields.add(spanField);
expectedResults.add(new Tuple(spanSchema, fields.toArray(new IField[fields.size()])));
// expected to match "avocado"
spans.clear();
spans.add(new Span(RegexTestConstantsText.CONTENT, 53, 60, query, "avocado"));
spanField = new ListField<Span>(new ArrayList<Span>(spans));
fields = new ArrayList<IField>(data.get(9).getFields());
fields.add(spanField);
expectedResults.add(new Tuple(spanSchema, fields.toArray(new IField[fields.size()])));
Assert.assertTrue(TestUtils.equals(expectedResults, exactResults));
}
use of edu.uci.ics.texera.api.field.ListField in project textdb by TextDB.
the class NlpEntityTestConstants method getTest5ResultTuples.
public static List<Tuple> getTest5ResultTuples() {
List<Span> spanList = new ArrayList<Span>();
Span span1 = new Span("sentence_two", 0, 12, NlpEntityType.PERSON.toString(), "Donald Trump");
Span span2 = new Span("sentence_two", 17, 29, NlpEntityType.PERSON.toString(), "Barack Obama");
spanList.add(span1);
spanList.add(span2);
IField[] fields1 = { new TextField("Microsoft, Google and Facebook are organizations."), new TextField("Donald Trump and Barack Obama are persons") };
Tuple tuple1 = new Tuple(SCHEMA_TWO_SENTENCE, fields1);
Tuple returnTuple = new Tuple.Builder(tuple1).add(REULST_ATTRIBUTE, new ListField<Span>(spanList)).build();
return Arrays.asList(returnTuple);
}
use of edu.uci.ics.texera.api.field.ListField in project textdb by TextDB.
the class NlpSplitTestConstants method getOneToOneResultTuple.
public static List<Tuple> getOneToOneResultTuple() throws ParseException {
// Build the expected result Tuple
List<Span> spanList = new ArrayList<Span>();
Span span1 = new Span(TEXT, 0, sentence1.length(), PropertyNameConstants.NLP_SPLIT_KEY, sentence1);
spanList.add(span1);
Span span2 = new Span(TEXT, sentence1.length() + 1, sentence1.length() + sentence2.length() + 1, PropertyNameConstants.NLP_SPLIT_KEY, sentence2);
spanList.add(span2);
Tuple tuple1 = getOneToOneTestTuple().get(0);
Tuple returnTuple = new Tuple.Builder(tuple1).add(SchemaConstants.SPAN_LIST_ATTRIBUTE, new ListField<Span>(spanList)).build();
return Arrays.asList(returnTuple);
}
use of edu.uci.ics.texera.api.field.ListField in project textdb by TextDB.
the class LabeledRegexMatcherTest method testQueryWithoutQualifiersLabeledRegex1.
@Test
public void testQueryWithoutQualifiersLabeledRegex1() throws Exception {
String query = "<lab1> <lab2>";
List<Tuple> exactResults = RegexMatcherTestHelper.getQueryResults(PEOPLE_TABLE, query, "short", Arrays.asList(TestConstants.DESCRIPTION), "lab1", false, Integer.MAX_VALUE, 0, "angry", "lab2");
List<Tuple> expectedResults = new ArrayList<>();
// expected to match "Short angry"
List<Tuple> data = TestConstants.getSamplePeopleTuples();
Schema spanSchema = new Schema.Builder().add(TestConstants.SCHEMA_PEOPLE).add(RESULTS, AttributeType.LIST).build();
List<Span> spans = new ArrayList<>();
spans.add(new Span(TestConstants.DESCRIPTION, 0, 11, query, "Short angry"));
IField spanField = new ListField<>(new ArrayList<>(spans));
List<IField> fields = new ArrayList<>(data.get(5).getFields());
fields.add(spanField);
expectedResults.add(new Tuple(spanSchema, fields.toArray(new IField[fields.size()])));
List<String> attributeNames = new ArrayList<>();
attributeNames.add(RESULTS);
Assert.assertTrue(TestUtils.attributeEquals(expectedResults, exactResults, attributeNames));
}
use of edu.uci.ics.texera.api.field.ListField in project textdb by TextDB.
the class LabeledRegexMatcherTest method testQueryWithoutQualifiersLabeledRegex3.
@Test
public void testQueryWithoutQualifiersLabeledRegex3() throws Exception {
String query = "Lin <lab2> is <lab1> and lin <lab2> is Angry";
List<Tuple> exactResults = RegexMatcherTestHelper.getQueryResults(PEOPLE_TABLE, query, "short", Arrays.asList(TestConstants.DESCRIPTION), "lab1", false, Integer.MAX_VALUE, 0, "Clooney", "lab2");
List<Tuple> expectedResults = new ArrayList<>();
// expected to match "Short angry"
List<Tuple> data = TestConstants.getSamplePeopleTuples();
Schema spanSchema = new Schema.Builder().add(TestConstants.SCHEMA_PEOPLE).add(RESULTS, AttributeType.LIST).build();
List<Span> spans = new ArrayList<>();
spans.add(new Span(TestConstants.DESCRIPTION, 0, 45, query, "Lin Clooney is Short and lin clooney is Angry"));
IField spanField = new ListField<>(new ArrayList<>(spans));
List<IField> fields = new ArrayList<>(data.get(3).getFields());
fields.add(spanField);
expectedResults.add(new Tuple(spanSchema, fields.toArray(new IField[fields.size()])));
List<String> attributeNames = new ArrayList<>();
attributeNames.add(RESULTS);
Assert.assertTrue(TestUtils.attributeEquals(expectedResults, exactResults, attributeNames));
}
Aggregations