Examples of NTriplesParser


Examples of no.priv.garshol.duke.utils.NTriplesParser

    private String property;
    private String object;
   
    public IncrementalRecordIterator(Reader input) {
      this.reader = new BufferedReader(input);
      this.parser = new NTriplesParser(this);
      parseNextLine();
      findNextRecord();
    }
View Full Code Here

Examples of org.openrdf.rio.ntriples.NTriplesParser

      InputStream in = inputURL.openStream();
      turtleParser.parse(in, base(inputURL.toExternalForm()));
      in.close();

      // Parse expected output data
      NTriplesParser ntriplesParser = new NTriplesParser();
      ntriplesParser.setDatatypeHandling(RDFParser.DatatypeHandling.IGNORE);

      Set<Statement> outputCollection = new LinkedHashSet<Statement>();
      StatementCollector outputCollector = new StatementCollector(outputCollection);
      ntriplesParser.setRDFHandler(outputCollector);

      in = outputURL.openStream();
      ntriplesParser.parse(in, base(outputURL.toExternalForm()));
      in.close();

      // Check equality of the two models
      if (!ModelUtil.equals(inputCollection, outputCollection)) {
        System.err.println("===models not equal===");
View Full Code Here

Examples of org.openrdf.rio.ntriples.NTriplesParser

      InputStream in = inputURL.openStream();
      turtleParser.parse(in, base(baseURL));
      in.close();

      // Parse expected output data
      NTriplesParser ntriplesParser = new NTriplesParser();
      ntriplesParser.setDatatypeHandling(RDFParser.DatatypeHandling.IGNORE);

      Set<Statement> outputCollection = new LinkedHashSet<Statement>();
      StatementCollector outputCollector = new StatementCollector(outputCollection);
      ntriplesParser.setRDFHandler(outputCollector);

      in = outputURL.openStream();
      ntriplesParser.parse(in, base(baseURL));
      in.close();

      // Check equality of the two models
      if (!ModelUtil.equals(inputCollection, outputCollection)) {
        System.err.println("===models not equal===");
View Full Code Here

Examples of org.openrdf.rio.ntriples.NTriplesParser

      InputStream in = resolveURL(inputURL).openStream();
      rdfxmlParser.parse(in, base(inputURL));
      in.close();

      // Parse expected output data
      NTriplesParser ntriplesParser = new NTriplesParser();
      ntriplesParser.setValueFactory(new CanonXMLValueFactory());
      ntriplesParser.setDatatypeHandling(RDFParser.DatatypeHandling.IGNORE);

      Set<Statement> outputCollection = new LinkedHashSet<Statement>();
      StatementCollector outputCollector = new StatementCollector(outputCollection);
      ntriplesParser.setRDFHandler(outputCollector);

      in = resolveURL(outputURL).openStream();
      ntriplesParser.parse(in, base(inputURL));
      in.close();

      // Check equality of the two models
      if (!ModelUtil.equals(inputCollection, outputCollection)) {
        StringBuilder sb = new StringBuilder(1024);
View Full Code Here

Examples of org.openrdf.rio.ntriples.NTriplesParser

      manager.close();
      sail.shutDown();
    }

  private static void loadFile(final String file, SailConnection sc, ValueFactory vf, CommitManager manager) throws RDFParseException, RDFHandlerException, FileNotFoundException, IOException {
    NTriplesParser parser = new NTriplesParser(vf);
    TripleHandler handler = new TripleHandler(sc, manager);
    parser.setRDFHandler(handler);
    parser.setStopAtFirstError(false);
    parser.setParseErrorListener(new ParseErrorListener() {
     
      @Override
      public void warning(String msg, int lineNo, int colNo) {
        System.err.println("warning: " + msg);
        System.err.println("file: " + file + " line: " + lineNo + " column: " +colNo);
      }

      @Override
      public void error(String msg, int lineNo, int colNo) {
        System.err.println("error: " + msg);
        System.err.println("file: " + file + " line: " + lineNo + " column: " +colNo);
      }

      @Override
      public void fatalError(String msg, int lineNo, int colNo) {
        System.err.println("fatal: " + msg);
        System.err.println("file: " + file + " line: " + lineNo + " column: " +colNo);
      }
     
    });
    parser.parse(new BufferedInputStream(new FileInputStream(new File(file))), "http://dbpedia.org/");
  }
View Full Code Here

Examples of org.openrdf.rio.ntriples.NTriplesParser

      final SesameParserType parserType, final String encoding) {
    final CounterRDFHandler handler = new CounterRDFHandler(tc);
    try {
      final InputStreamReader isr = new InputStreamReader(in, encoding);
      if (parserType == SesameParserType.NTRIPLES) {
        final NTriplesParser parser = new NTriplesParser();
        parser.setRDFHandler(handler);
        try {
          parser.parse(isr, "");
        } catch (final RDFParseException e) {
          System.err.println(e);
          e.printStackTrace();
        } catch (final RDFHandlerException e) {
          System.err.println(e);
          e.printStackTrace();
        } catch (final IOException e) {
          System.err.println(e);
          e.printStackTrace();
        }
      } else if (parserType == SesameParserType.RDFXML) {
        final RDFXMLParser parser = new RDFXMLParser();
        parser.setRDFHandler(handler);
        try {
          parser.parse(isr, "");
        } catch (final RDFParseException e) {
          System.err.println(e);
          e.printStackTrace();
        } catch (final RDFHandlerException e) {
          System.err.println(e);
          e.printStackTrace();
        } catch (final IOException e) {
          System.err.println(e);
          e.printStackTrace();
        }
      } else if (parserType == SesameParserType.TURTLE) {
        final TurtleParser parser = new TurtleParser();
        parser.setRDFHandler(handler);
        try {
          parser.parse(isr, "");
        } catch (final RDFParseException e) {
          System.err.println(e);
          e.printStackTrace();
        } catch (final RDFHandlerException e) {
          System.err.println(e);
View Full Code Here

Examples of org.openrdf.rio.ntriples.NTriplesParser

            final boolean verifyDataType,
            final boolean stopAtFirstError,
            final ExtractionContext extractionContext,
            final ExtractionResult extractionResult
    ) {
        final NTriplesParser parser = new NTriplesParser();
        configureParser(parser, verifyDataType, stopAtFirstError, extractionContext, extractionResult);
        return parser;
    }
View Full Code Here

Examples of org.openrdf.rio.ntriples.NTriplesParser

            if ("rdfxml".equals(lang)) {
                parser = new RDFXMLParser(r.getValueFactory());
            } else if ("n3".equals(lang) || "turtle".equals(lang)) {
                parser = new TurtleParser(r.getValueFactory());
            } else if ("ntriples".equals(lang)) {
                parser = new NTriplesParser(r.getValueFactory());
            }
           
            try {
              SailConnection c = null;
              try {
View Full Code Here

Examples of org.openrdf.rio.ntriples.NTriplesParser

      InputStream in = inputURL.openStream();
      turtleParser.parse(in, inputURL.toExternalForm());
      in.close();

      // Parse expected output data
      NTriplesParser ntriplesParser = new NTriplesParser();
      ntriplesParser.setDatatypeHandling(RDFParser.DatatypeHandling.IGNORE);

      Set<Statement> outputCollection = new LinkedHashSet<Statement>();
      StatementCollector outputCollector = new StatementCollector(outputCollection);
      ntriplesParser.setRDFHandler(outputCollector);

      in = outputURL.openStream();
      ntriplesParser.parse(in, outputURL.toExternalForm());
      in.close();

      // Check equality of the two models
      if (!ModelUtil.equals(inputCollection, outputCollection)) {
        System.err.println("===models not equal===");
View Full Code Here

Examples of org.openrdf.rio.ntriples.NTriplesParser

      InputStream in = inputURL.openStream();
      turtleParser.parse(in, baseURL);
      in.close();

      // Parse expected output data
      NTriplesParser ntriplesParser = new NTriplesParser();
      ntriplesParser.setDatatypeHandling(RDFParser.DatatypeHandling.IGNORE);

      Set<Statement> outputCollection = new LinkedHashSet<Statement>();
      StatementCollector outputCollector = new StatementCollector(outputCollection);
      ntriplesParser.setRDFHandler(outputCollector);

      in = outputURL.openStream();
      ntriplesParser.parse(in, baseURL);
      in.close();

      // Check equality of the two models
      if (!ModelUtil.equals(inputCollection, outputCollection)) {
        Collection<? extends Statement> missingStatements = RepositoryUtil.difference(outputCollection,
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.