Java Code Examples for org.apache.jena.rdf.model.Model#add()

The following examples show how to use org.apache.jena.rdf.model.Model#add() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SPARQLEndpointService.java    From hypergraphql with Apache License 2.0 6 votes vote down vote up
void iterateFutureResults (
        final Set<Future<SPARQLExecutionResult>> futureSPARQLResults,
        final Model unionModel,
        Map<String, Set<String>> resultSet
) {

    for (Future<SPARQLExecutionResult> futureExecutionResult : futureSPARQLResults) {
        try {
            SPARQLExecutionResult result = futureExecutionResult.get();
            unionModel.add(result.getModel());
            resultSet.putAll(result.getResultSet());
        } catch (InterruptedException
                | ExecutionException e) {
            e.printStackTrace();
        }
    }
}
 
Example 2
Source File: AbstractDataGenerator.java    From IGUANA with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * Will send a {@link org.apache.jena.rdf.model.Model} 
 */
public void sendData(Model m) throws Exception {
	int sendedSize=0;
	//split Model into small parts
	StmtIterator sti = m.listStatements();
	while(sti.hasNext()){
		Model send = ModelFactory.createDefaultModel();
		send.setNsPrefixes(m.getNsPrefixMap());
		while(sendedSize < maxSize){
			Statement stmt = sti.next();
			send.add(stmt);
			sendedSize+=1;
		}
		sendDataSnippet(RabbitMQUtils.getData(send));
	}
	
}
 
Example 3
Source File: Service.java    From hypergraphql with Apache License 2.0 6 votes vote down vote up
private Model buildModel(QuerySolution results, JsonNode currentNode , HGQLSchema schema) {

        Model model = ModelFactory.createDefaultModel();

        FieldConfig propertyString = schema.getFields().get(currentNode.get("name").asText());
        TypeConfig targetTypeString = schema.getTypes().get(currentNode.get("targetName").asText());

        populateModel(results, currentNode, model, propertyString, targetTypeString);

        QueryFieldConfig queryField = schema.getQueryFields().get(currentNode.get("name").asText());

        if (queryField != null) {

            String typeName = (currentNode.get("alias").isNull()) ? currentNode.get("name").asText() : currentNode.get("alias").asText();
            Resource object = results.getResource(currentNode.get("nodeId").asText());
            Resource subject = model.createResource(HGQL_QUERY_URI);
            Property predicate = model.createProperty("", HGQL_QUERY_NAMESPACE + typeName);
            model.add(subject, predicate, object);
        }
        return model;
    }
 
Example 4
Source File: SPARQLEndpointService.java    From hypergraphql with Apache License 2.0 6 votes vote down vote up
void iterateFutureResults (
        final Set<Future<SPARQLExecutionResult>> futureSPARQLResults,
        final Model unionModel,
        Map<String, Set<String>> resultSet
) {

    for (Future<SPARQLExecutionResult> futureExecutionResult : futureSPARQLResults) {
        try {
            SPARQLExecutionResult result = futureExecutionResult.get();
            unionModel.add(result.getModel());
            resultSet.putAll(result.getResultSet());
        } catch (InterruptedException
                | ExecutionException e) {
            e.printStackTrace();
        }
    }
}
 
Example 5
Source File: RdfStreamReaderDatasetTest.java    From RDFUnit with Apache License 2.0 6 votes vote down vote up
@Before
public void setUp() {
    Model defaultModel = ModelFactory.createDefaultModel();
    defaultModel.add(
            ResourceFactory.createResource("http://rdfunit.aksw.org"),
            OWL.sameAs,
            ResourceFactory.createResource("http://dbpedia.org/resource/Cool")
    );

    Model namedModel = ModelFactory.createDefaultModel();
    namedModel.add(
            ResourceFactory.createResource("http://rdfunit.aksw.org"),
            OWL.sameAs,
            ResourceFactory.createResource("http://dbpedia.org/resource/Super")
    );
    dataset = DatasetFactory.create(defaultModel);

    dataset.addNamedModel("http://rdfunit.aksw.org", namedModel);
}
 
Example 6
Source File: AbstractTool.java    From shacl with Apache License 2.0 6 votes vote down vote up
AbstractTool() {
	
	InputStream shaclTTL = SHACLSystemModel.class.getResourceAsStream("/rdf/shacl.ttl");
	Model shacl = JenaUtil.createMemoryModel();
	shacl.read(shaclTTL, SH.BASE_URI, FileUtils.langTurtle);
	shacl.add(SystemTriples.getVocabularyModel());
	dm.addModel(SH.BASE_URI, shacl);
	
	InputStream dashTTL = SHACLSystemModel.class.getResourceAsStream("/rdf/dash.ttl");
	Model dash = JenaUtil.createMemoryModel();
	dash.read(dashTTL, SH.BASE_URI, FileUtils.langTurtle);
	dm.addModel(DASH.BASE_URI, dash);
	
	InputStream toshTTL = SHACLSystemModel.class.getResourceAsStream("/rdf/tosh.ttl");
	Model tosh = JenaUtil.createMemoryModel();
	tosh.read(toshTTL, SH.BASE_URI, FileUtils.langTurtle);
	dm.addModel(TOSH.BASE_URI, tosh);
	
	spec.setDocumentManager(dm);
	
	SHACLC.install();
}
 
Example 7
Source File: OneM2MContentInstanceMapper.java    From SDA with BSD 2-Clause "Simplified" License 6 votes vote down vote up
public static void main(String[] args) throws IOException {

		File f = new File("/Users/rosenc/Documents/business/[2015]icbms/json_sample1.txt");
		BufferedReader br = new BufferedReader(new FileReader(f));
		String line = null;
		String s = "";
		while ((line = br.readLine()) != null) {
			s = s + line + "\n";
		}

		System.out.println(s);
		Gson gson = new Gson();
		OneM2MContentInstanceDTO cont = gson.fromJson(s, OneM2MContentInstanceDTO.class);
		OneM2MContentInstanceMapper mapper = new OneM2MContentInstanceMapper(cont);

		Model model = ModelFactory.createDefaultModel();
		model.add(mapper.from());
		System.out.println("content type ; " + mapper.getContentType());
		// 스트링 변환부분
		RDFDataMgr.write(System.out, model, RDFFormat.NTRIPLES);
		// System.out.println(mapper.getTypedContent("2k42kk"));
		// mapper.getTypedContent("2.4");

	}
 
Example 8
Source File: OneM2MContentInstanceMapper.java    From SDA with BSD 2-Clause "Simplified" License 6 votes vote down vote up
public static void main(String[] args) throws IOException {

		File f = new File("/Users/rosenc/Documents/business/[2015]icbms/json_sample1.txt");
		BufferedReader br = new BufferedReader(new FileReader(f));
		String line = null;
		String s = "";
		while ((line = br.readLine()) != null) {
			s = s + line + "\n";
		}

		System.out.println(s);
		Gson gson = new Gson();
		OneM2MContentInstanceDTO cont = gson.fromJson(s, OneM2MContentInstanceDTO.class);
		OneM2MContentInstanceMapper mapper = new OneM2MContentInstanceMapper(cont);

		Model model = ModelFactory.createDefaultModel();
		model.add(mapper.from());
		System.out.println("content type ; " + mapper.getContentType());
		// 스트링 변환부분
		RDFDataMgr.write(System.out, model, RDFFormat.NTRIPLES);
		// System.out.println(mapper.getTypedContent("2k42kk"));
		// mapper.getTypedContent("2.4");

	}
 
Example 9
Source File: HierarchicalMatchingsCounterTest.java    From gerbil with GNU Affero General Public License v3.0 5 votes vote down vote up
public static Resource[] createResources(int numberOfResources, Model classModel) {
    Resource resources[] = new Resource[numberOfResources];
    int startChar = (int) 'A';
    for (int i = 0; i < resources.length; ++i) {
        resources[i] = classModel.createResource(KNOWN_KB_URIS[0] + ((char) (startChar + i)));
        classModel.add(resources[i], RDF.type, RDFS.Class);
    }
    return resources;
}
 
Example 10
Source File: DB2Closure.java    From quetzal with Eclipse Public License 2.0 5 votes vote down vote up
private static void closure(Statement stmt, Model closureBlob,
		Collection<Resource> visited, ClosureTest test, Collection<String> resources) {
	if (test.includeStmt(stmt))
		closureBlob.add(stmt);
	closure(stmt.getSubject(), closureBlob, visited, test, resources);
	closure(stmt.getObject(), closureBlob, visited, test, resources);
}
 
Example 11
Source File: DataIDGenerator.java    From gerbil with GNU Affero General Public License v3.0 5 votes vote down vote up
public Resource createExperimentResource(Model model, String eID) {
    // create experiment resource
    Resource experiment = model.createResource(gerbilURL + EXPERIMENT_PREFIX + eID);
    experiment.addProperty(RDF.type, CUBE.Dataset);
    experiment.addProperty(RDF.type, GERBIL.Experiment);

    model.add(experiment, RDFS.label, "Experiment " + eID);
    model.add(experiment, CUBE.structure, GERBIL.DSD);

    return experiment;
}
 
Example 12
Source File: GraphValidationTestCaseType.java    From shacl with Apache License 2.0 5 votes vote down vote up
public static void addStatements(Model model, Statement s) {
	if(!IGNORED_PROPERTIES.contains(s.getPredicate())) {
		model.add(s);
	}
	if(s.getObject().isAnon()) {
		for(Statement t : s.getModel().listStatements(s.getResource(), null, (RDFNode)null).toList()) {
			addStatements(model, t);
		}
	}
}
 
Example 13
Source File: ReaderTestUtils.java    From RDFUnit with Apache License 2.0 5 votes vote down vote up
public static Model createOneTripleModel() {
    Model model = ModelFactory.createDefaultModel();
    model.add(
            ResourceFactory.createResource("http://rdfunit.aksw.org"),
            OWL.sameAs,
            ResourceFactory.createResource("http://dbpedia.org/resource/Cool"));
    return model;
}
 
Example 14
Source File: OneM2MAEDTO.java    From SDA with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public static void main(String[] args) {
	String sample = " {     \"_id\" : ObjectId(\"561e1e1e1ee82041fac258b6\"),     \"rn\" : \"SAE_0\",     \"ty\" : 2,     \"ri\" : \"SAE_0\",     \"pi\" : \"herit-in\",     \"lbl\" : [          \"home1\",          \"home_service\"     ],     \"et\" : \"20151203T122321\",     \"at\" : [          \"//onem2m.hubiss.com/cse1\",          \"//onem2m.hubiss.com/cse2\"     ],     \"aa\" : [          \"poa\",          \"apn\"     ],     \"apn\" : \"onem2mPlatformAdmin\",     \"api\" : \"NHeritAdmin\",     \"aei\" : \"/SAE_0\",     \"poa\" : [          \"10.101.101.111:8080\"     ],     \"rr\" : false,     \"_uri\" : \"/herit-in/herit-cse/SAE_0\",     \"ct\" : \"20151014T181926\",     \"lt\" : \"20151014T181926\" }";
	Gson gson = new Gson();
	OneM2MAEDTO cont = gson.fromJson(sample, OneM2MAEDTO.class);


	System.out.println(cont);
	
	OneM2MAEMapper mapper = new OneM2MAEMapper(cont);
	Model model = ModelFactory.createDefaultModel();
	model.add(mapper.from());
	
	//스트링 변환부분
	RDFDataMgr.write(System.out, model, RDFFormat.NTRIPLES);
}
 
Example 15
Source File: JenaUtil.java    From quetzal with Eclipse Public License 2.0 5 votes vote down vote up
public static void addTupleSet(Dataset dataset, TupleSet tt, BasicUniverse u, Instance t2) {
	if (tt != null) {
		for(Tuple t : tt) {
			Object graph = t.atom(0);
			Model m = QuadTableRelations.defaultGraph.equals(graph)? dataset.getDefaultModel(): dataset.getNamedModel(graph.toString());
			m.add(fromTuple(m, t, u, t2));
		}
	}
}
 
Example 16
Source File: JenaTransformationRepairConnectedSegments.java    From trainbenchmark with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void activate(final Collection<JenaConnectedSegmentsMatch> matches) throws IOException {
	final Model model = driver.getModel();
	final Property connectsToProperty = model.getProperty(BASE_PREFIX + ModelConstants.LENGTH);

	for (final JenaConnectedSegmentsMatch match : matches) {
		final Resource segment2 = match.getSegment2();

		// delete segment2 by removing all (segment2, _, _) and (_, _, segment2) triples
		final Collection<Statement> statementsToRemove = new ArrayList<>();

		final Selector selectorOutgoingEdges = new SimpleSelector(segment2, null, (RDFNode) null);
		final StmtIterator statementsOutgoingEdges = model.listStatements(selectorOutgoingEdges);
		while (statementsOutgoingEdges.hasNext()) {
			statementsToRemove.add(statementsOutgoingEdges.next());
		}
		final Selector selectorIncomingEdges = new SimpleSelector(null, null, segment2);
		final StmtIterator statementsIncomingEdges = model.listStatements(selectorIncomingEdges);
		while (statementsIncomingEdges.hasNext()) {
			statementsToRemove.add(statementsIncomingEdges.next());
		}
		for (final Statement statement : statementsToRemove) {
			model.remove(statement);
		}

		// insert (segment1)-[:connectsTo]->(segment3) edge
		model.add(model.createStatement(match.getSegment1(), connectsToProperty, match.getSegment3()));
	}
}
 
Example 17
Source File: HdtBasedRequestProcessorForTPFs.java    From Server.Java with MIT License 4 votes vote down vote up
/**
 * Creates an {@link ILinkedDataFragment} from the HDT
 * 
 * @param subject
 * @param predicate
 * @param object
 * @param offset
 * @param limit
 * @return
 */
@Override
protected ILinkedDataFragment createFragment(
           final ITriplePatternElement<RDFNode,String,String> subject,
           final ITriplePatternElement<RDFNode,String,String> predicate,
           final ITriplePatternElement<RDFNode,String,String> object,
           final long offset,
           final long limit )
{
    // FIXME: The following algorithm is incorrect for cases in which
    //        the requested triple pattern contains a specific variable
    //        multiple times;
    //        e.g., (?x foaf:knows ?x ) or (_:bn foaf:knows _:bn)
    // see https://github.com/LinkedDataFragments/Server.Java/issues/23

    // look up the result from the HDT datasource)
    int subjectId = subject.isVariable() ? 0 : dictionary.getIntID(subject.asConstantTerm().asNode(), TripleComponentRole.SUBJECT);
    int predicateId = predicate.isVariable() ? 0 : dictionary.getIntID(predicate.asConstantTerm().asNode(), TripleComponentRole.PREDICATE);
    int objectId = object.isVariable() ? 0 : dictionary.getIntID(object.asConstantTerm().asNode(), TripleComponentRole.OBJECT);

    if (subjectId < 0 || predicateId < 0 || objectId < 0) {
        return createEmptyTriplePatternFragment();
    }

    final Model triples = ModelFactory.createDefaultModel();
    IteratorTripleID matches = datasource.getTriples().search(new TripleID(subjectId, predicateId, objectId));
    boolean hasMatches = matches.hasNext();
		
    if (hasMatches) {
        // try to jump directly to the offset
        boolean atOffset;
        if (matches.canGoTo()) {
            try {
                matches.goTo(offset);
                atOffset = true;
            } // if the offset is outside the bounds, this page has no matches
            catch (IndexOutOfBoundsException exception) {
                atOffset = false;
            }
        } // if not possible, advance to the offset iteratively
        else {
            matches.goToStart();
            for (int i = 0; !(atOffset = i == offset) && matches.hasNext(); i++) {
                matches.next();
            }
        }
        // try to add `limit` triples to the result model
        if (atOffset) {
            for (int i = 0; i < limit && matches.hasNext(); i++) {
                triples.add(triples.asStatement(toTriple(matches.next())));
            }
        }
    }

    // estimates can be wrong; ensure 0 is returned if there are no results, 
    // and always more than actual results
    final long estimatedTotal = triples.size() > 0 ?
            Math.max(offset + triples.size() + 1, matches.estimatedNumResults())
            : hasMatches ?
                    Math.max(matches.estimatedNumResults(), 1)
                    : 0;

    // create the fragment
    final boolean isLastPage = ( estimatedTotal < offset + limit );
    return createTriplePatternFragment( triples, estimatedTotal, isLastPage );
}
 
Example 18
Source File: ExTDB6.java    From xcurator with Apache License 2.0 4 votes vote down vote up
public static void main(String[] args) throws Exception {
    /// turn off the "No BGP optimizer warning"
    TDB.setOptimizerWarningFlag(false);

    final IRIFactory iriFactory = IRIFactory.semanticWebImplementation();

    final String DATASET_DIR_NAME = "data0";
    final Dataset data0 = TDBFactory.createDataset( DATASET_DIR_NAME );

    // show the currently registered names
    for (Iterator<String> it = data0.listNames(); it.hasNext(); ) {
        out.println("NAME="+it.next());
    }

    out.println("getting named model...");
    /// this is the OWL portion
    final Model model = data0.getNamedModel( MY_NS );
    out.println("Model := "+model);

    out.println("getting graph...");
    /// this is the DATA in that MODEL
    final Graph graph = model.getGraph();
    out.println("Graph := "+graph);

    if (graph.isEmpty()) {
        final Resource product1 = model.createResource(
                iriFactory.construct( MY_NS +"product/1" )
                    .toString() );

        final Property hasName = model.createProperty( MY_NS, "#hasName");
        final Statement stmt = model.createStatement(
                product1, hasName, model.createLiteral("Beach Ball","en") );
        out.println("Statement = " + stmt);

        model.add(stmt);

        // just for fun
        out.println("Triple := " + stmt.asTriple().toString());
    } else {
        out.println("Graph is not Empty; it has "+graph.size()+" Statements");
        long t0, t1;
        t0 = System.currentTimeMillis();
        final Query q = QueryFactory.create(
                "PREFIX exns: <"+MY_NS+"#>\n"+
                "PREFIX exprod: <"+MY_NS+"product/>\n"+
                " SELECT * "
                // if you don't provide the Model to the
                // QueryExecutionFactory below, then you'll need
                // to specify the FROM;
                // you *can* always specify it, if you want
                // +" FROM <"+MY_NS+">\n"
                // +" WHERE { ?node <"+MY_NS+"#hasName> ?name }"
                // +" WHERE { ?node exns:hasName ?name }"
                // +" WHERE { exprod:1 exns:hasName ?name }"
                +" WHERE { ?res ?pred ?obj }"
                );
        out.println("Query := "+q);
        t1 = System.currentTimeMillis();
        out.println("QueryFactory.TIME="+(t1 - t0));

        t0 = System.currentTimeMillis();
        final QueryExecution qExec = QueryExecutionFactory
                // if you query the whole DataSet,
                // you have to provide a FROM in the SparQL
                //.create(q, data0);
                .create(q, model);
        t1 = System.currentTimeMillis();
        out.println("QueryExecutionFactory.TIME="+(t1 - t0));

        try {
            t0 = System.currentTimeMillis();
            ResultSet rs = qExec.execSelect();
            t1 = System.currentTimeMillis();
            out.println("executeSelect.TIME="+(t1 - t0));
            while (rs.hasNext()) {
                QuerySolution sol = rs.next();
                out.println("Solution := "+sol);
                for (Iterator<String> names = sol.varNames(); names.hasNext(); ) {
                    final String name = names.next();
                    out.println("\t"+name+" := "+sol.get(name));
                }
            }
        } finally {
            qExec.close();
        }
    }
    out.println("closing graph");
    graph.close();
    out.println("closing model");
    model.close();
    //out.println("closing DataSetGraph");
    //dsg.close();
    out.println("closing DataSet");
    data0.close();
}
 
Example 19
Source File: TripleService.java    From SDA with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public String getTriple(Object doc) throws Exception {
	Gson gson = new Gson();
	StringWriter sw = new StringWriter();
	String returnStr = "";
	String ri = Utils.NotSupportingType;
	OneM2MContentInstanceDTO contextInstanceDTO = new OneM2MContentInstanceDTO();

	int ty = -1;

	if (doc instanceof DBObject) {
		DBObject docT = (DBObject) doc;
		ty = (Integer) docT.get("ty");
	} else if (doc instanceof String) {
		// ty값을 확인하기 위해서 특정 객체에 매핑해봄(ty=4)
		contextInstanceDTO = gson.fromJson((String) doc, OneM2MContentInstanceDTO.class);
		ty = Integer.parseInt(contextInstanceDTO.getTy());
	}

	if (ty == 5) {
		log.debug("=== ri : "+ri+",  ty : "+ty+" ====>exclude");
		sw.flush();
	} else if (ty == 4) {
		if (doc instanceof DBObject) {
			contextInstanceDTO = gson.fromJson(gson.toJson(doc), OneM2MContentInstanceDTO.class);
		} else if (doc instanceof String) {
			contextInstanceDTO = gson.fromJson((String) doc, OneM2MContentInstanceDTO.class);
		}
		log.debug("=== ri : "+contextInstanceDTO.getRi()+",  ty : "+ty+" ====>include");		
		
		OneM2MContentInstanceMapper mapper = new OneM2MContentInstanceMapper(contextInstanceDTO);
	
		Model model = ModelFactory.createDefaultModel();
		model.add(mapper.from());
		
		// 스트링 변환부분(test)
	    //RDFDataMgr.write(System.out, model, RDFFormat.NTRIPLES);

		// 스트링 변환부분
		RDFDataMgr.write(sw, model, RDFFormat.NTRIPLES);

		returnStr = sw.toString();
		sw.flush();
	} else if (ty == 3) {
		log.debug("=== ri: "+ri+",  ty : "+ty+" ====>exclude");			
		sw.flush();

		/*
		 * OneM2MContainerDTO cont = null; if (doc instanceof DBObject) {
		 * gson.toJson(doc)); cont = gson.fromJson(gson.toJson(doc),
		 * OneM2MContainerDTO.class); } else if (doc instanceof String) {
		 * (doc)); cont = gson.fromJson((String) doc,
		 * OneM2MContainerDTO.class); } OneM2MContainerMapper mapper = new
		 * OneM2MContainerMapper(cont); Model model =
		 * ModelFactory.createDefaultModel(); model.add(mapper.from());
		 * 
		 * // 스트링 변환부분 RDFDataMgr.write(sw, model, RDFFormat.NTRIPLES);
		 * 
		 * log.debug("value from mongo ====3(json)====>" +
		 * cont.toString()); log.debug(
		 * "value from mongo ====3(sw)====>" + sw.toString());
		 * 
		 * returnStr = sw.toString(); sw.flush();
		 */
	} else if (ty == 2) {
		log.debug("=== ri : "+ri+",  ty : "+ty+" ====>exclude");			
		sw.flush();

		/*
		 * OneM2MAEDTO cont = null; if (doc instanceof DBObject) {
		 * gson.toJson(doc)); cont = gson.fromJson(gson.toJson(doc),
		 * OneM2MAEDTO.class); } else if (doc instanceof String) {
		 * (doc)); cont = gson.fromJson((String) (doc), OneM2MAEDTO.class);
		 * } OneM2MAEMapper mapper = new OneM2MAEMapper(cont);
		 * 
		 * Model model = ModelFactory.createDefaultModel();
		 * model.add(mapper.from());
		 * 
		 * // 스트링 변환부분 RDFDataMgr.write(sw, model, RDFFormat.NTRIPLES);
		 * 
		 * log.debug("value from mongo ====2(json)====>" +
		 * cont.toString()); log.debug(
		 * "value from mongo ====2(sw)====>" + sw.toString());
		 * 
		 * returnStr = sw.toString(); sw.flush();
		 */
	} else if (ty == 1) {
		log.debug("=== ri : "+ri+",  ty : "+ty+" ====>exclude");			
		sw.flush();
	} else if (ty == 0) {
		log.debug("=== ri : "+ri+",  ty : "+ty+" ====>exclude");			
		sw.flush();
	} else {
		log.debug("unknown ty("+ty+") value ====>exclude ");
	}
	
	return returnStr;
}
 
Example 20
Source File: InteractiveMode.java    From rdflint with MIT License 4 votes vote down vote up
/**
 * execute interacitve mode.
 */
void execute(Map<String, String> cmdOptions) throws IOException {
  // initialize graph model
  Model m = ModelFactory.createDefaultModel();

  // initialize jline
  Terminal terminal = TerminalBuilder.builder()
      .system(true)
      .build();
  LineReader lineReader = LineReaderBuilder.builder()
      .terminal(terminal)
      .completer(new InteractiveCompleter(m))
      .parser(new InteractiveParser())
      .build();

  String welcome = MessageFormat
      .format(messages.getString("interactivemode.welcome"), RdfLint.VERSION);
  System.out.println(welcome);// NOPMD

  RdfLintParameters params = new RdfLintParameters();
  try {
    // load configurations
    params = ConfigurationLoader.loadParameters(cmdOptions);
    // load rdf
    m.removeAll();
    m.add(DatasetLoader.loadRdfSet(params, params.getTargetDir()));
  } catch (Exception ex) {
    System.out.println(ex.getLocalizedMessage()); // NOPMD
  }

  while (true) {
    String line;

    try {
      line = lineReader.readLine("SPARQL> ");
    } catch (UserInterruptException | EndOfFileException e) {
      return;
    }

    if (!interactiveCommand(System.out, line, params, cmdOptions, m)) {
      return;
    }
  }
}