Example usage for edu.stanford.nlp.io StringOutputStream StringOutputStream

List of usage examples for edu.stanford.nlp.io StringOutputStream StringOutputStream

Introduction

In this page you can find the example usage for edu.stanford.nlp.io StringOutputStream StringOutputStream.

Prototype

public StringOutputStream() 

Source Link

Usage

From source file:com.tronipm.orcaide.controller.ControllerConversor.java

License:Apache License

public void print() {
    RDFXMLDocumentFormat f = new RDFXMLDocumentFormat();
    //        ManchesterSyntaxDocumentFormat f = new ManchesterSyntaxDocumentFormat();

    StringOutputStream stream = new StringOutputStream();
    try {//from w  w w  .j  a va  2 s.co  m
        manager.saveOntology(ontology, f, stream);
        System.out.println(stream.toString());
    } catch (OWLOntologyStorageException ex) {
        Logger.getLogger(ControllerConversor.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:com.tronipm.orcaide.core.OWLRepository.java

License:Apache License

public void saveState() throws OWLOntologyCreationException {
    OWLOntologyManager m = OWLManager.createOWLOntologyManager();
    try {//w  w w. ja v  a 2s .c o  m
        saveOntologyToOutputStream();
    } catch (Exception ex) {
        Logger.getLogger(OWLRepository.class.getName()).log(Level.SEVERE, null, ex);
    }
    OWLOntology clone = m
            .loadOntologyFromOntologyDocument(new StringDocumentSource(currentOutputStreamOntology.toString()));
    OWLDataFactory df_clone = m.getOWLDataFactory();
    StringOutputStream output = new StringOutputStream();
    try {
        m.saveOntology(clone, output);
    } catch (OWLOntologyStorageException ex) {
        Logger.getLogger(OWLRepository.class.getName()).log(Level.SEVERE, null, ex);
    }

    /*OWLOntology clone = m.createOntology();
     m.addAxioms(clone, original.getAxioms());
     for (OWLImportsDeclaration d : original.getImportsDeclarations()) {
     m.applyChange(new AddImport(clone, d));
     }*/
    OntologyBundle bundle = new OntologyBundle();
    bundle.setOntologyManager(m);
    bundle.setOntology(clone);
    bundle.setDataFactory(df_clone);
    bundle.setOutputStreamOntology(output);

    undoRedoOntologyManager.insert(bundle);

    try {
        coreApp.frame.verifyOntologyUndoRedoButtonEnabled();
    } catch (NullPointerException e) {
        //vai cair no catch no inicio do programa...
    }

}

From source file:com.tronipm.orcaide.core.OWLRepository.java

License:Apache License

public void saveOntologyToOutputStream(OWLDocumentFormat format) throws Exception {

    if (format == null) {
        format = new RDFXMLDocumentFormat();
    }//from w  ww . ja  va2 s. co  m

    currentOutputStreamOntology = new StringOutputStream();
    currentOntologyManager.saveOntology(currentOntology, format, currentOutputStreamOntology);
}

From source file:com.tronipm.orcaide.core.OWLRepository.java

License:Apache License

public void mergedOntology(String pathNewOntology)
        throws OWLOntologyStorageException, OWLOntologyCreationException {
    //OWLOntologyManager m = create();
    Object[] objs = null;/*from   w ww  .  j a v a  2s.  co m*/
    try {
        objs = loadOntologyFromFile(pathNewOntology);
    } catch (OWLOntologyCreationException ex) {
        Logger.getLogger(OWLRepository.class.getName()).log(Level.SEVERE, null, ex);
    }
    OWLOntologyManager ontologyManager_new = (OWLOntologyManager) objs[0];
    OWLOntology ontology_new = (OWLOntology) objs[1];
    StringOutputStream aAux = new StringOutputStream();
    ontologyManager_new.saveOntology(ontology_new, aAux);
    String aString = aAux.toString();
    System.out.println(aString);

    currentOntologyManager.addAxiom(ontology_new, currentDataFactory
            .getOWLDeclarationAxiom(currentDataFactory.getOWLClass(IRI.create("PAULOMATEUS"))));

    OWLOntologyMerger merger = new OWLOntologyMerger(currentOntologyManager);
    IRI mergedOntologyIRI = IRI.create("Mateus");
    OWLOntology merged = merger.createMergedOntology(ontologyManager_new, mergedOntologyIRI);

    StringOutputStream aaa = new StringOutputStream();
    ontologyManager_new.saveOntology(merged, aaa);

    System.out.println("NEW ONTOLOGY START");
    System.out.println(aaa.toString());
    System.out.println("NEW ONTOLOGY END----------------------------------");
    //ontologyManager = ontologyManager_new;
    currentOntology = merged;
    currentDataFactory = currentOntologyManager.getOWLDataFactory();

    coreApp.atualizarTelas();
}

From source file:com.tronipm.orcaide.core.PelletRepository.java

License:Apache License

public void getInferring(boolean isStandard) throws OWLOntologyCreationException {
    List<InferredAxiomGenerator<? extends OWLAxiom>> gens = new ArrayList<>();
    gens.add(new InferredClassAssertionAxiomGenerator());
    //gens.add(new InferredDataPropertyCharacteristicAxiomGenerator());
    gens.add(new InferredDisjointClassesAxiomGenerator());
    gens.add(new InferredEquivalentClassAxiomGenerator());
    gens.add(new InferredEquivalentClassAxiomGenerator());
    //gens.add(new InferredEquivalentDataPropertiesAxiomGenerator());
    //gens.add(new InferredEquivalentObjectPropertyAxiomGenerator());
    //gens.add(new InferredInverseObjectPropertiesAxiomGenerator());
    //gens.add(new InferredObjectPropertyCharacteristicAxiomGenerator());
    //gens.add(new InferredPropertyAssertionGenerator());
    gens.add(new InferredSubClassAxiomGenerator());
    //gens.add(new InferredSubObjectPropertyAxiomGenerator());
    /**//  ww  w .  j  av  a2s  .c  o m
     * Para tirar os parmetros, s remover o "gens" de
     * InferredOntologyGenerator
     */
    ontology_INFERRED_ = getOntologyManager().createOntology();
    //InferredOntologyGenerator iog = new InferredOntologyGenerator(reasoner);
    InferredOntologyGenerator iog = null;
    if (isStandard) {
        iog = new InferredOntologyGenerator(reasoner);
    } else {
        iog = new InferredOntologyGenerator(reasoner, gens);
    }
    iog.fillOntology(getOntologyManager().getOWLDataFactory(), ontology_INFERRED_);

    //Gerando em outputStream ontologia
    StringOutputStream auxiliar = new StringOutputStream();
    try {
        getOntologyManager().saveOntology(ontology_INFERRED_, auxiliar);
    } catch (OWLOntologyStorageException ex) {
        Logger.getLogger(PelletRepository.class.getName()).log(Level.SEVERE, null, ex);
    }

    ontology_INFERRED_STRING = auxiliar.toString();
}

From source file:knu.univ.lingvo.coref.SieveCoreferenceSystem.java

License:Open Source License

public static String getConllEvalSummary(String conllMentionEvalScript, String goldFile, String predictFile)
        throws IOException {
    ProcessBuilder process = new ProcessBuilder(conllMentionEvalScript, "all", goldFile, predictFile, "none");
    StringOutputStream errSos = new StringOutputStream();
    StringOutputStream outSos = new StringOutputStream();
    PrintWriter out = new PrintWriter(outSos);
    PrintWriter err = new PrintWriter(errSos);
    SystemUtils.run(process, out, err);/*from w  ww . j ava 2  s.  c o m*/
    out.close();
    err.close();
    String summary = outSos.toString();
    String errStr = errSos.toString();
    if (!errStr.isEmpty()) {
        summary += "\nERROR: " + errStr;
    }
    Pattern pattern = Pattern.compile("\\d+\\.\\d\\d\\d+");
    DecimalFormat df = new DecimalFormat("#.##");
    Matcher matcher = pattern.matcher(summary);
    while (matcher.find()) {
        String number = matcher.group();
        summary = summary.replaceFirst(number, df.format(Double.parseDouble(number)));
    }
    return summary;
}

From source file:LVCoref.LVCoref.java

License:Open Source License

public static String getConllEvalSummary(String conllMentionEvalScript, String goldFile, String predictFile)
        throws IOException {
    if (conllMentionEvalScript == null)
        return "";
    ProcessBuilder process = new ProcessBuilder(conllMentionEvalScript, "all", goldFile, predictFile, "none");
    StringOutputStream errSos = new StringOutputStream();
    StringOutputStream outSos = new StringOutputStream();
    PrintWriter out = new PrintWriter(outSos);
    PrintWriter err = new PrintWriter(errSos);
    SystemUtils.run(process, out, err);/*from w  w  w . j  a v a  2 s  .  c  o  m*/
    out.close();
    err.close();
    String summary = outSos.toString();
    String errStr = errSos.toString();
    if (errStr.length() > 0) {
        summary += "\nERROR: " + errStr;
    }
    return summary;
}