Package edu.stanford.nlp.pipeline

Examples of edu.stanford.nlp.pipeline.CoreNLPProtos$Document


    @Test
    public void test_HighSurrogateAttPairDecimal() throws JDOMException, IOException, XMLStreamException {
      SAXBuilder builder = new SAXBuilder();
      builder.setExpandEntities(true);
      Document doc = builder.build(new StringReader("<?xml version=\"1.0\"?><root att=\"&#x10000; &#65536;\" />"));
      Format format = Format.getCompactFormat().setEncoding("ISO-8859-1");
      StAXStreamOutputter outputter = new StAXStreamOutputter(format);
      ByteArrayOutputStream baos = new ByteArrayOutputStream();
      XMLStreamWriter xsw = soutfactory.createXMLStreamWriter(baos, "ISO-8859-1");
      outputter.output(doc, xsw);
View Full Code Here


    // Construct a raw surrogate pair character and confirm it outputs hex escaped
    @Test
    public void test_RawSurrogatePair() throws JDOMException, IOException, XMLStreamException {
      SAXBuilder builder = new SAXBuilder();
      builder.setExpandEntities(true);
      Document doc = builder.build(new StringReader("<?xml version=\"1.0\"?><root>\uD800\uDC00</root>"));
      Format format = Format.getCompactFormat().setEncoding("ISO-8859-1");
      StAXStreamOutputter outputter = new StAXStreamOutputter(format);
      ByteArrayOutputStream baos = new ByteArrayOutputStream();
      XMLStreamWriter xsw = soutfactory.createXMLStreamWriter(baos, "ISO-8859-1");
      outputter.output(doc, xsw);
View Full Code Here

    // Construct a raw surrogate pair character and confirm it outputs hex escaped, when UTF-8 too
    @Test
    public void test_RawSurrogatePairUTF8() throws JDOMException, IOException, XMLStreamException {
      SAXBuilder builder = new SAXBuilder();
      builder.setExpandEntities(true);
      Document doc = builder.build(new StringReader("<?xml version=\"1.0\"?><root>\uD800\uDC00</root>"));
      Format format = Format.getCompactFormat().setEncoding("UTF-8");
      StAXStreamOutputter outputter = new StAXStreamOutputter(format);
      StringWriter baos = new StringWriter();
      XMLStreamWriter xsw = soutfactory.createXMLStreamWriter(baos);
      outputter.output(doc, xsw);
View Full Code Here

    // Construct illegal XML and check if the parser notices
    @Test
    public void test_ErrorSurrogatePair() throws JDOMException, IOException {
      SAXBuilder builder = new SAXBuilder();
      builder.setExpandEntities(true);
      Document doc = builder.build(new StringReader("<?xml version=\"1.0\"?><root></root>"));
      try {
        doc.getRootElement().setText("\uD800\uDBFF");
        fail("Illegal surrogate pair should have thrown an exception");
      }
      catch (IllegalDataException e) {
        // do nothing
      } catch (Exception e) {
View Full Code Here

    // Manually construct illegal XML and make sure the outputter notices
    @Test
    public void test_ErrorSurrogatePairOutput() throws JDOMException, IOException, XMLStreamException {
      SAXBuilder builder = new SAXBuilder();
      builder.setExpandEntities(true);
      Document doc = builder.build(new StringReader("<?xml version=\"1.0\"?><root></root>"));
      Text t = new UncheckedJDOMFactory().text("\uD800\uDBFF");
      doc.getRootElement().setContent(t);
      Format format = Format.getCompactFormat().setEncoding("ISO-8859-1");
      StAXStreamOutputter outputter = new StAXStreamOutputter(format);
      ByteArrayOutputStream baos = new ByteArrayOutputStream();
      XMLStreamWriter xsw = soutfactory.createXMLStreamWriter(baos);
      try {
View Full Code Here

         
          char[] chars = expect.toCharArray();
          CharArrayReader car = new CharArrayReader(chars);
          XMLStreamReader xsr = sinfactory.createXMLStreamReader(car);
         
      Document backagain = sbuilder.build(xsr);
      xsr.close();
     
      // get a String representation of the round-trip.
        if (backagain.hasRootElement()) {
          normalizeAttributes(backagain.getRootElement());
        }
        StringWriter swb = new StringWriter();
        xsw = soutfactory.createXMLStreamWriter(swb);
      xout.output(backagain, xsw);
      String actual = swb.toString();
View Full Code Here

    }
    }
   
  @Test
  public void testRTOutputDocumentSimple() {
    Document doc = new Document(new Element("root"));
    roundTripDocument(doc);
  }
View Full Code Here

    @Test
  @Ignore
  // TODO
    public void testRTOutputDocumentFull() {
      Document doc = new Document();
      DocType dt = new DocType("root");
      dt.setInternalSubset(" ");
      doc.addContent(dt);
      doc.addContent(new Comment("This is a document"));
      doc.addContent(new ProcessingInstruction("jdomtest", ""));
      Element e = new Element("root");
      e.addContent(new EntityRef("ref"));
      doc.addContent(e);
      roundTripDocument(doc);
    }
View Full Code Here

      roundTripDocument(doc);
    }
   
    @Test
    public void testOutputDocumentRootAttNS() {
      Document doc = new Document();
      Element e = new Element("root");
      e.setAttribute(new Attribute("att", "val", Namespace.getNamespace("ans", "mynamespace")));
      doc.addContent(e);
      roundTripDocument(doc);
    }
View Full Code Here

   
    @Test
    public void testOutputDocumentAttributes() {
      Element emt = new Element("root");
      emt.setAttribute("att", "val");
    Document doc = new Document(emt);
    roundTripDocument(doc);
    }
View Full Code Here

TOP

Related Classes of edu.stanford.nlp.pipeline.CoreNLPProtos$Document

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.