Package org.apache.clerezza.rdf.core.serializedform

Examples of org.apache.clerezza.rdf.core.serializedform.Parser


     * @param format the format of the RDF data
     *
     * @return the resulting MGraph or null if the RDF serialization format is not supported by the parser
     */
    public MGraph readModel(InputStream in, String format) {
        Parser parser = Parser.getInstance();
        if (parser.getSupportedFormats().contains(format)) {
            Graph graph = parser.parse(in, format);
            MGraph model = new SimpleMGraph(graph);
            return model;
        } else {
            log.warn("Unsupported RDF format: {}\nSupported RDF formats: {}",
                    format, parser.getSupportedFormats());
        }
        return null;
    }
View Full Code Here


        assertEquals(classifier.acceptedLanguages, Arrays.asList("en", "fr"));
    }

    @Test
    public void testImportModelFromSKOS() throws Exception {
        Parser parser = Parser.getInstance();
        parser.bindParsingProvider(new JenaParserProvider());
        Graph graph = parser.parse(getClass().getResourceAsStream("/sample-scheme.skos.rdf.xml"),
            SupportedFormat.RDF_XML);
        int imported = classifier.importConceptsFromGraph(graph, OntologicalClasses.SKOS_CONCEPT,
            Properties.SKOS_BROADER);
        assertEquals(imported, 4);
        assertEquals(0, classifier.getBroaderConcepts("http://example.com/ns#someconceptscheme/100").size());
View Full Code Here

            if (LOG.isDebugEnabled()) {
                String rdf = writer.toString("UTF-8");
                LOG.debug(rdf);
            }
            InputStream reader = new ByteArrayInputStream(writer.toByteArray());
            Parser rdfParser = Parser.getInstance();
            Graph graph = rdfParser.parse(reader, this.syntax);
            result.addAll(graph);
        } catch (TransformerException e) {
            throw new ExtractorException(e.getMessage(), e);
        } catch (IOException e) {
            throw new ExtractorException(e.getMessage(), e);
View Full Code Here

     * @param format the format of the RDF data
     *
     * @return the resulting MGraph or null if the RDF serialization format is not supported by the parser
     */
    public MGraph readModel(InputStream in, String format) {
        Parser parser = Parser.getInstance();
        if (parser.getSupportedFormats().contains(format)) {
            Graph graph = parser.parse(in, format);
            MGraph model = new SimpleMGraph(graph);
            return model;
        } else {
            log.warn("Unsupported RDF format: {}\nSupported RDF formats: {}",
                    format, parser.getSupportedFormats());
        }
        return null;
    }
View Full Code Here

    public static void reset() {
        tcManager = new TcManager();
        tcManager.addWeightedTcProvider(new SimpleTcProvider());

        parser = new Parser();
        parser.bindParsingProvider(new JenaParserProvider());
        parser.bindParsingProvider(new RdfJsonParsingProvider());

        serializer = new Serializer();
        serializer.bindSerializingProvider(new JenaSerializerProvider());
View Full Code Here

         */
        if(__parser == null){
            if(context != null){
                __parser = ContextHelper.getServiceFromContext(Parser.class, context);
            } else { //mainly for unit tests we want also allow initialisation without context
                __parser = new Parser();
                __parser.bindParsingProvider(new JenaParserProvider());
            }
        }
        return __parser;
    }
View Full Code Here

        final Dictionary<String,Object> config = new Hashtable<String,Object>();
        config.put(OfflineConfiguration.ONTOLOGY_PATHS, new String[] {"/ontologies", "/ontologies/registry"});
        OfflineConfiguration offline = new OfflineConfigurationImpl(config);
        // The registry manager can be updated via calls to createModel()
        regman = new RegistryManagerImpl(offline, new ClerezzaOntologyProvider(new SimpleTcProvider(),
                offline, new Parser()), config);
    }
View Full Code Here

                         Dictionary<String,Object> configuration) {
        /*
         * Assume this.tcm this.wtcp and this.wtcp were not filled in by OSGi-DS. As a matter of fact,
         * WeightedTcProvider is now ignored as we assume to use those bound with the TcManager.
         */
        this(new ClerezzaOntologyProvider(tcm, offline, new Parser()), offline, configuration);
    }
View Full Code Here

                          Type genericType,
                          Annotation[] annotations,
                          MediaType mediaType,
                          MultivaluedMap<String,String> httpHeaders,
                          InputStream entityStream) throws IOException, WebApplicationException {
        Parser parser = getParser();
        if (parser == null) {
            RuntimeException e = new RuntimeException(String.format(
                "Could not find RDF Parser implementing '%s' in OSGi context.", Parser.class.getName()));
            throw new WebApplicationException(e);
        }
        return parser.parse(entityStream, mediaType.toString());
    }
View Full Code Here

    }

    private static long benchmarkClerezza(String path) throws FileNotFoundException {
        System.out.println("Clerezza benchmark");
        MGraph model = createClerezzaModel();
        Parser parser = Parser.getInstance();

        List<File> files = listFiles(path);
        long time = System.nanoTime();
        for (File file : files) {
            parser.parse(model, new FileInputStream(file), SupportedFormat.RDF_XML);
        }
        System.out.println("Model size = " + model.size());
        return System.nanoTime() - time;
    }
View Full Code Here

TOP

Related Classes of org.apache.clerezza.rdf.core.serializedform.Parser

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.