Search in sources :

Example 1 with TextIndex

use of org.apache.jena.query.text.TextIndex in project jena by apache.

the class TextDatasetAssembler method open.

/*
<#text_dataset> rdf:type     text:Dataset ;
    text:dataset <#dataset> ;
    text:index   <#index> ;
    .

     */
@Override
public Dataset open(Assembler a, Resource root, Mode mode) {
    Resource dataset = GraphUtils.getResourceValue(root, pDataset);
    Resource index = GraphUtils.getResourceValue(root, pIndex);
    Resource textDocProducerNode = GraphUtils.getResourceValue(root, pTextDocProducer);
    Dataset ds = (Dataset) a.open(dataset);
    TextIndex textIndex = (TextIndex) a.open(index);
    // Null will use the default producer
    TextDocProducer textDocProducer = null;
    if (null != textDocProducerNode) {
        Class<?> c = Loader.loadClass(textDocProducerNode.getURI(), TextDocProducer.class);
        String className = textDocProducerNode.getURI().substring(ARQConstants.javaClassURIScheme.length());
        Constructor<?> dyadic = getConstructor(c, DatasetGraph.class, TextIndex.class);
        Constructor<?> monadic = getConstructor(c, TextIndex.class);
        try {
            if (dyadic != null) {
                textDocProducer = (TextDocProducer) dyadic.newInstance(ds.asDatasetGraph(), textIndex);
            } else if (monadic != null) {
                textDocProducer = (TextDocProducer) monadic.newInstance(textIndex);
            } else {
                Log.warn(Loader.class, "Exception during instantiation '" + className + "' no TextIndex or DatasetGraph,Index constructor");
            }
        } catch (Exception ex) {
            Log.warn(Loader.class, "Exception during instantiation '" + className + "': " + ex.getMessage());
            return null;
        }
    }
    Dataset dst = TextDatasetFactory.create(ds, textIndex, true, textDocProducer);
    return dst;
}
Also used : TextVocab.pTextDocProducer(org.apache.jena.query.text.assembler.TextVocab.pTextDocProducer) TextDocProducer(org.apache.jena.query.text.TextDocProducer) TextIndex(org.apache.jena.query.text.TextIndex) TextVocab.textDataset(org.apache.jena.query.text.assembler.TextVocab.textDataset) TextVocab.pDataset(org.apache.jena.query.text.assembler.TextVocab.pDataset) Dataset(org.apache.jena.query.Dataset) Resource(org.apache.jena.rdf.model.Resource) Loader(org.apache.jena.sparql.util.Loader)

Aggregations

Dataset (org.apache.jena.query.Dataset)1 TextDocProducer (org.apache.jena.query.text.TextDocProducer)1 TextIndex (org.apache.jena.query.text.TextIndex)1 TextVocab.pDataset (org.apache.jena.query.text.assembler.TextVocab.pDataset)1 TextVocab.pTextDocProducer (org.apache.jena.query.text.assembler.TextVocab.pTextDocProducer)1 TextVocab.textDataset (org.apache.jena.query.text.assembler.TextVocab.textDataset)1 Resource (org.apache.jena.rdf.model.Resource)1 Loader (org.apache.jena.sparql.util.Loader)1