use of edu.uci.ics.texera.api.field.IField in project textdb by TextDB.
the class KeywordPhraseTest method testWordInMultipleFieldsQueryWithStopWords3.
/**
* Verifies: Query with Stop Words match corresponding phrases with Medline
* data
*
* @throws Exception
* with Medline data
*/
@Test
public void testWordInMultipleFieldsQueryWithStopWords3() throws Exception {
// Prepare Query
String query = "skin rash";
ArrayList<String> attributeNames = new ArrayList<>();
attributeNames.add(keywordTestConstants.ABSTRACT);
// Prepare expected result list
List<Span> list = new ArrayList<>();
Span span1 = new Span(keywordTestConstants.ABSTRACT, 192, 201, "skin rash", "skin rash");
list.add(span1);
Attribute[] schemaAttributes = new Attribute[keywordTestConstants.ATTRIBUTES_MEDLINE.length + 1];
for (int count = 0; count < schemaAttributes.length - 1; count++) {
schemaAttributes[count] = keywordTestConstants.ATTRIBUTES_MEDLINE[count];
}
schemaAttributes[schemaAttributes.length - 1] = new Attribute(RESULTS, AttributeType.LIST);
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), new ListField<>(list) };
Tuple tuple1 = new Tuple(new Schema(schemaAttributes), fields1);
List<Tuple> expectedResultList = new ArrayList<>();
expectedResultList.add(tuple1);
List<Tuple> results = KeywordTestHelper.getQueryResults(MEDLINE_TABLE, query, attributeNames, phrase);
// Perform Check
boolean contains = TestUtils.equals(expectedResultList, results);
Assert.assertTrue(contains);
}
use of edu.uci.ics.texera.api.field.IField in project textdb by TextDB.
the class KeywordPhraseTest method testCombinedSpanInMultipleFieldsQuery.
/**
* Verifies: getNextTuple should return Combined Span info for the phrase
*
* @throws Exception
*/
@Test
public void testCombinedSpanInMultipleFieldsQuery() throws Exception {
// Prepare 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 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, 11, "lin clooney", "Lin Clooney");
Span span3 = new Span("description", 25, 36, "lin clooney", "lin clooney");
list.add(span1);
list.add(span2);
list.add(span3);
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 Query
List<Tuple> resultList = KeywordTestHelper.getQueryResults(PEOPLE_TABLE, query, attributeNames, phrase);
// Perform Check
boolean contains = TestUtils.equals(expectedResultList, resultList);
Assert.assertTrue(contains);
}
use of edu.uci.ics.texera.api.field.IField in project textdb by TextDB.
the class KeywordSubstringTest method testSubstringForStringField.
/**
* Verifies List<ITuple> returned by Substring Matcher on query with
* multiple spaces and stop words on a String Field
*
* @throws Exception
*/
@Test
public void testSubstringForStringField() throws Exception {
// Prepare Query
String query = "short and lin";
ArrayList<String> attributeNames = new ArrayList<>();
attributeNames.add(TestConstants.FIRST_NAME);
attributeNames.add(TestConstants.LAST_NAME);
attributeNames.add(TestConstants.DESCRIPTION);
// Prepare expected result list
List<Span> list = new ArrayList<Span>();
Span span1 = new Span("description", 15, 28, "short and lin", "Short and lin");
list.add(span1);
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 Query
List<Tuple> resultList = KeywordTestHelper.getScanSourceResults(PEOPLE_TABLE, query, attributeNames, substring, Integer.MAX_VALUE, 0);
// Perform Check
boolean contains = TestUtils.equals(expectedResultList, resultList);
Assert.assertTrue(contains);
}
use of edu.uci.ics.texera.api.field.IField in project textdb by TextDB.
the class KeywordSubstringTest method testSubstringWithStopwordQuery.
/**
* Verifies: Verifies List<ITuple> returned multiple results by Substring
* Matcher on query with spaces on both left side and right side.
*
* @throws Exception
*/
@Test
public void testSubstringWithStopwordQuery() throws Exception {
// Prepare Query
String query = "is";
ArrayList<String> attributeNames = new ArrayList<>();
attributeNames.add(TestConstants.FIRST_NAME);
attributeNames.add(TestConstants.LAST_NAME);
attributeNames.add(TestConstants.DESCRIPTION);
// Prepare expected result list
List<Span> list = new ArrayList<>();
Span span1 = new Span("description", 12, 14, "is", "is");
Span span2 = new Span("description", 37, 39, "is", "is");
list.add(span1);
list.add(span2);
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 Query
List<Tuple> resultList = KeywordTestHelper.getScanSourceResults(PEOPLE_TABLE, query, attributeNames, substring, Integer.MAX_VALUE, 0);
// Perform Check
boolean contains = TestUtils.equals(expectedResultList, resultList);
Assert.assertTrue(contains);
}
use of edu.uci.ics.texera.api.field.IField in project textdb by TextDB.
the class KeywordSubstringTest method testCombinedSpanInMultipleFieldsQuery.
/**
* Verifies: Verifies List<ITuple> returned multiple results by Substring
* Matcher on query with spaces on both left side and right side.
*
* @throws Exception
*/
@Test
public void testCombinedSpanInMultipleFieldsQuery() throws Exception {
// Prepare Query
String query = " lin ";
ArrayList<String> attributeNames = new ArrayList<>();
attributeNames.add(TestConstants.FIRST_NAME);
attributeNames.add(TestConstants.LAST_NAME);
attributeNames.add(TestConstants.DESCRIPTION);
// Prepare expected result list
List<Span> list = new ArrayList<>();
Span span1 = new Span("description", 24, 29, " lin ", " lin ");
list.add(span1);
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 Query
List<Tuple> resultList = KeywordTestHelper.getScanSourceResults(PEOPLE_TABLE, query, attributeNames, substring, Integer.MAX_VALUE, 0);
// Perform Check
boolean contains = TestUtils.equals(expectedResultList, resultList);
Assert.assertTrue(contains);
}
Aggregations