Search in sources :

Example 21 with Schema

use of edu.uci.ics.textdb.api.schema.Schema in project textdb by TextDB.

the class NlpEntityTestConstants method getTest1ResultTuples.

public static List<Tuple> getTest1ResultTuples() {
    List<Tuple> resultList = new ArrayList<>();
    List<Span> spanList = new ArrayList<Span>();
    Span span1 = new Span("sentence_one", 0, 9, NlpEntityType.ORGANIZATION.toString(), "Microsoft");
    spanList.add(span1);
    IField[] fields1 = { new TextField("Microsoft is an organization.") };
    Tuple tuple1 = new Tuple(SCHEMA_ONE_SENTENCE, fields1);
    Schema returnSchema = Utils.addAttributeToSchema(tuple1.getSchema(), new Attribute(RESULTS, AttributeType.LIST));
    Tuple returnTuple = DataflowUtils.getSpanTuple(tuple1.getFields(), spanList, returnSchema);
    resultList.add(returnTuple);
    return resultList;
}
Also used : Attribute(edu.uci.ics.textdb.api.schema.Attribute) Schema(edu.uci.ics.textdb.api.schema.Schema) ArrayList(java.util.ArrayList) TextField(edu.uci.ics.textdb.api.field.TextField) IField(edu.uci.ics.textdb.api.field.IField) Span(edu.uci.ics.textdb.api.span.Span)

Example 22 with Schema

use of edu.uci.ics.textdb.api.schema.Schema in project textdb by TextDB.

the class NlpEntityTestConstants method getTest7ResultTuples.

public static List<Tuple> getTest7ResultTuples() {
    List<Tuple> resultList = new ArrayList<>();
    List<Span> spanList = new ArrayList<Span>();
    Span span1 = new Span("sentence_one", 12, 16, NlpEntityType.ADJECTIVE.toString(), "warm");
    spanList.add(span1);
    IField[] fields1 = { new TextField("Feeling the warm sun rays beaming steadily down, the girl decided there was no need to wear a coat.") };
    Tuple tuple1 = new Tuple(SCHEMA_ONE_SENTENCE, fields1);
    Schema returnSchema = Utils.addAttributeToSchema(tuple1.getSchema(), new Attribute(RESULTS, AttributeType.LIST));
    Tuple returnTuple = DataflowUtils.getSpanTuple(tuple1.getFields(), spanList, returnSchema);
    resultList.add(returnTuple);
    return resultList;
}
Also used : Attribute(edu.uci.ics.textdb.api.schema.Attribute) Schema(edu.uci.ics.textdb.api.schema.Schema) ArrayList(java.util.ArrayList) TextField(edu.uci.ics.textdb.api.field.TextField) IField(edu.uci.ics.textdb.api.field.IField) Span(edu.uci.ics.textdb.api.span.Span)

Example 23 with Schema

use of edu.uci.ics.textdb.api.schema.Schema in project textdb by TextDB.

the class NlpEntityTestConstants method getTest2ResultTuples.

public static List<Tuple> getTest2ResultTuples() {
    List<Tuple> resultList = new ArrayList<>();
    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);
    Schema returnSchema = Utils.addAttributeToSchema(tuple1.getSchema(), new Attribute(RESULTS, AttributeType.LIST));
    Tuple returnTuple = DataflowUtils.getSpanTuple(tuple1.getFields(), spanList, returnSchema);
    resultList.add(returnTuple);
    return resultList;
}
Also used : Attribute(edu.uci.ics.textdb.api.schema.Attribute) Schema(edu.uci.ics.textdb.api.schema.Schema) ArrayList(java.util.ArrayList) TextField(edu.uci.ics.textdb.api.field.TextField) IField(edu.uci.ics.textdb.api.field.IField) Span(edu.uci.ics.textdb.api.span.Span)

Example 24 with Schema

use of edu.uci.ics.textdb.api.schema.Schema in project textdb by TextDB.

the class NlpEntityTestConstants method getTest10ResultTuples.

public static List<Tuple> getTest10ResultTuples() {
    List<Tuple> resultList = new ArrayList<>();
    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");
    Span span4 = new Span("sentence_one", 53, 65, NlpEntityType.PERSON.toString(), "Donald Trump");
    Span span5 = new Span("sentence_one", 70, 82, NlpEntityType.PERSON.toString(), "Barack Obama");
    Span span6 = new Span("sentence_one", 23, 34, NlpEntityType.MONEY.toString(), "300 dollars");
    Span span7 = new Span("sentence_one", 18, 25, NlpEntityType.ORGANIZATION.toString(), "Samsung");
    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[] 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 tuple5 = new Tuple(SCHEMA_ONE_SENTENCE, fields5);
    Tuple tuple6 = new Tuple(SCHEMA_ONE_SENTENCE, fields6);
    Schema returnSchema = Utils.addAttributeToSchema(tuple1.getSchema(), new Attribute(RESULTS, AttributeType.LIST));
    spanList.add(span1);
    resultList.add(DataflowUtils.getSpanTuple(tuple1.getFields(), spanList, returnSchema));
    spanList.add(span2);
    spanList.add(span3);
    resultList.add(DataflowUtils.getSpanTuple(tuple2.getFields(), spanList, returnSchema));
    spanList.add(span4);
    spanList.add(span5);
    resultList.add(DataflowUtils.getSpanTuple(tuple3.getFields(), spanList, returnSchema));
    spanList.clear();
    spanList.add(span6);
    resultList.add(DataflowUtils.getSpanTuple(tuple5.getFields(), spanList, returnSchema));
    spanList.clear();
    spanList.add(span7);
    resultList.add(DataflowUtils.getSpanTuple(tuple6.getFields(), spanList, returnSchema));
    return resultList;
}
Also used : Attribute(edu.uci.ics.textdb.api.schema.Attribute) Schema(edu.uci.ics.textdb.api.schema.Schema) ArrayList(java.util.ArrayList) TextField(edu.uci.ics.textdb.api.field.TextField) IField(edu.uci.ics.textdb.api.field.IField) Span(edu.uci.ics.textdb.api.span.Span)

Example 25 with Schema

use of edu.uci.ics.textdb.api.schema.Schema in project textdb by TextDB.

the class NlpEntityTestConstants method getTest5ResultTuples.

public static List<Tuple> getTest5ResultTuples() {
    List<Tuple> resultList = new ArrayList<>();
    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);
    Schema returnSchema = Utils.addAttributeToSchema(tuple1.getSchema(), new Attribute(RESULTS, AttributeType.LIST));
    Tuple returnTuple = DataflowUtils.getSpanTuple(tuple1.getFields(), spanList, returnSchema);
    resultList.add(returnTuple);
    return resultList;
}
Also used : Attribute(edu.uci.ics.textdb.api.schema.Attribute) Schema(edu.uci.ics.textdb.api.schema.Schema) ArrayList(java.util.ArrayList) TextField(edu.uci.ics.textdb.api.field.TextField) IField(edu.uci.ics.textdb.api.field.IField) Span(edu.uci.ics.textdb.api.span.Span)

Aggregations

Schema (edu.uci.ics.textdb.api.schema.Schema)126 ArrayList (java.util.ArrayList)98 Tuple (edu.uci.ics.textdb.api.tuple.Tuple)95 IField (edu.uci.ics.textdb.api.field.IField)94 Test (org.junit.Test)94 Attribute (edu.uci.ics.textdb.api.schema.Attribute)93 Span (edu.uci.ics.textdb.api.span.Span)86 TextField (edu.uci.ics.textdb.api.field.TextField)83 StringField (edu.uci.ics.textdb.api.field.StringField)65 IntegerField (edu.uci.ics.textdb.api.field.IntegerField)63 DoubleField (edu.uci.ics.textdb.api.field.DoubleField)52 DateField (edu.uci.ics.textdb.api.field.DateField)49 SimpleDateFormat (java.text.SimpleDateFormat)48 Dictionary (edu.uci.ics.textdb.exp.dictionarymatcher.Dictionary)24 ListField (edu.uci.ics.textdb.api.field.ListField)14 DataFlowException (edu.uci.ics.textdb.api.exception.DataFlowException)9 AttributeType (edu.uci.ics.textdb.api.schema.AttributeType)9 JoinDistancePredicate (edu.uci.ics.textdb.exp.join.JoinDistancePredicate)9 KeywordMatcherSourceOperator (edu.uci.ics.textdb.exp.keywordmatcher.KeywordMatcherSourceOperator)9 IDField (edu.uci.ics.textdb.api.field.IDField)8