sem.graphreader
Class RaspGraphReader

java.lang.Object
  extended by sem.graphreader.RaspGraphReader
All Implemented Interfaces:
GraphReader

public class RaspGraphReader
extends java.lang.Object
implements GraphReader

Graph reader for the default RASP format.

The RASP toolkit: http://ilexir.co.uk/2011/open-source-rasp-release/

The small files were parsed with: ./rasp.sh -m -p'-ogi -n10'

The large file was parsed with: ./rasp.sh -m -p'-og'


Field Summary
static java.util.List<java.lang.String> grsWithInitialGr
           
static java.util.List<java.lang.String> grsWithSubtype
           
 
Constructor Summary
RaspGraphReader(java.lang.String inputPath, boolean getAllParses)
           
 
Method Summary
 void close()
          Close the reader.
 boolean hasNext()
          Check whether there are more graphs available.
static void main(java.lang.String[] args)
           
 Graph next()
          Get the next graph from the corpus.
 java.util.ArrayList<Graph> nextSentence()
          Read a sentence from the corpus.
static java.util.LinkedHashMap<java.lang.String,java.lang.String> parseGr(java.lang.String line, boolean simpleEdgeFormat)
          Parses a line that represents a GR and return a LinkedHashMap with the arguments.
static java.util.LinkedHashMap<java.lang.String,java.lang.String> parseLabel(java.lang.String label)
          Parses a string that represents a token/lemma.
 void reset()
          Reset the whole reading process to the beginning.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

grsWithSubtype

public static java.util.List<java.lang.String> grsWithSubtype

grsWithInitialGr

public static java.util.List<java.lang.String> grsWithInitialGr
Constructor Detail

RaspGraphReader

public RaspGraphReader(java.lang.String inputPath,
                       boolean getAllParses)
                throws GraphFormatException
Throws:
GraphFormatException
Method Detail

parseLabel

public static java.util.LinkedHashMap<java.lang.String,java.lang.String> parseLabel(java.lang.String label)
                                                                             throws GraphFormatException
Parses a string that represents a token/lemma. It is designed to handle formats: lemma+suffix:id_POS, lemma+suffix:id, lemma. For example: algorithm+s:6_NOUN, algorithm+s:6_NOUN, algorithms Returns a LinkedHashMap with four fields: lemma, suffix, index, pos

Parameters:
label -
Returns:
Throws:
GraphFormatException

parseGr

public static java.util.LinkedHashMap<java.lang.String,java.lang.String> parseGr(java.lang.String line,
                                                                                 boolean simpleEdgeFormat)
                                                                          throws GraphFormatException
Parses a line that represents a GR and return a LinkedHashMap with the arguments. The hashmap has five keys: type, subtype, head, dependent, initialgr.

Parameters:
line -
Returns:
Throws:
GraphFormatException

hasNext

public boolean hasNext()
Check whether there are more graphs available.

Specified by:
hasNext in interface GraphReader
Returns:
True if there are more graphs available.

next

public Graph next()
           throws GraphFormatException
Get the next graph from the corpus.

Specified by:
next in interface GraphReader
Returns:
The next graph.
Throws:
GraphFormatException

nextSentence

public java.util.ArrayList<Graph> nextSentence()
                                        throws GraphFormatException
Read a sentence from the corpus. This returns a list of graphs if getAllParses is set to true.

Specified by:
nextSentence in interface GraphReader
Returns:
List of graphs
Throws:
GraphFormatException

reset

public void reset()
           throws GraphFormatException
Reset the whole reading process to the beginning.

Specified by:
reset in interface GraphReader
Throws:
GraphFormatException

close

public void close()
Close the reader.

Specified by:
close in interface GraphReader

main

public static void main(java.lang.String[] args)