[ 
https://issues.apache.org/jira/browse/JENA-735?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14049923#comment-14049923
 ] 

Andy Seaborne commented on JENA-735:
------------------------------------

Please do submit a patch for that.  The table of formats does already exist but 
if you think some extra words would help, please do suggest them.

> Cannot write using TURTLE_FLAT: 
> com.hp.hpl.jena.shared.NoWriterForLangException: TURTLE_FLAT
> --------------------------------------------------------------------------------------------
>
>                 Key: JENA-735
>                 URL: https://issues.apache.org/jira/browse/JENA-735
>             Project: Apache Jena
>          Issue Type: Bug
>          Components: Web site
>    Affects Versions: Jena 2.11.2
>            Reporter: Hendy Irawan
>            Priority: Minor
>
> https://jena.apache.org/documentation/io/rdf-output.html mentioned:
> bq. This page describes the RIOT (RDF I/O technology) output capabilities 
> introduced in Jena 2.10.1. ... There are two ways to write RDF data using 
> Apache Jena RIOT, either via the RDFDataMgr ... or using the model API:
> {code}
> model.write(output, "format") ;
> {code}
> It should be mentioned in the documentation that using the model API has 
> limited supported formats, and Jena users should use RDFDataMgr because it's 
> typesafe and it supports all formats.
> The Model API (I'm using {{DefaultModel}}) method throws exception for 
> {{TURTLE_FLAT}} (it works for {{TURTLE}}):
> {code}
> 05:14:19.797 [main] DEBUG o.a.j.riot.stream.JenaIOEnvironment - Failed to 
> find configuration: 
> location-mapping.ttl;location-mapping.rdf;location-mapping.n3;etc/location-mapping.rdf;etc/location-mapping.n3;etc/location-mapping.ttl
> 05:14:19.851 [main] INFO  c.hendyirawan.wordnet.Wn30CoreToWn31 - Loading 
> WordNet 3.0 core file 
> '/media/ceefour/passport/Tech/Intelligent_Systems/WordNet3/wn30-core-synsets.tab'...
> 05:14:19.993 [main] INFO  c.hendyirawan.wordnet.Wn30CoreToWn31 - Converted to 
> 9920 RDF statements
> 05:14:19.993 [main] INFO  c.hendyirawan.wordnet.Wn30CoreToWn31 - Saving 
> TURTLE to '/home/ceefour/git/wordnet-extras/wn31-core-synsets.ttl'...
> Exception in thread "main" com.hp.hpl.jena.shared.NoWriterForLangException: 
> TURTLE_FLAT
>       at 
> com.hp.hpl.jena.rdf.model.impl.RDFWriterFImpl.getWriter(RDFWriterFImpl.java:125)
>       at com.hp.hpl.jena.rdf.model.impl.ModelCom.getWriter(ModelCom.java:305)
>       at com.hp.hpl.jena.rdf.model.impl.ModelCom.write(ModelCom.java:354)
>       at com.hendyirawan.wordnet.Wn30CoreToWn31.main(Wn30CoreToWn31.java:96)
> {code}
> Code:
> {code}
> Model model = ModelFactory.createDefaultModel();
> model.setNsPrefix("wn31", "http://wordnet-rdf.princeton.edu/wn31/";);
> model.setNsPrefix("wordnet-ontology", 
> "http://wordnet-rdf.princeton.edu/ontology#";);
> model.setNsPrefix("olo", "http://purl.org/ontology/olo/core#";);
> Resource synsetRes = 
> model.createResource(model.getNsPrefixURI("wordnet-ontology") + "Synset");
> Property indexProp = model.createProperty(model.getNsPrefixURI("olo"), 
> "index");
> File wn30coreFile = new File(args[0]);
> log.info("Loading WordNet 3.0 core file '{}'...", wn30coreFile);
> try (CSVReader reader = new CSVReader(new FileReader(wn30coreFile), '\t')) {
>       int index = 1;
>       while (true) {
>               String[] row = reader.readNext();
>               if (row == null) {
>                       break;
>               }
>               String wn30sense = row[0];
>               char posLetter = wn30sense.charAt(9);
>               final Integer posNumeric = 
> Preconditions.checkNotNull(POS_NUMERIC.get(posLetter),
>                               "Invalid part-of-speech letter code '%s' for 
> sense '%s'", posLetter, wn30sense);
>               String wn31sense = posNumeric + wn30sense;
>               final Resource wn31res = 
> model.createResource(model.getNsPrefixURI("wn31") + wn31sense);
>               model.add(wn31res, RDF.type, synsetRes);
>               model.addLiteral(wn31res, indexProp, index); // hacky usage, 
> but pragmatic :P
>               index++;
>       }
> }
> log.info("Converted to {} RDF statements", 
> Iterators.size(model.listStatements()));
> File wn31TurtleFile = new File(args[1], "wn31-core-synsets.ttl");
> log.info("Saving TURTLE to '{}'...", wn31TurtleFile);
> model.write(new FileOutputStream(wn31TurtleFile), "TURTLE_FLAT");
> {code}



--
This message was sent by Atlassian JIRA
(v6.2#6252)

Reply via email to