Package uk.ac.cam.ch.wwmm.oscar3.recogniser.test

Examples of uk.ac.cam.ch.wwmm.oscar3.recogniser.test.PatternRecogniserTest


  /**Performs the example on-initialisation tasks.
   *
   */
  public void call() throws Exception {
    System.out.println("Hello init world!");
    FlowRunner.getInstance().addCommand("helloworld"new FlowCommand() {
      public void call(OscarFlow flow, List<String> args) throws Exception {
        System.out.println("Hello command world!");
        PrintWriter pw = flow.customPrintWriter("hello.txt");
        pw.println("Hello custom output world!");
        pw.close();
View Full Code Here


    writeScrapBook();
  }
 
  public void autoAnnotate() throws Exception {
    clearAnnotations();
    OscarFlow oscarFlow = new OscarFlow(doc);
    oscarFlow.processLite();
    doc = SciXMLDocument.makeFromDoc(oscarFlow.getInlineXML());
    writeScrapBook();
  }
View Full Code Here

    }
    nodes = parseDoc.query("//cmlPile");
    for(int i=0;i<nodes.size();i++) {
      nodes.get(i).detach();
    }   
    OscarFlow oscarFlow = new OscarFlow(parseDoc);
    oscarFlow.processLite();
    parseDoc = oscarFlow.getInlineXML();
   
    Nodes parsedIds = parseDoc.query("//snippet/@id");
    Nodes goodIds = doc.query("//snippet/@id");
    Set<String> parsedIdStrs = new LinkedHashSet<String>();
    Set<String> goodIdStrs = new LinkedHashSet<String>();
View Full Code Here

      }
    })) {
      try {
        String contents = FileUtils.readFileToString(f);
        SciXMLDocument doc = TextToSciXML.textToSciXML(contents);
        OscarFlow flow = new OscarFlow(doc);
        flow.runFlow("recognise resolve");
        if (++count > 200)
          break;
      } catch (Exception e) {
        e.printStackTrace();
      }
View Full Code Here

   * @return The string form of the inline annotated XML.
   * @throws Exception
   */
  public static String stringToString(String input) throws Exception {
    Document doc = TextToSciXML.textToSciXML(input);
    OscarFlow flow = new OscarFlow(doc);
    flow.processLite();
    return flow.getInlineXML().toXML();
  }
View Full Code Here

      doc = ptsx.getSciXML();
    } else {
      throw new Error("Mode not recognised");
    }
   
    OscarFlow oscarFlow = new OscarFlow(doc);

    if(mode.equals("Process")) {
      oscarFlow.processLite();
      return oscarFlow.getInlineXML();
    } else if(mode.equals("SAF")) {
      oscarFlow.processToSAF();
      return oscarFlow.getSafXML();
    } else if(mode.equals("Data")) {
      oscarFlow.parseData();
      return oscarFlow.getDataXML();
    } else if(mode.equals("RoundTrip")) {
      oscarFlow.processLite();
      ptsx.setSciXMLDoc(oscarFlow.getInlineXML());
      return ptsx.getAnnotatedPubXML();
    }
    return null;
  }
View Full Code Here

      /* Get "side streams" for output ready */
      Document safDoc = new Document(new Element("dummy"));
      /* Get the document */
      Document doc = new Builder().build(new File(directory, "source.xml"));
     
      OscarFlow oscarFlow = new OscarFlow(doc);
      oscarFlow.processFull();
     
      /* Output time! */
      new Serializer(new FileOutputStream(new File(directory, "markedup.xml"))).write(oscarFlow.getInlineXML());
      safDoc.getRootElement().addAttribute(new Attribute("document", directory.getName()));
      new Serializer(new FileOutputStream(new File(directory, "saf.xml"))).write(oscarFlow.getSafXML());
      if(oscarFlow.getGeniaSAF() != null) {
        new Serializer(new FileOutputStream(new File(directory, "geniasaf.xml"))).write(oscarFlow.getGeniaSAF());       
      }
      if(oscarFlow.getRelationXML() != null) {
        new Serializer(new FileOutputStream(new File(directory, "relations.xml"))).write(oscarFlow.getRelationXML());       
      }
      if(oscarFlow.getDataXML() != null) {
        new Serializer(new FileOutputStream(new File(directory, "data.xml"))).write(oscarFlow.getDataXML());       
      }

      /* PubXML present? Then round-trip it */
      if(new File(directory, "pubxml-source.xml").exists()) {
        Builder b = new Builder();
        Document pubXML = b.build(new FileReader (new File(directory, "pubxml-source.xml")));
        Document convDoc = b.build(new File(directory, "conv.xml"));
        Document outDoc = PubXMLToSciXML.getAnnotatedPubXML(pubXML, oscarFlow.getInlineXML(), oscarFlow.getSourceXML(), convDoc);
        new Serializer(new FileOutputStream(new File(directory, "pubxml-annotated.xml"))).write(outDoc);
      }
      /* Write out custom files, if present */
      for(String filename : oscarFlow.getCustomOutputNames()) {
        //InputStream is = oscarFlow.customInputStream(filename);
        OutputStream os = new FileOutputStream(new File(directory, filename));
        /*byte[] buffer = new byte[1024];
        int i = 0;
        while ((i = is.read(buffer)) != -1) {
          os.write(buffer, 0, i);
        }
        is.close();
        os.close();*/
        oscarFlow.writeCustomeOutputToStream(filename, os);
        os.close();
      }
     
    } catch (Exception e) {
      e.printStackTrace();
View Full Code Here

    long start = System.currentTimeMillis();
   
    Document doc = null;
    try {
      doc = ToSciXML.fileToSciXML(file);
      OscarFlow oscarFlow = new OscarFlow(doc);
      oscarFlow.runFlow(flow);
      if (oscarFlow.getDataXML() != null) writeDoc(oscarFlow.getDataXML(), file.getName(), "data.xml");
      if (oscarFlow.getGeniaSAF() != null) writeDoc(oscarFlow.getGeniaSAF(), file.getName(), "genia.xml");
      if (oscarFlow.getInlineXML() != null) writeDoc(oscarFlow.getInlineXML(), file.getName(), "inline.xml");
      if (oscarFlow.getRelationXML() != null) writeDoc(oscarFlow.getRelationXML(), file.getName(), "relation.xml");
      if (oscarFlow.getSafXML() != null) writeDoc(oscarFlow.getSafXML(), file.getName(), "saf.xml");
      long time = (System.currentTimeMillis() - start)/1000;
      System.out.println("Finished " + file.getName() + " in " + time + " seconds");
    }
   
    catch (Exception e) {
View Full Code Here

  public static void main(String[] args) {
    try {
      String contents = FileUtils.readFileToString(new File("test.html"));
      SciXMLDocument doc = TextToSciXML.textToSciXML(HtmlCleaner
          .cleanHTML(contents));
      OscarFlow flow = new OscarFlow(doc);
      flow.runFlow("recognise resolve");
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
View Full Code Here

    inStr = "<wrap xmlns:z=\"http://foo.bar\">" + inStr + "</wrap>";
    Document doc = new Builder().build(inStr, "");
     
    Document sciXML = XSLTransform.toDocument(getXSLT().transform(doc));
   
    OscarFlow of = new OscarFlow(sciXML);
    of.processToSAF();
    Document saf = of.getSafXML();
    doc = SAFToInline.safToInline(saf, doc, false);
   
    return doc.getRootElement().getChild(0).toXML();
  }
View Full Code Here

TOP

Related Classes of uk.ac.cam.ch.wwmm.oscar3.recogniser.test.PatternRecogniserTest

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.