Search in sources :

Example 61 with StringField

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

the class KeywordConjunctionTest method testSingleWordQueryInTextField.

/**
 * Verifies GetNextTuple of Keyword Matcher and single word queries in Text
 * Field
 *
 * @throws Exception
 */
@Test
public void testSingleWordQueryInTextField() throws Exception {
    // Prepare the query
    String query = "TaLL";
    ArrayList<String> attributeNames = new ArrayList<>();
    attributeNames.add(TestConstants.FIRST_NAME);
    attributeNames.add(TestConstants.LAST_NAME);
    attributeNames.add(TestConstants.DESCRIPTION);
    // Prepare the expected result list
    List<Span> list = new ArrayList<>();
    Span span = new Span("description", 0, 4, "tall", "Tall", 0);
    list.add(span);
    Attribute[] schemaAttributes = new Attribute[TestConstants.ATTRIBUTES_PEOPLE.length + 1];
    for (int count = 0; count < schemaAttributes.length - 1; count++) {
        schemaAttributes[count] = TestConstants.ATTRIBUTES_PEOPLE[count];
    }
    schemaAttributes[schemaAttributes.length - 1] = new Attribute(RESULTS, AttributeType.LIST);
    IField[] fields1 = { 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"), new ListField<>(list) };
    IField[] fields2 = { 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"), new ListField<>(list) };
    Tuple tuple1 = new Tuple(new Schema(schemaAttributes), fields1);
    Tuple tuple2 = new Tuple(new Schema(schemaAttributes), fields2);
    List<Tuple> expectedResultList = new ArrayList<>();
    expectedResultList.add(tuple1);
    expectedResultList.add(tuple2);
    // Perform the query
    List<Tuple> resultList = KeywordTestHelper.getQueryResults(PEOPLE_TABLE, query, attributeNames, conjunction);
    // check the results
    boolean contains = TestUtils.equals(expectedResultList, resultList);
    Assert.assertTrue(contains);
}
Also used : Attribute(edu.uci.ics.texera.api.schema.Attribute) Schema(edu.uci.ics.texera.api.schema.Schema) ArrayList(java.util.ArrayList) IntegerField(edu.uci.ics.texera.api.field.IntegerField) IField(edu.uci.ics.texera.api.field.IField) Span(edu.uci.ics.texera.api.span.Span) StringField(edu.uci.ics.texera.api.field.StringField) TextField(edu.uci.ics.texera.api.field.TextField) DateField(edu.uci.ics.texera.api.field.DateField) SimpleDateFormat(java.text.SimpleDateFormat) DoubleField(edu.uci.ics.texera.api.field.DoubleField) Tuple(edu.uci.ics.texera.api.tuple.Tuple) Test(org.junit.Test)

Example 62 with StringField

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

the class KeywordConjunctionTest method testWordInMultipleFieldsQuery.

/**
 * Verifies: data source has multiple attributes, and an entity can appear
 * in all the fields and multiple times.
 *
 * @throws Exception
 */
@Test
public void testWordInMultipleFieldsQuery() throws Exception {
    // Prepare the query
    String query = "lin clooney";
    ArrayList<String> attributeNames = new ArrayList<>();
    attributeNames.add(TestConstants.FIRST_NAME);
    attributeNames.add(TestConstants.LAST_NAME);
    attributeNames.add(TestConstants.DESCRIPTION);
    // Prepare the expected result list
    List<Span> list = new ArrayList<>();
    Span span1 = new Span("lastName", 0, 11, "lin clooney", "lin clooney");
    Span span2 = new Span("description", 0, 3, "lin", "Lin", 0);
    Span span3 = new Span("description", 25, 28, "lin", "lin", 5);
    Span span4 = new Span("description", 4, 11, "clooney", "Clooney", 1);
    Span span5 = new Span("description", 29, 36, "clooney", "clooney", 6);
    list.add(span1);
    list.add(span2);
    list.add(span3);
    list.add(span4);
    list.add(span5);
    Attribute[] schemaAttributes = new Attribute[TestConstants.ATTRIBUTES_PEOPLE.length + 1];
    for (int count = 0; count < schemaAttributes.length - 1; count++) {
        schemaAttributes[count] = TestConstants.ATTRIBUTES_PEOPLE[count];
    }
    schemaAttributes[schemaAttributes.length - 1] = new Attribute(RESULTS, AttributeType.LIST);
    IField[] fields1 = { 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"), new ListField<>(list) };
    Tuple tuple1 = new Tuple(new Schema(schemaAttributes), fields1);
    List<Tuple> expectedResultList = new ArrayList<>();
    expectedResultList.add(tuple1);
    // Perform the query
    List<Tuple> resultList = KeywordTestHelper.getQueryResults(PEOPLE_TABLE, query, attributeNames, conjunction);
    // check the results
    boolean contains = TestUtils.equals(expectedResultList, resultList);
    Assert.assertTrue(contains);
}
Also used : Attribute(edu.uci.ics.texera.api.schema.Attribute) Schema(edu.uci.ics.texera.api.schema.Schema) ArrayList(java.util.ArrayList) IntegerField(edu.uci.ics.texera.api.field.IntegerField) IField(edu.uci.ics.texera.api.field.IField) Span(edu.uci.ics.texera.api.span.Span) StringField(edu.uci.ics.texera.api.field.StringField) TextField(edu.uci.ics.texera.api.field.TextField) DateField(edu.uci.ics.texera.api.field.DateField) SimpleDateFormat(java.text.SimpleDateFormat) DoubleField(edu.uci.ics.texera.api.field.DoubleField) Tuple(edu.uci.ics.texera.api.tuple.Tuple) Test(org.junit.Test)

Example 63 with StringField

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

the class keywordTestConstants method getSampleMedlineRecord.

public static List<Tuple> getSampleMedlineRecord() {
    IField[] fields1 = { new IntegerField(14347980), new TextField(""), new TextField("CHRONIC MENINGOCOCCEMIA; EPIDEMIOLOGY, DIAGNOSIS AND TREATMENT."), new TextField("D S BLOOM"), new StringField("103 Aug, 1965"), new TextField("California medicine"), new TextField("DRUG THERAPY, MENINGOCOCCAL INFECTIONS, PENICILLIN G, SULFONAMIDES"), new TextField("Drug Therapy, Meningococcal Infections, Penicillin G, Sulfonamides"), new TextField("This report describes four cases of chronic meningococcemia with the characteristic manifestations of recurrent episodes of " + "fever, chills, night sweats, headache and anorexia, associated with skin rash and arthralgias. The diagnosis was established in all instances by blood culture. Administration " + "of sulfonamides in three cases and penicillin in the fourth resulted in prompt recovery. The recent finding of a strain of sulfonamide-resistant meningococci, however, indicates " + "that antibiotic-sensitivity tests should be carried out in all cases of meningococcal disease. While waiting for the results of such tests to be reported, the clinician should " + "initiate treatment with large doses of a sulfonamide and penicillin in combination."), new DoubleField(0.664347980) };
    IField[] fields2 = { new IntegerField(17832788), new TextField(""), new TextField("Cosmic X-ray Sources."), new TextField("S Bowyer, E T Byram, T A Chubb, H Friedman"), new StringField("147-3656 Jan 22, 1965"), new TextField("Science (New York, N.Y.)"), new TextField(""), new TextField(""), new TextField("Eight new sources of cosmic x-rays were detected by two Aerobee surveys in 1964. One source, from Sagittarius, is close to the galactic center, and the other, " + "from Ophiuchus, may coincide with Kepler's 1604 supernova. All the x-ray sources are fairly close to the galactic plane."), new DoubleField(0.667832788) };
    IField[] fields3 = { new IntegerField(4566015), new TextField(""), new TextField("Significance of milk pH in newborn infants."), new TextField("V C Harrison, G Peat"), new StringField("4-5839 Dec 2, 1972"), new TextField("British medical journal"), new TextField(""), new TextField("Infant Nutritional Physiological Phenomena, Infant, Newborn, Milk"), new TextField("Bottle-fed infants do not gain weight as rapidly as breast-fed babies during the first week of life. This " + "weight lag can be corrected by the addition of a small amount of alkali (sodium bicarbonate or trometamol) to " + "the feeds. The alkali corrects the acidity of cow's milk which now assumes some of the properties of human breast " + "milk. It has a bacteriostatic effect on specific Escherichia coli in vitro, and in infants it produces a stool with" + " a preponderance of lactobacilli over E. coli organisms. When alkali is removed from the milk there is a decrease in" + " the weight of an infant and the stools contain excessive numbers of E. coli bacteria.A pH-corrected milk appears to" + " be more physiological than unaltered cow's milk and may provide some protection against gastroenteritis in early " + "life. Its bacteriostatic effect on specific E. coli may be of practical significance in feed preparations where " + "terminal sterilization and refrigeration are not available. The study was conducted during the week after birth, and " + "no conclusions are derived for older infants. The long-term effects of trometamol are unknown. No recommendation can " + "be given for the addition of sodium bicarbonate to milks containing a higher content of sodium."), new DoubleField(0.667832788) };
    Tuple tuple1 = new Tuple(SCHEMA_MEDLINE, fields1);
    Tuple tuple2 = new Tuple(SCHEMA_MEDLINE, fields2);
    Tuple tuple3 = new Tuple(SCHEMA_MEDLINE, fields3);
    return Arrays.asList(tuple1, tuple2, tuple3);
}
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) IField(edu.uci.ics.texera.api.field.IField) DoubleField(edu.uci.ics.texera.api.field.DoubleField)

Example 64 with StringField

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

the class ProjectionOperatorTest method testProjection2.

@Test
public void testProjection2() throws Exception {
    List<String> projectionFields = Arrays.asList(TestConstants.FIRST_NAME, TestConstants.DESCRIPTION);
    Schema projectionSchema = new Schema(TestConstants.FIRST_NAME_ATTR, TestConstants.DESCRIPTION_ATTR);
    IField[] fields1 = { new StringField("bruce"), new TextField("Tall Angry") };
    IField[] fields2 = { new StringField("tom hanks"), new TextField("Short Brown") };
    IField[] fields3 = { new StringField("brad lie angelina"), new TextField("White Angry") };
    IField[] fields4 = { new StringField("george lin lin"), new TextField("Lin Clooney is Short and lin clooney is Angry") };
    IField[] fields5 = { new StringField("christian john wayne"), new TextField("Tall Fair") };
    IField[] fields6 = { new StringField("Mary brown"), 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) StringField(edu.uci.ics.texera.api.field.StringField) 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 65 with StringField

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

the class RegexTestConstantStaff method getSampleStaffTuples.

public static List<Tuple> getSampleStaffTuples() {
    IField[] fields1 = { new StringField("Melody"), new StringField("Bocanegra"), new StringField("m.bocanegra@164.com"), new StringField("(945) 734-5156") };
    IField[] fields2 = { new StringField("Kanon"), new StringField("Hwang"), new StringField("hwangk@ske.akb.edu"), new StringField("(494) 352-8098") };
    IField[] fields3 = { new StringField("Shirley"), new StringField("Clarkson"), new StringField("clarkson@facebook"), new StringField("(587) 241-7550") };
    IField[] fields4 = { new StringField("Lucy"), new StringField("Kimoto"), new StringField("lki?moto@microsoft.com"), new StringField("(499) 824-3625") };
    Tuple tuple1 = new Tuple(SCHEMA_STAFF, fields1);
    Tuple tuple2 = new Tuple(SCHEMA_STAFF, fields2);
    Tuple tuple3 = new Tuple(SCHEMA_STAFF, fields3);
    Tuple tuple4 = new Tuple(SCHEMA_STAFF, fields4);
    return Arrays.asList(tuple1, tuple2, tuple3, tuple4);
}
Also used : StringField(edu.uci.ics.texera.api.field.StringField) IField(edu.uci.ics.texera.api.field.IField)

Aggregations

StringField (edu.uci.ics.texera.api.field.StringField)103 Tuple (edu.uci.ics.texera.api.tuple.Tuple)94 IField (edu.uci.ics.texera.api.field.IField)87 IntegerField (edu.uci.ics.texera.api.field.IntegerField)87 TextField (edu.uci.ics.texera.api.field.TextField)79 Schema (edu.uci.ics.texera.api.schema.Schema)75 ArrayList (java.util.ArrayList)74 Test (org.junit.Test)70 Span (edu.uci.ics.texera.api.span.Span)64 DoubleField (edu.uci.ics.texera.api.field.DoubleField)63 DateField (edu.uci.ics.texera.api.field.DateField)60 Attribute (edu.uci.ics.texera.api.schema.Attribute)60 SimpleDateFormat (java.text.SimpleDateFormat)58 Dictionary (edu.uci.ics.texera.dataflow.dictionarymatcher.Dictionary)29 JoinDistancePredicate (edu.uci.ics.texera.dataflow.join.JoinDistancePredicate)9 KeywordMatcherSourceOperator (edu.uci.ics.texera.dataflow.keywordmatcher.KeywordMatcherSourceOperator)9 JsonNode (com.fasterxml.jackson.databind.JsonNode)8 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)8 IDField (edu.uci.ics.texera.api.field.IDField)5 IOperator (edu.uci.ics.texera.api.dataflow.IOperator)4