@@ -0,0 +1,2776 @@
+package it.polito.nexa;%0A%0Aimport com.hp.hpl.jena.rdf.model.Model;%0Aimport com.hp.hpl.jena.rdf.model.ModelFactory;%0Aimport com.hp.hpl.jena.vocabulary.DCTerms;%0Aimport com.hp.hpl.jena.vocabulary.RDF;%0Aimport com.hp.hpl.jena.vocabulary.RDFS;%0Aimport it.polito.nexa.triplifiers.DefaultJSONTriplifier;%0Aimport org.apache.jena.riot.RDFDataMgr;%0Aimport org.apache.jena.riot.RDFFormat;%0A%0Aimport java.io.*;%0Aimport java.util.HashMap;%0Aimport java.util.Map;%0A%0Apublic class TriplesGenerator %7B%0A%0A    public static void main(String%5B%5D args) throws IOException %7B%0A        if (args.length != 4) %7B%0A            System.err.println(%22Number of arguments is wrong!%22);%0A            System.exit(1);%0A        %7D%0A%0A        String dataPath = args%5B0%5D;%0A        String dataModel = args%5B1%5D;%0A        String data = readFile(dataPath);%0A        String model = readFile(dataModel);%0A        String baseURI = args%5B2%5D;%0A        String uriReference = args%5B3%5D;%0A%0A        Model baseModel = createBaseModel();%0A        DefaultJSONTriplifier djt = new DefaultJSONTriplifier(data, model, baseURI, uriReference);%0A        baseModel.add(djt.triplifyJSON());%0A%0A        publishRDF(%22output/rdf.nt%22, baseModel);%0A    %7D%0A%0A    private static String readFile(String source)%7B%0A        String data = %22%22;%0A        try %7B%0A            BufferedReader br = new BufferedReader(new FileReader(source));%0A            StringBuilder sb = new StringBuilder();%0A            String line;%0A            while ((line = br.readLine()) != null) %7B%0A                sb.append(line+%22%5Cn%22);%0A            %7D%0A            br.close();%0A            data = sb.toString();%0A        %7D catch (FileNotFoundException e) %7B%0A            e.printStackTrace();%0A        %7D catch (IOException e) %7B%0A            e.printStackTrace();%0A        %7D%0A        return data;%0A    %7D%0A%0A    private static Model createBaseModel()%7B%0A        Model result = ModelFactory.createDefaultModel();%0A        Map%3CString, String%3E prefixMap = new HashMap%3CString, String%3E();%0A%0A        prefixMap.put(%22rdfs%22, RDFS.getURI());%0A        prefixMap.put(%22geo%22, %22http://www.w3.org/2003/01/geo/wgs84_pos#%22);%0A        prefixMap.put(%22schema%22, %22http://schema.org/%22);%0A        prefixMap.put(%22rdf%22, %22http://www.w3.org/1999/02/22-rdf-syntax-ns#%22);%0A        prefixMap.put(%22gn%22, %22http://www.geonames.org/ontology#%22);%0A        prefixMap.put(%22rdf%22, RDF.getURI());%0A        prefixMap.put(%22dcterms%22, DCTerms.getURI());%0A%0A        result.setNsPrefixes(prefixMap);%0A%0A        return result;%0A    %7D%0A%0A    private static void publishRDF(String filePath, Model model) throws FileNotFoundException %7B%0A        File file = new File(filePath.replaceAll(%22(.+)/%5B%5E/%5D+%22, %22$1%22));%0A        file.mkdirs();%0A        OutputStream outTurtle = new FileOutputStream(new File(filePath));%0A        RDFDataMgr.write(outTurtle, model, RDFFormat.NTRIPLES);%0A        System.out.println(%22RDF printed!%22);%0A    %7D%0A%7D%0A

Create TriplesGenerator