001 package org.maltparser.core.syntaxgraph.reader; 002 003 import java.io.InputStream; 004 import java.io.InputStreamReader; 005 import java.net.URL; 006 007 import org.maltparser.core.exception.MaltChainedException; 008 import org.maltparser.core.io.dataformat.DataFormatInstance; 009 import org.maltparser.core.syntaxgraph.TokenStructure; 010 011 /** 012 * 013 * 014 * @author Johan Hall 015 */ 016 public interface SyntaxGraphReader { 017 /** 018 * Opens a file for read only 019 * 020 * @param fileName the file name of the file 021 * @param charsetName the name of the character encoding set 022 * @throws MaltChainedException 023 */ 024 public void open(String fileName, String charsetName) throws MaltChainedException; 025 /** 026 * Opens an URL for read only 027 * 028 * @param url the URL of the resource 029 * @param charsetName the name of the character encoding set 030 * @throws MaltChainedException 031 */ 032 public void open(URL url, String charsetName) throws MaltChainedException; 033 /** 034 * Opens an input stream 035 * 036 * @param is an input stream 037 * @param charsetName the name of the character encoding set 038 * @throws MaltChainedException 039 */ 040 public void open(InputStream is, String charsetName) throws MaltChainedException; 041 /** 042 * Opens an input stream reader 043 * 044 * @param isr an input stream reader 045 * @throws MaltChainedException 046 */ 047 public void open(InputStreamReader isr) throws MaltChainedException; 048 /** 049 * Cause the syntax graph reader to read the beginning of the file (such as header information) 050 * 051 * @throws MaltChainedException 052 */ 053 public void readProlog() throws MaltChainedException; 054 055 /** 056 * Reads a sentence (token structure, dependency structure or/and phrase structure) 057 * 058 * @param syntaxGraph a syntax graph (token structure, dependency structure or/and phrase structure) 059 * @return true if there is more sentences to be processed, otherwise false. 060 * @throws MaltChainedException 061 */ 062 public boolean readSentence(TokenStructure syntaxGraph) throws MaltChainedException; 063 /** 064 * Reads the end of the file, after all sentences have been processed, 065 * 066 * @throws MaltChainedException 067 */ 068 public void readEpilog() throws MaltChainedException; 069 /** 070 * Returns the current number of the sentence. 071 * 072 * @return the current number of the sentence. 073 * @throws MaltChainedException 074 */ 075 public int getSentenceCount() throws MaltChainedException; 076 /** 077 * Returns the input data format instance 078 * 079 * @return the input data format instance 080 */ 081 public DataFormatInstance getDataFormatInstance(); 082 /** 083 * Sets the input data format instance 084 * 085 * @param dataFormatInstance an input data format instance 086 */ 087 public void setDataFormatInstance(DataFormatInstance dataFormatInstance); 088 /** 089 * Returns a string representation of the reader specific options. 090 * 091 * @return a string representation of the reader specific options. 092 */ 093 public String getOptions(); 094 /** 095 * Sets the reader specific options. 096 * 097 * @param optionString a string representation of the reader specific options 098 * @throws MaltChainedException 099 */ 100 public void setOptions(String optionString) throws MaltChainedException; 101 /** 102 * Closes the file or the input stream. 103 * 104 * @throws MaltChainedException 105 */ 106 public void close() throws MaltChainedException; 107 }