001 package org.maltparser.core.syntaxgraph.writer; 002 003 import java.io.OutputStream; 004 import java.io.OutputStreamWriter; 005 006 import org.maltparser.core.exception.MaltChainedException; 007 import org.maltparser.core.io.dataformat.DataFormatInstance; 008 import org.maltparser.core.syntaxgraph.TokenStructure; 009 /** 010 * 011 * 012 * @author Johan Hall 013 */ 014 public interface SyntaxGraphWriter { 015 /** 016 * Opens a file for writing 017 * 018 * @param fileName the file name of the file 019 * @param charsetName the name of the character encoding set 020 * @throws MaltChainedException 021 */ 022 public void open(String fileName, String charsetName) throws MaltChainedException; 023 /** 024 * Opens an output stream 025 * 026 * @param os an output stream 027 * @param charsetName the name of the character encoding set 028 * @throws MaltChainedException 029 */ 030 public void open(OutputStream os, String charsetName) throws MaltChainedException; 031 /** 032 * Cause the syntax graph writer to write the beginning of the file (such as header information) 033 * 034 * @throws MaltChainedException 035 */ 036 public void writeProlog() throws MaltChainedException; 037 /** 038 * Writes a sentence (token structure, dependency structure or/and phrase structure) 039 * 040 * @param syntaxGraph a syntax graph (token structure, dependency structure or/and phrase structure) 041 * @throws MaltChainedException 042 */ 043 public void writeSentence(TokenStructure syntaxGraph) throws MaltChainedException; 044 /** 045 * Writes the end of the file 046 * 047 * @throws MaltChainedException 048 */ 049 public void writeEpilog() throws MaltChainedException; 050 /** 051 * Returns the output data format instance 052 * 053 * @return the output data format instance 054 */ 055 public DataFormatInstance getDataFormatInstance(); 056 /** 057 * Sets the output data format instance 058 * 059 * @param dataFormatInstance an output data format instance 060 */ 061 public void setDataFormatInstance(DataFormatInstance dataFormatInstance); 062 /** 063 * Returns a string representation of the writer specific options. 064 * 065 * @return a string representation of the writer specific options. 066 */ 067 public String getOptions(); 068 /** 069 * Sets the writer specific options. 070 * 071 * @param optionString a string representation of the writer specific options 072 * @throws MaltChainedException 073 */ 074 public void setOptions(String optionString) throws MaltChainedException; 075 /** 076 * Closes the file or the output stream. 077 * 078 * @throws MaltChainedException 079 */ 080 public void close() throws MaltChainedException; 081 }