Search in sources :

Example 16 with RelationManager

use of edu.uci.ics.textdb.storage.RelationManager in project textdb by TextDB.

the class NlpEntityTest method setUp.

@BeforeClass
public static void setUp() throws TextDBException {
    RelationManager relationManager = RelationManager.getRelationManager();
    relationManager.createTable(ONE_SENTENCE_TABLE, "../index/test_tables/" + ONE_SENTENCE_TABLE, NlpEntityTestConstants.SCHEMA_ONE_SENTENCE, LuceneAnalyzerConstants.standardAnalyzerString());
    relationManager.createTable(TWO_SENTENCE_TABLE, "../index/test_tables/" + TWO_SENTENCE_TABLE, NlpEntityTestConstants.SCHEMA_TWO_SENTENCE, LuceneAnalyzerConstants.standardAnalyzerString());
}
Also used : RelationManager(edu.uci.ics.textdb.storage.RelationManager) BeforeClass(org.junit.BeforeClass)

Example 17 with RelationManager

use of edu.uci.ics.textdb.storage.RelationManager in project textdb by TextDB.

the class NlpEntityTest method deleteData.

// table is cleared after each test case
@After
public void deleteData() throws TextDBException {
    RelationManager relationManager = RelationManager.getRelationManager();
    DataWriter oneSentenceDataWriter = relationManager.getTableDataWriter(ONE_SENTENCE_TABLE);
    oneSentenceDataWriter.open();
    oneSentenceDataWriter.clearData();
    oneSentenceDataWriter.close();
    DataWriter twoSentenceDataWriter = relationManager.getTableDataWriter(TWO_SENTENCE_TABLE);
    twoSentenceDataWriter.open();
    twoSentenceDataWriter.clearData();
    twoSentenceDataWriter.close();
}
Also used : RelationManager(edu.uci.ics.textdb.storage.RelationManager) DataWriter(edu.uci.ics.textdb.storage.DataWriter) After(org.junit.After)

Example 18 with RelationManager

use of edu.uci.ics.textdb.storage.RelationManager in project textdb by TextDB.

the class DictionaryMatcherTestHelper method deleteTestTables.

public static void deleteTestTables() throws TextDBException {
    RelationManager relationManager = RelationManager.getRelationManager();
    relationManager.deleteTable(PEOPLE_TABLE);
    relationManager.deleteTable(CHINESE_TABLE);
}
Also used : RelationManager(edu.uci.ics.textdb.storage.RelationManager)

Example 19 with RelationManager

use of edu.uci.ics.textdb.storage.RelationManager in project textdb by TextDB.

the class DictionaryMatcherTestHelper method getScanSourceResults.

/**
     * Get the results from a DictionaryMatcher with a ScanSource Operator 
     *   (which scans the table first and then feeds the data into the dictionary matcher)
     * 
     * @param tableName
     * @param dictionary
     * @param attributeNames
     * @param matchingType
     * @param limit
     * @param offset
     * @return
     * @throws TextDBException
     */
public static List<Tuple> getScanSourceResults(String tableName, Dictionary dictionary, List<String> attributeNames, KeywordMatchingType matchingType, int limit, int offset) throws TextDBException {
    RelationManager relationManager = RelationManager.getRelationManager();
    String luceneAnalyzerStr = relationManager.getTableAnalyzerString(tableName);
    ScanBasedSourceOperator scanSource = new ScanBasedSourceOperator(new ScanSourcePredicate(tableName));
    DictionaryPredicate dictiaonryPredicate = new DictionaryPredicate(dictionary, attributeNames, luceneAnalyzerStr, matchingType, RESULTS);
    DictionaryMatcher dictionaryMatcher = new DictionaryMatcher(dictiaonryPredicate);
    dictionaryMatcher.setLimit(limit);
    dictionaryMatcher.setOffset(offset);
    dictionaryMatcher.setInputOperator(scanSource);
    Tuple tuple;
    List<Tuple> results = new ArrayList<>();
    dictionaryMatcher.open();
    while ((tuple = dictionaryMatcher.getNextTuple()) != null) {
        results.add(tuple);
    }
    dictionaryMatcher.close();
    return results;
}
Also used : ArrayList(java.util.ArrayList) DictionaryPredicate(edu.uci.ics.textdb.exp.dictionarymatcher.DictionaryPredicate) ScanBasedSourceOperator(edu.uci.ics.textdb.exp.source.scan.ScanBasedSourceOperator) ScanSourcePredicate(edu.uci.ics.textdb.exp.source.scan.ScanSourcePredicate) Tuple(edu.uci.ics.textdb.api.tuple.Tuple) RelationManager(edu.uci.ics.textdb.storage.RelationManager)

Example 20 with RelationManager

use of edu.uci.ics.textdb.storage.RelationManager in project textdb by TextDB.

the class FuzzyTokenMatcherTestHelper method writeTestTables.

/*
     * Creates the test table(s) and writes data into it(them).
     */
public static void writeTestTables() throws TextDBException {
    RelationManager relationManager = RelationManager.getRelationManager();
    // create the people table and write tuples
    relationManager.createTable(PEOPLE_TABLE, "../index/test_tables/" + PEOPLE_TABLE, TestConstants.SCHEMA_PEOPLE, LuceneAnalyzerConstants.standardAnalyzerString());
    DataWriter peopleDataWriter = relationManager.getTableDataWriter(PEOPLE_TABLE);
    peopleDataWriter.open();
    for (Tuple tuple : TestConstants.getSamplePeopleTuples()) {
        peopleDataWriter.insertTuple(tuple);
    }
    peopleDataWriter.close();
}
Also used : Tuple(edu.uci.ics.textdb.api.tuple.Tuple) RelationManager(edu.uci.ics.textdb.storage.RelationManager) DataWriter(edu.uci.ics.textdb.storage.DataWriter)

Aggregations

RelationManager (edu.uci.ics.textdb.storage.RelationManager)35 Tuple (edu.uci.ics.textdb.api.tuple.Tuple)19 DataWriter (edu.uci.ics.textdb.storage.DataWriter)18 BeforeClass (org.junit.BeforeClass)8 ArrayList (java.util.ArrayList)5 AfterClass (org.junit.AfterClass)5 ScanBasedSourceOperator (edu.uci.ics.textdb.exp.source.scan.ScanBasedSourceOperator)2 ScanSourcePredicate (edu.uci.ics.textdb.exp.source.scan.ScanSourcePredicate)2 File (java.io.File)2 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 StorageException (edu.uci.ics.textdb.api.exception.StorageException)1 IntegerField (edu.uci.ics.textdb.api.field.IntegerField)1 StringField (edu.uci.ics.textdb.api.field.StringField)1 TextField (edu.uci.ics.textdb.api.field.TextField)1 DictionaryPredicate (edu.uci.ics.textdb.exp.dictionarymatcher.DictionaryPredicate)1 BufferedReader (java.io.BufferedReader)1 IOException (java.io.IOException)1 ParseException (java.text.ParseException)1 Scanner (java.util.Scanner)1