use of edu.uci.ics.textdb.api.schema.Attribute 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;
}
use of edu.uci.ics.textdb.api.schema.Attribute in project textdb by TextDB.
the class JsonSerializationTest method testSchema.
@Test
public void testSchema() {
Schema schema = new Schema(Arrays.asList(new Attribute("_id", AttributeType._ID_TYPE), new Attribute("text", AttributeType.TEXT), new Attribute("payload", AttributeType.LIST)));
TestUtils.testJsonSerialization(schema);
}
use of edu.uci.ics.textdb.api.schema.Attribute in project textdb by TextDB.
the class SchemaTest method testGetInvalidAttribute.
@Test
public void testGetInvalidAttribute() {
Attribute retrievedAttribute1 = schema.getAttribute("invalid_attribute");
Assert.assertNull(retrievedAttribute1);
}
use of edu.uci.ics.textdb.api.schema.Attribute in project textdb by TextDB.
the class SchemaTest method testGetAttributes.
@Test
public void testGetAttributes() {
List<Attribute> attributes = schema.getAttributes();
Assert.assertEquals(this.attributes.length, attributes.size());
for (Attribute attribute : this.attributes) {
Assert.assertTrue(attributes.contains(attribute));
}
}
use of edu.uci.ics.textdb.api.schema.Attribute in project textdb by TextDB.
the class KeywordConjunctionTest method testSingleWordQueryInTextFieldChinese.
/**
* Verifies GetNextTuple of Keyword Matcher and single word queries in Text
* Field using Chinese.
*
* @throws Exception
*/
@Test
public void testSingleWordQueryInTextFieldChinese() throws Exception {
// Prepare the query
String query = "北京大学";
ArrayList<String> attributeNames = new ArrayList<>();
attributeNames.add(TestConstantsChinese.FIRST_NAME);
attributeNames.add(TestConstantsChinese.LAST_NAME);
attributeNames.add(TestConstantsChinese.DESCRIPTION);
// Prepare the expected result list
List<Span> list = new ArrayList<>();
Span span = new Span("description", 0, 4, "北京大学", "北京大学", 0);
list.add(span);
Attribute[] schemaAttributes = new Attribute[TestConstantsChinese.ATTRIBUTES_PEOPLE.length + 1];
for (int count = 0; count < schemaAttributes.length - 1; count++) {
schemaAttributes[count] = TestConstantsChinese.ATTRIBUTES_PEOPLE[count];
}
schemaAttributes[schemaAttributes.length - 1] = new Attribute(RESULTS, AttributeType.LIST);
IField[] fields1 = { new StringField("无忌"), new StringField("长孙"), new IntegerField(46), new DoubleField(5.50), new DateField(new SimpleDateFormat("MM-dd-yyyy").parse("01-14-1970")), new TextField("北京大学电气工程学院"), new ListField<>(list) };
IField[] fields2 = { new StringField("孔明"), new StringField("洛克贝尔"), new IntegerField(42), new DoubleField(5.99), new DateField(new SimpleDateFormat("MM-dd-yyyy").parse("01-13-1974")), new TextField("北京大学计算机学院"), 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(CHINESE_TABLE, query, attributeNames, conjunction, Integer.MAX_VALUE, 0);
// check the results
boolean contains = TestUtils.equals(expectedResultList, resultList);
Assert.assertTrue(contains);
}
Aggregations