///////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2000 Jason Baldridge and Gann Bierner
// 
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
// 
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
// 
// You should have received a copy of the GNU Lesser General Public
// License along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
//////////////////////////////////////////////////////////////////////////////

 package opennlp.common.xml;

import java.io.*;

/**
 * A class for going from plain text to a roughly marked-up NLPDocument.
 *
 * @author      Jason Baldridge
 * @version     $Revision: 1.1 $, $Date: 2001/10/23 13:46:24 $
 */

public class RawToXml {

    public static PreProcessDocument process(File f) {
	try {
	    return process(new FileReader(f));
	} catch (IOException E) {
	    E.printStackTrace();
	    return null;
	}
    }
    public static PreProcessDocument process(InputStream i) {
	return process(new InputStreamReader(i));
    }

    public static PreProcessDocument process(Reader r) {
	String text = "";
	String par, read;
	
	try {
	    BufferedReader br = new BufferedReader(r);
	    read = br.readLine();

	    while (read != null) {
		par = "";
		
		while (read.equals("")) read = br.readLine();
		while (read != null && !read.equals("")) {
		    par += read;
		    read = br.readLine();
		}
		
		if (!par.equals(""))
		    text += "<PAR><SENT><TOK><LEX><![CDATA[" + par +
			"]]></LEX></TOK></SENT></PAR>";

	    }
	    
	    return new PreProcessDocument(text);
	    
	} catch (Exception E) {
	    System.out.println(E);
	    return null;
	}
	
    }

    public static PreProcessDocument process(String s) {
	return new PreProcessDocument(s);
    }

}

@@ -945,17 +945,16 @@
 //////%0A%0A
- 
 package 
@@ -1134,17 +1134,17 @@
 sion: 1.
-1
+2
  $, $Dat
@@ -1158,19 +1158,19 @@
 /10/
-23 13:46:24
+30 11:16:17
  $%0A 
@@ -1560,16 +1560,22 @@
 ring
+Buffer
  text = 
 %22%22;%0A
@@ -1570,18 +1570,36 @@
  text = 
-%22%22
+new StringBuffer(32)
 ;%0A%09Strin
@@ -1603,21 +1603,16 @@
 ring
- par,
  read;%0A%09
 %0A%09tr
@@ -1607,16 +1607,59 @@
  read;%0A%09
+StringBuffer chunk = new StringBuffer(16);%0A
 %0A%09try %7B%0A
@@ -1768,18 +1768,8 @@
 %7B%0A%09%09
-par = %22%22;%0A
 %09%09%0A%09
@@ -1870,19 +1870,26 @@
     
-par += 
+chunk.append(
 read
+)
 ;%0A%09%09
@@ -1927,43 +1927,98 @@
 %09%0A%09%09
-if (!par.equals(%22%22)
+// Don't think this is needed - jmb, joaoc%0A%09%09//if (chunk.length() %3E 0
 )%0A%09%09
+//
    
- 
 text
- += 
+.append(
 %22%3CPA
@@ -2049,20 +2049,42 @@
 TA%5B%22
- + par +%0A%09%09%09
+).append(chunk.toString()).append(
 %22%5D%5D%3E
@@ -2109,16 +2109,17 @@
 %3E%3C/PAR%3E%22
+)
 ;%0A%0A%09    
@@ -2161,20 +2161,32 @@
 ocument(
-text
+chunk.toString()
 );%0A%09    
@@ -2368,10 +2368,199 @@
 %0A    %7D%0A%0A
+    public static void main(String%5B%5D args)%7B%0A%09PreProcessDocument ppd = process(new File(args%5B0%5D));%0A%09// PreProcessDocument ppd = process(args%5B0%5D);%0A%09System.out.println(ppd.toString());%0A    %7D%0A%0A
 %7D%0A

replaced String with StringBuffer