se.lth.cs.nlp.nlputils.deptree
Class ImportMalt

java.lang.Object
  extended by se.lth.cs.nlp.nlputils.deptree.ImportMalt

public class ImportMalt
extends Object

Factory class that reads a dependency graph encoded in the MALT-XML format.

Author:
Richard Johansson (richard@cs.lth.se)

Method Summary
static void handleGraphs(InputSource is, Procedure<DepGraph> callback)
          Reads dependency graphs from an InputSource and calls a callback for each graph.
static void handleGraphsFromFile(String fn, Procedure<DepGraph> callback)
          Reads dependency graphs from a file and calls a callback for each graph.
static List<DepGraph> importGraphsFromFile(String fn)
          Returns a list of dependency graphs read from a file.
static List<DepGraph> importGraphsFromString(String s)
          Returns a list of dependency graphs given an XML string.
static void main(String[] argv)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

importGraphsFromString

public static List<DepGraph> importGraphsFromString(String s)
                                             throws SAXException
Returns a list of dependency graphs given an XML string. WARNING: XML shouldn't be put into a Java string -- preferably use importGraphsFromFile instead.

Parameters:
s - the XML string.
Returns:
the list of dependency graphs.
Throws:
SAXException - if the XML is invalid.

importGraphsFromFile

public static List<DepGraph> importGraphsFromFile(String fn)
                                           throws SAXException,
                                                  IOException
Returns a list of dependency graphs read from a file.

Parameters:
fn - the file name.
Returns:
the list of dependency graphs.
Throws:
SAXException - if the XML is invalid.
IOException - if there was an IO problem.

handleGraphs

public static void handleGraphs(InputSource is,
                                Procedure<DepGraph> callback)
                         throws SAXException,
                                IOException
Reads dependency graphs from an InputSource and calls a callback for each graph.

Parameters:
is - the input source.
callback - the callback.
Throws:
SAXException - if the XML was invalid.
IOException - if there was an IO problem.

handleGraphsFromFile

public static void handleGraphsFromFile(String fn,
                                        Procedure<DepGraph> callback)
                                 throws IOException,
                                        SAXException
Reads dependency graphs from a file and calls a callback for each graph.

Parameters:
fn - the file.
callback - the callback.
Throws:
SAXException - if the XML was invalid.
IOException - if there was an IO problem.

main

public static void main(String[] argv)