Package uk.ac.cam.ch.wwmm.ptclib.scixml

Examples of uk.ac.cam.ch.wwmm.ptclib.scixml.SciXMLDocument


 
    paper.appendChild(makeNavElement("show"));
   
    Element body = new Element("BODY");
    Element div = new Element("DIV");
    SciXMLDocument doc = SciXMLDocument.makeFromDoc(new Document(paper));
    paper.appendChild(body);
    body.appendChild(div);
    div.appendChild("\n\n");
   
    return doc;
View Full Code Here


    resultsPaper.appendChild(makeNavElement("regtest"));
   
    resultsPaper.appendChild(resultsBody);
    resultsBody.appendChild(goodDiv);
    resultsBody.appendChild(failedDiv);
    SciXMLDocument resultsDoc = SciXMLDocument.makeFromDoc(new Document(resultsPaper));
   
    Element failedDivHeader = new Element("HEADER");
    failedDivHeader.appendChild("Regression");
    failedDiv.appendChild(failedDivHeader);
   
View Full Code Here

   
    editorPaper.appendChild(nav);
   
    editorPaper.appendChild(editorBody);
    editorBody.appendChild(editorDiv);
    SciXMLDocument editorDoc = SciXMLDocument.makeFromDoc(new Document(editorPaper));

    Element goodPara = (Element)doc.query("//snippet[@id='" + sid + "']").get(0).getParent();
   
    Nodes nn = goodPara.query(".|following-sibling::P");
   
View Full Code Here

   
    editorPaper.appendChild(nav);
   
    editorPaper.appendChild(editorBody);
    editorBody.appendChild(editorDiv);
    SciXMLDocument editorDoc = SciXMLDocument.makeFromDoc(new Document(editorPaper));

    Element goodPara = (Element)doc.query("//snippet[@id='" + sid + "']").get(0).getParent();
   
    Nodes nn = goodPara.query(".|following-sibling::P");
   
View Full Code Here

   
    editorPaper.appendChild(nav);
   
    editorPaper.appendChild(editorBody);
    editorBody.appendChild(editorDiv);
    SciXMLDocument editorDoc = SciXMLDocument.makeFromDoc(new Document(editorPaper));

    Nodes nn = doc.query("//snippet");
   
    List<String> testOpts = new ArrayList<String>();
    testOpts.add("A");
View Full Code Here

   
    editorPaper.appendChild(nav);
   
    editorPaper.appendChild(editorBody);
    editorBody.appendChild(editorDiv);
    SciXMLDocument editorDoc = SciXMLDocument.makeFromDoc(new Document(editorPaper));

    Nodes nn = doc.query("//snippet");
   
    for(int i=0;i<nn.size();i++) {   
      Element para = (Element)XOMTools.safeCopy(nn.get(i).getParent());
View Full Code Here

   
    editorPaper.appendChild(nav);
   
    editorPaper.appendChild(editorBody);
    editorBody.appendChild(editorDiv);
    SciXMLDocument editorDoc = SciXMLDocument.makeFromDoc(new Document(editorPaper));

    Nodes nn = doc.query("//snippet");

        for(int i=0;i<nn.size();i++) {   
      Element para = (Element)XOMTools.safeCopy(nn.get(i).getParent());
View Full Code Here

    for(int i=0;i<n.size();i++) {
      Element e = (Element)n.get(i);
      e.addAttribute(new Attribute("surface", e.getValue()));
    }
   
    SciXMLDocument inlineDoc = SciXMLDocument.makeFromDoc(new Builder().build(sourceFile));
    Document sourceDoc = (Document)inlineDoc.copy();
    PaperToScrapBook.importAnnotations(this, inlineDoc);
    new Serializer(new FileOutputStream(destFile)).write(inlineDoc);
    Document safDoc = InlineToSAF.extractSAFs(inlineDoc, sourceDoc, name);
    SciBorgPostProcess.postProcess(safDoc, false);
    SafTools.numberSaf(safDoc, "oscar", "o");
View Full Code Here

   
    editorPaper.appendChild(nav);
   
    editorPaper.appendChild(editorBody);
    editorBody.appendChild(editorDiv);
    SciXMLDocument editorDoc = SciXMLDocument.makeFromDoc(new Document(editorPaper));

    Element para = new Element((Element)doc.query("//snippet[@id='" + sid + "']").get(0).getParent());
    CharacterMarkup.markupCharacters(para, Oscar3Props.getInstance().scrapBookIEFix);   
    editorDiv.appendChild(para);   
   
    Nodes n = para.query("//ne");
    Element ne = (Element)XOMTools.safeCopy(n.get(Integer.parseInt(neid)));
   
    Element attrEd = new Element("attred");
    editorDiv.appendChild(attrEd);
    attrEd.appendChild(ne);
    attrEd.addAttribute(new Attribute("neid", neid));
    attrEd.addAttribute(new Attribute("sid", sid));
    for(int i=0;i<ne.getAttributeCount();i++) {
      Attribute a = ne.getAttribute(i);
      //if(a.getLocalName() == "type") continue;
      Element attr = new Element("attr");
      attr.addAttribute(new Attribute("name", a.getLocalName()));
      attr.appendChild(a.getValue());
      attrEd.appendChild(attr);
    }
   
    editorDoc.addServerProcessingInstructions();
   
    /*ProcessingInstruction pi = new ProcessingInstruction("xml-stylesheet", "type=\"text/xsl\" href=\"toHTMLJS.xsl\"");
    editorDoc.insertChild(pi, 0);
    pi = new ProcessingInstruction("host", Oscar3Props.getInstance().hostname + ":" + Oscar3Props.getInstance().port);
    editorDoc.insertChild(pi, 0);*/
 
View Full Code Here

        PaperToScrapBook.makeScrapBook(paperDoc, paperName);
        response.setContentType("text/plain");
        response.getWriter().printf("Paper %s added OK!", paperName);*/
      } else if(action.equals("show")) {
        response.setContentType("application/xml");
        SciXMLDocument doc = scrapBook.getDoc();
        doc.addServerProcessingInstructions();
        new Serializer(response.getOutputStream()).write(doc);
      } else if(action.equals("add")) {
        request.setCharacterEncoding("UTF-8");
        String fileno = request.getParameter("fileno");
        String html = request.getParameter("html");
        html = URLDecoder.decode(html, "UTF-8");
        response.setContentType("text/html");
        scrapBook.addScrap(html, fileno);
        PrintWriter out = response.getWriter();
        out.println("<html><head><title>Foo</title></head>");
        out.println("<body>");
        out.println("<script>var t=setTimeout('window.close()', 500)</script>");
        out.println("Added OK!");
        out.println("</body></html>");
      } else if(action.equals("delete")) {
        response.setContentType("text/plain");
        String sid = request.getParameter("sid");
        scrapBook.deleteScrap(sid);
        response.getWriter().println("snippet deleted OK");
      } else if(action.equals("deletebook")) {
        scrapBooks.remove(scrapBook.getName());
        scrapBook.delete();
        response.setContentType("text/plain");
        response.getWriter().printf("Scrapbook deleted OK!");
        scrapBook = null;
      } else if(action.equals("clear")) {
        scrapBook.clearAnnotations();
        response.setContentType("application/xml");
        SciXMLDocument doc = scrapBook.getDoc();
        doc.addServerProcessingInstructions();
        new Serializer(response.getOutputStream()).write(doc);       
      } else if(action.equals("autoannotate")) {
        scrapBook.autoAnnotate();
        response.setContentType("application/xml");
        SciXMLDocument doc = scrapBook.getDoc();
        doc.addServerProcessingInstructions();
        new Serializer(response.getOutputStream()).write(doc);       
      } else if(action.equals("autoannotatereactions")) {
        scrapBook.autoAnnotateReactions();
        response.setContentType("application/xml");
        SciXMLDocument doc = scrapBook.getDoc();
        doc.addServerProcessingInstructions();
        new Serializer(response.getOutputStream()).write(doc);       
      } else if(action.equals("regtest")) {
        response.setContentType("application/xml");
        SciXMLDocument doc = scrapBook.regtest().getDoc();
        doc.addServerProcessingInstructions();
        new Serializer(response.getOutputStream()).write(doc);       
      } else if(action.equals("index")) {
        String s = rg.getString("scrapbookindex.html");
        StringBuffer links = new StringBuffer();

        File [] fileArr = fileRoot.listFiles();
        for(int i=0;i<fileArr.length;i++) {
          if(fileArr[i].isDirectory()) {
            String sbn = fileArr[i].getName();
            links.append("<li><a href=\"ScrapBook?action=show&name=" + sbn);
            links.append("\">" + sbn + "</a>");
            links.append(" ");
            links.append("<a href=\"ScrapBook?action=deletebook&name=" + sbn);
            links.append("\">" + "Delete!" + "</a>");           
            links.append(" ");
            links.append("<a href=\"ScrapBook?action=selectedit&type=subtype&name=" + sbn);
            links.append("\">" + "Edit subtypes" + "</a>");           
            links.append(" ");
            links.append("</li>\n");
          }
        }
        s = s.replace("LINKS GO HERE", links.toString());
        response.setContentType("text/html");
        response.getWriter().print(s);
      } else if(action.equals("requestbooleanedit")) {
        String s = rg.getString("booleanedit.html");
        s = s.replace("PAPERNAME", name);
        response.setContentType("text/html");
        response.getWriter().print(s);       
      } else if(action.equals("regtests")) {
        //ToughWords.deTrain(10);
        response.setContentType("text/plain");
        PrintWriter out = response.getWriter();       
        File [] fileArr = fileRoot.listFiles();
        ScoreStats grandTotal = new ScoreStats();
        for(int i=0;i<fileArr.length;i++) {
          if(fileArr[i].isDirectory()) {
            String sbn = fileArr[i].getName();
            setScrapBook(sbn);
            ScoreStats score = scrapBook.regtest().getScoreStats();
            out.printf("%s %s\n", sbn, score.getPrecAndRecallString());
            grandTotal.addScoreStats(score);
            out.flush();
          }
        }
        out.println("Grand Total:");
        out.println(grandTotal.getPrecAndRecallString());
      } else if(action.equals("edit")) {
        String sid = request.getParameter("sid");
        SciXMLDocument editor = scrapBook.getEditor(sid);
        editor.addServerProcessingInstructions();
        response.setContentType("application/xml");
        new Serializer(response.getOutputStream()).write(editor);       
      } else if(action.equals("reledit")) {
        String sid = request.getParameter("sid");
        SciXMLDocument editor = scrapBook.getRelEditor(sid);
        editor.addServerProcessingInstructions();
        response.setContentType("application/xml");
        new Serializer(response.getOutputStream()).write(editor);       
      } else if(action.equals("selectedit")) {
        String editType = request.getParameter("type");
        SciXMLDocument editor = scrapBook.getSelectorEditor(editType);
        editor.addServerProcessingInstructions();
        response.setContentType("application/xml");
        new Serializer(response.getOutputStream()).write(editor);       
      } else if(action.equals("selecteditsubmit")) {
        if(Oscar3Props.getInstance().verbose) System.out.println("Editing via selects");
        String editType = request.getParameter("type");
        if(Oscar3Props.getInstance().verbose) System.out.println("Editing: editType");
        scrapBook.updateToSelections(request.getParameterMap(), editType);
        if(Oscar3Props.getInstance().verbose) System.out.println("Done: updateToSelections");
        response.setContentType("text/html");
        PrintWriter out = response.getWriter();
        out.println(editType + "s changed OK!");
        out.println("<a href='ScrapBook'>Back to Index</a>");
      } else if(action.equals("booleanedit")) {
        SciXMLDocument editor = scrapBook.getBooleanAttrEditor(request.getParameter("attrName"));
        editor.addServerProcessingInstructions();
        response.setContentType("application/xml");
        new Serializer(response.getOutputStream()).write(editor);       
      } else if(action.equals("booleaneditsubmit")) {
        scrapBook.submitBooleans(request.getParameterMap(), request.getParameter("attrName"));
        response.setContentType("text/plain");
        response.getWriter().println("Booleans submitted OK!");
      } else if(action.equals("textfieldedit")) {
        String editType = request.getParameter("type");
        SciXMLDocument editor = scrapBook.getTextFieldEditor(editType);
        editor.addServerProcessingInstructions();
        response.setContentType("application/xml");
        new Serializer(response.getOutputStream()).write(editor);       
      } else if(action.equals("delne")) {
        String sid = request.getParameter("sid");
        String neid = request.getParameter("neid");
        scrapBook.deleteNe(sid, neid);
        response.setContentType("text/plain");
        response.getWriter().println("Removed ne OK!");
      } else if(action.equals("addne")) {
        String sid = request.getParameter("sid");
        String start = request.getParameter("start");
        String end = request.getParameter("end");
        String type = request.getParameter("type");
        scrapBook.addNe(sid, start, end, type);
        response.setContentType("text/plain");
        response.getWriter().println("Added ne OK!");
      } else if(action.equals("movene")) {
        String sid = request.getParameter("sid");
        String start = request.getParameter("start");
        String end = request.getParameter("end");
        String neid = request.getParameter("neid");
        scrapBook.moveNe(sid, start, end, neid);
        response.setContentType("text/plain");
        response.getWriter().println("Moved ne OK!");
      } else if(action.equals("makepaper")) {
        SciXMLDocument doc = scrapBook.makePaper();
        doc.addServerProcessingInstructions();
        response.setContentType("application/xml");
        new Serializer(response.getOutputStream()).write(doc);               
      } else if(action.equals("makepubxmlpaper")) {
        Document doc = scrapBook.makePubXMLPaper();
        response.setContentType("application/xml");
        new Serializer(response.getOutputStream()).write(doc);               
      } else if(action.equals("attred")) {
        String sid = request.getParameter("sid");
        String neid = request.getParameter("neid");
        SciXMLDocument editor = scrapBook.getAttributeEditor(sid, neid);
        editor.addServerProcessingInstructions();
        response.setContentType("application/xml");
        new Serializer(response.getOutputStream()).write(editor);               
      } else if(action.equals("edattr")) {
        String sid = request.getParameter("sid");
        String neid = request.getParameter("neid");
View Full Code Here

TOP

Related Classes of uk.ac.cam.ch.wwmm.ptclib.scixml.SciXMLDocument

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.