Search in sources :

Example 41 with TextField

use of edu.uci.ics.texera.api.field.TextField in project textdb by TextDB.

the class NlpEntityTestConstants method getOneSentenceTestTuple.

public static List<Tuple> getOneSentenceTestTuple() {
    IField[] fields1 = { new TextField("Microsoft is an organization.") };
    IField[] fields2 = { new TextField("Microsoft, Google and Facebook are organizations.") };
    IField[] fields3 = { new TextField("Microsoft, Google and Facebook are organizations and Donald Trump and Barack Obama are persons.") };
    IField[] fields4 = { new TextField("Feeling the warm sun rays beaming steadily down, the girl decided there was no need to wear a coat.") };
    IField[] fields5 = { new TextField("This backpack costs me 300 dollars.") };
    IField[] fields6 = { new TextField("What't the brand, Samsung or Apple?") };
    Tuple tuple1 = new Tuple(SCHEMA_ONE_SENTENCE, fields1);
    Tuple tuple2 = new Tuple(SCHEMA_ONE_SENTENCE, fields2);
    Tuple tuple3 = new Tuple(SCHEMA_ONE_SENTENCE, fields3);
    Tuple tuple4 = new Tuple(SCHEMA_ONE_SENTENCE, fields4);
    Tuple tuple5 = new Tuple(SCHEMA_ONE_SENTENCE, fields5);
    Tuple tuple6 = new Tuple(SCHEMA_ONE_SENTENCE, fields6);
    return Arrays.asList(tuple1, tuple2, tuple3, tuple4, tuple5, tuple6);
}
Also used : TextField(edu.uci.ics.texera.api.field.TextField) IField(edu.uci.ics.texera.api.field.IField)

Example 42 with TextField

use of edu.uci.ics.texera.api.field.TextField 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);
}
Also used : ArrayList(java.util.ArrayList) TextField(edu.uci.ics.texera.api.field.TextField) ListField(edu.uci.ics.texera.api.field.ListField) IField(edu.uci.ics.texera.api.field.IField) Span(edu.uci.ics.texera.api.span.Span)

Example 43 with TextField

use of edu.uci.ics.texera.api.field.TextField in project textdb by TextDB.

the class NlpEntityTestConstants method getTest2ResultTuples.

public static List<Tuple> getTest2ResultTuples() {
    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.") };
    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);
}
Also used : ArrayList(java.util.ArrayList) TextField(edu.uci.ics.texera.api.field.TextField) ListField(edu.uci.ics.texera.api.field.ListField) IField(edu.uci.ics.texera.api.field.IField) Span(edu.uci.ics.texera.api.span.Span)

Example 44 with TextField

use of edu.uci.ics.texera.api.field.TextField in project textdb by TextDB.

the class ProjectionOperatorTest method testProjection1.

@Test
public void testProjection1() throws Exception {
    List<String> projectionFields = Arrays.asList(TestConstants.DESCRIPTION);
    Schema projectionSchema = new Schema(TestConstants.DESCRIPTION_ATTR);
    IField[] fields1 = { new TextField("Tall Angry") };
    IField[] fields2 = { new TextField("Short Brown") };
    IField[] fields3 = { new TextField("White Angry") };
    IField[] fields4 = { new TextField("Lin Clooney is Short and lin clooney is Angry") };
    IField[] fields5 = { new TextField("Tall Fair") };
    IField[] fields6 = { new TextField("Short angry") };
    Tuple tuple1 = new Tuple(projectionSchema, fields1);
    Tuple tuple2 = new Tuple(projectionSchema, fields2);
    Tuple tuple3 = new Tuple(projectionSchema, fields3);
    Tuple tuple4 = new Tuple(projectionSchema, fields4);
    Tuple tuple5 = new Tuple(projectionSchema, fields5);
    Tuple tuple6 = new Tuple(projectionSchema, fields6);
    List<Tuple> expectedResults = Arrays.asList(tuple1, tuple2, tuple3, tuple4, tuple5, tuple6);
    List<Tuple> returnedResults = getProjectionResults(new ScanBasedSourceOperator(new ScanSourcePredicate(PEOPLE_TABLE)), projectionFields);
    Assert.assertTrue(TestUtils.equals(expectedResults, returnedResults));
}
Also used : Schema(edu.uci.ics.texera.api.schema.Schema) TextField(edu.uci.ics.texera.api.field.TextField) IField(edu.uci.ics.texera.api.field.IField) Tuple(edu.uci.ics.texera.api.tuple.Tuple) ScanBasedSourceOperator(edu.uci.ics.texera.dataflow.source.scan.ScanBasedSourceOperator) ScanSourcePredicate(edu.uci.ics.texera.dataflow.source.scan.ScanSourcePredicate) Test(org.junit.Test)

Example 45 with TextField

use of edu.uci.ics.texera.api.field.TextField in project textdb by TextDB.

the class TestConstants method getSamplePeopleTuples.

public static List<Tuple> getSamplePeopleTuples() {
    try {
        IField[] fields0 = { new StringField("bruce"), new StringField("john Lee"), new IntegerField(46), new DoubleField(5.50), new DateField(new SimpleDateFormat("MM-dd-yyyy").parse("01-14-1970")), new TextField("Tall Angry") };
        IField[] fields1 = { new StringField("tom hanks"), new StringField("cruise"), new IntegerField(45), new DoubleField(5.95), new DateField(new SimpleDateFormat("MM-dd-yyyy").parse("01-13-1971")), new TextField("Short Brown") };
        IField[] fields2 = { new StringField("brad lie angelina"), new StringField("pitt"), new IntegerField(44), new DoubleField(6.10), new DateField(new SimpleDateFormat("MM-dd-yyyy").parse("01-12-1972")), new TextField("White Angry") };
        IField[] fields3 = { new StringField("george lin lin"), new StringField("lin clooney"), new IntegerField(43), new DoubleField(6.06), new DateField(new SimpleDateFormat("MM-dd-yyyy").parse("01-13-1973")), new TextField("Lin Clooney is Short and lin clooney is Angry") };
        IField[] fields4 = { new StringField("christian john wayne"), new StringField("rock bale"), new IntegerField(42), new DoubleField(5.99), new DateField(new SimpleDateFormat("MM-dd-yyyy").parse("01-13-1974")), new TextField("Tall Fair") };
        IField[] fields5 = { new StringField("Mary brown"), new StringField("Lake Forest"), new IntegerField(42), new DoubleField(5.99), new DateField(new SimpleDateFormat("MM-dd-yyyy").parse("01-13-1974")), new TextField("Short angry") };
        Tuple tuple0 = new Tuple(SCHEMA_PEOPLE, fields0);
        Tuple tuple1 = new Tuple(SCHEMA_PEOPLE, fields1);
        Tuple tuple2 = new Tuple(SCHEMA_PEOPLE, fields2);
        Tuple tuple3 = new Tuple(SCHEMA_PEOPLE, fields3);
        Tuple tuple4 = new Tuple(SCHEMA_PEOPLE, fields4);
        Tuple tuple5 = new Tuple(SCHEMA_PEOPLE, fields5);
        return Arrays.asList(tuple0, tuple1, tuple2, tuple3, tuple4, tuple5);
    } catch (ParseException e) {
        // exception should not happen because we know the data is correct
        e.printStackTrace();
        return Arrays.asList();
    }
}
Also used : StringField(edu.uci.ics.texera.api.field.StringField) TextField(edu.uci.ics.texera.api.field.TextField) IntegerField(edu.uci.ics.texera.api.field.IntegerField) DateField(edu.uci.ics.texera.api.field.DateField) ParseException(java.text.ParseException) IField(edu.uci.ics.texera.api.field.IField) SimpleDateFormat(java.text.SimpleDateFormat) DoubleField(edu.uci.ics.texera.api.field.DoubleField)

Aggregations

TextField (edu.uci.ics.texera.api.field.TextField)115 IField (edu.uci.ics.texera.api.field.IField)99 Tuple (edu.uci.ics.texera.api.tuple.Tuple)89 ArrayList (java.util.ArrayList)84 IntegerField (edu.uci.ics.texera.api.field.IntegerField)78 StringField (edu.uci.ics.texera.api.field.StringField)78 Span (edu.uci.ics.texera.api.span.Span)78 Schema (edu.uci.ics.texera.api.schema.Schema)77 Test (org.junit.Test)76 DoubleField (edu.uci.ics.texera.api.field.DoubleField)63 DateField (edu.uci.ics.texera.api.field.DateField)58 Attribute (edu.uci.ics.texera.api.schema.Attribute)56 SimpleDateFormat (java.text.SimpleDateFormat)56 Dictionary (edu.uci.ics.texera.dataflow.dictionarymatcher.Dictionary)29 ListField (edu.uci.ics.texera.api.field.ListField)11 JoinDistancePredicate (edu.uci.ics.texera.dataflow.join.JoinDistancePredicate)9 KeywordMatcherSourceOperator (edu.uci.ics.texera.dataflow.keywordmatcher.KeywordMatcherSourceOperator)9 JsonNode (com.fasterxml.jackson.databind.JsonNode)5 IOperator (edu.uci.ics.texera.api.dataflow.IOperator)5 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)4