Examples of OscarFlow


Examples of uk.ac.cam.ch.wwmm.oscar3.flow.OscarFlow

               
        }
       
        public ARTSciXMLDocument autoAnnotate2() throws Exception {
                clearAnnotations2();
                OscarFlow oscarFlow = new OscarFlow(doc2);
                oscarFlow.runFlow("recognise inline");
                doc2 = ARTSciXMLDocument.makeFromDoc(oscarFlow.getInlineXML());
                writeMode2Doc(doc2);
                return doc2;
        }
View Full Code Here

Examples of uk.ac.cam.ch.wwmm.oscar3.flow.OscarFlow

        out.close();
        return;
      }
      /* Process the document */     

      OscarFlow oscarFlow = new OscarFlow(plainDoc);
     
      if(request.getParameter("flowcommand") != null &&
          request.getParameter("flowcommand").trim().length() > 0) {
        oscarFlow.runFlow(request.getParameter("flowcommand"));
      } else if(outputMode.equals("data")) {
        oscarFlow.parseData();
      } else {
        oscarFlow.processLite();
      }
      if(outputMode.equals("default") && request.getParameter("flowcommand") != null &&
          !request.getParameter("flowcommand").toLowerCase().contains("inline")) {
        outputMode = "saf";
      }
     
      if(outputMode.equalsIgnoreCase("custom")) {
        String name = request.getParameter("name");
        if(name.endsWith(".xml")) {
          response.setContentType("application/xml");
          response.setCharacterEncoding("UTF-8");         
        } else if(name.endsWith(".htm") || name.endsWith(".html")) {
          response.setContentType("text/html");
          response.setCharacterEncoding("UTF-8");
        } else {
          response.setContentType("text/plain");
          response.setCharacterEncoding("UTF-8");
        }
      } else {
        response.setContentType("application/xml");
        response.setCharacterEncoding("UTF-8");
      }
     
      OutputStream out = response.getOutputStream();
      if(outputMode.equalsIgnoreCase("saf")) {
        new Serializer(out).write(oscarFlow.getSafXML());       
      } else if(outputMode.equalsIgnoreCase("data")) {
        new Serializer(out).write(oscarFlow.getDataXML());       
      } else if(outputMode.equalsIgnoreCase("genia")) {
        new Serializer(out).write(oscarFlow.getGeniaSAF());
      } else if(outputMode.equalsIgnoreCase("relation")) {
        new Serializer(out).write(oscarFlow.getRelationXML());
      } else if(outputMode.equalsIgnoreCase("custom")) {
        String name = request.getParameter("name");
        oscarFlow.writeCustomeOutputToStream(name, out);
      } else {
        // default to markedup
        doc = SciXMLDocument.makeFromDoc(oscarFlow.getInlineXML());
        doc.addServerProcessingInstructions();
        new Serializer(out).write(doc);
        out.close();
      }
     
View Full Code Here

Examples of uk.ac.cam.ch.wwmm.oscar3.flow.OscarFlow

   
    String s = rg.getString("testcard.txt");
    assertTrue("Have testcard string", s != null && s.length() > 0);
    Document doc = TextToSciXML.textToSciXML(s);
    assertTrue("Have SciXML document", doc != null);
    OscarFlow flow = new OscarFlow(doc);
    flow.runFlow("recognise resolve numbersaf inline data");
    assertNotNull("Have source XML", flow.getSourceXML());
    assertNotNull("Have inline XML", flow.getInlineXML());
    assertNotNull("Have SAF XML", flow.getSafXML());
    assertNotNull("Have data XML", flow.getDataXML());
   
    SAFTester tester = new SAFTester(flow.getSafXML());
    assertTrue("At least one annot", tester.atLeastOne(new AllElementsFilter()));
    assertTrue("Null filter gives no annots", tester.no(new NoElementsFilter()));
    assertTrue("At least one annot", tester.atLeastOne(new NoElementsFilter().setNegate(true)));
    assertTrue("Null filter gives no annots", tester.no(new AllElementsFilter().setNegate(true)));
    assertTrue("At least one annot", tester.atLeastOne(new AllElementsFilter().chain(new AllElementsFilter())));
View Full Code Here

Examples of uk.ac.cam.ch.wwmm.oscar3.flow.OscarFlow

  }
 
  public void testTestCard2() throws Exception {
    String s = rg.getString("testcard2.txt");
    Document doc = TextToSciXML.textToSciXML(s);
    OscarFlow flow = new OscarFlow(doc);
    flow.runFlow("recognise resolve");
    assertNotNull("Have SAF XML", flow.getSafXML());
   
    SAFTester tester = new SAFTester(flow.getSafXML());
    assertTrue("Has a CM", tester.atLeastOne(new TypeFilter("CM")));
    assertTrue("Has an ONT", tester.atLeastOne(new TypeFilter("ONT")));
   
    assertTrue("Has a single-word ONT", tester.atLeastOne(new TypeFilter("ONT").chain(new SurfaceRegexFilter("[a-z]+"))));
    assertTrue("Has a multi-word ONT", tester.atLeastOne(new TypeFilter("ONT").chain(new SurfaceRegexFilter("([a-z]+ )+[a-z]+"))));
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.