use of edu.uci.ics.texera.api.span.Span in project textdb by TextDB.
the class RegexMatcherTest method testGetNextTupleCorpIP.
@Test
public void testGetNextTupleCorpIP() throws Exception {
String query = "^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$";
List<Tuple> exactResults = RegexMatcherTestHelper.getQueryResults(CORP_TABLE, query, Arrays.asList(RegexTestConstantsCorp.IP_ADDRESS));
List<Tuple> expectedResults = new ArrayList<Tuple>();
// expected to match "66.220.144.0"
List<Tuple> data = RegexTestConstantsCorp.getSampleCorpTuples();
Schema spanSchema = new Schema.Builder().add(RegexTestConstantsCorp.SCHEMA_CORP).add(RESULTS, AttributeType.LIST).build();
List<Span> spans = new ArrayList<Span>();
spans.add(new Span(RegexTestConstantsCorp.IP_ADDRESS, 0, 12, query, "66.220.144.0"));
IField spanField = new ListField<Span>(new ArrayList<Span>(spans));
List<IField> fields = new ArrayList<IField>(data.get(0).getFields());
fields.add(spanField);
expectedResults.add(new Tuple(spanSchema, fields.toArray(new IField[fields.size()])));
// expected to match "180.149.134.141"
spans.clear();
spans.add(new Span(RegexTestConstantsCorp.IP_ADDRESS, 0, 15, query, "180.149.134.141"));
spanField = new ListField<Span>(new ArrayList<Span>(spans));
fields = new ArrayList<IField>(data.get(1).getFields());
fields.add(spanField);
expectedResults.add(new Tuple(spanSchema, fields.toArray(new IField[fields.size()])));
// expected to match "131.107.0.89"
spans.clear();
spans.add(new Span(RegexTestConstantsCorp.IP_ADDRESS, 0, 12, query, "131.107.0.89"));
spanField = new ListField<Span>(new ArrayList<Span>(spans));
fields = new ArrayList<IField>(data.get(2).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.span.Span in project textdb by TextDB.
the class RegexMatcherTest method testGetNextTupleStaffEmail.
@Test
public void testGetNextTupleStaffEmail() throws Exception {
String query = "^([a-z0-9_\\.-]+)@([\\da-z\\.-]+)\\.([a-z\\.]{2,6})$";
List<Tuple> exactResults = RegexMatcherTestHelper.getQueryResults(STAFF_TABLE, query, Arrays.asList(RegexTestConstantStaff.EMAIL));
List<Tuple> expectedResults = new ArrayList<Tuple>();
// expected to match "k.bocanegra@uci.edu"
List<Tuple> data = RegexTestConstantStaff.getSampleStaffTuples();
Schema spanSchema = new Schema.Builder().add(RegexTestConstantStaff.SCHEMA_STAFF).add(RESULTS, AttributeType.LIST).build();
List<Span> spans = new ArrayList<Span>();
spans.add(new Span(RegexTestConstantStaff.EMAIL, 0, 19, query, "m.bocanegra@164.com"));
IField spanField = new ListField<Span>(new ArrayList<Span>(spans));
List<IField> fields = new ArrayList<IField>(data.get(0).getFields());
fields.add(spanField);
expectedResults.add(new Tuple(spanSchema, fields.toArray(new IField[fields.size()])));
// expected to match "hwangl@ics.uci.edu"
spans.clear();
spans.add(new Span(RegexTestConstantStaff.EMAIL, 0, 18, query, "hwangk@ske.akb.edu"));
spanField = new ListField<Span>(new ArrayList<Span>(spans));
fields = new ArrayList<IField>(data.get(1).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.span.Span in project textdb by TextDB.
the class NlpEntityTestConstants method getTest6ResultTuples.
public static List<Tuple> getTest6ResultTuples() {
List<Span> spanList = new ArrayList<Span>();
Span span1 = new Span("sentence_one", 0, 9, NlpEntityType.ORGANIZATION.toString(), "Microsoft");
Span span2 = new Span("sentence_one", 11, 17, NlpEntityType.ORGANIZATION.toString(), "Google");
Span span3 = new Span("sentence_one", 22, 30, NlpEntityType.ORGANIZATION.toString(), "Facebook");
spanList.add(span1);
spanList.add(span2);
spanList.add(span3);
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.span.Span in project textdb by TextDB.
the class NlpEntityTestConstants method getTest9ResultTuples.
public static List<Tuple> getTest9ResultTuples() {
List<Span> spanList = new ArrayList<Span>();
Span span1 = new Span("sentence_one", 25, 29, NlpEntityType.TIME.toString(), "8 am");
Span span2 = new Span("sentence_two", 0, 12, NlpEntityType.DATE.toString(), "Aug 16 , 2016");
spanList.add(span1);
spanList.add(span2);
IField[] fields1 = { new TextField("I made an appointment at 8 am."), new TextField("Aug 16, 2016 is a really important date.") };
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.span.Span in project textdb by TextDB.
the class NlpEntityTestConstants method getTest8ResultTuples.
public static List<Tuple> getTest8ResultTuples() {
List<Span> spanList = new ArrayList<Span>();
Span span1 = new Span("sentence_one", 23, 34, NlpEntityType.MONEY.toString(), "300 dollars");
spanList.add(span1);
IField[] fields1 = { new TextField("This backpack costs me 300 dollars.") };
Tuple tuple1 = new Tuple(SCHEMA_ONE_SENTENCE, fields1);
Tuple returnTuple = new Tuple.Builder(tuple1).add(REULST_ATTRIBUTE, new ListField<Span>(spanList)).build();
return Arrays.asList(returnTuple);
}
Aggregations