// Path: src/io/Preface.java
// public class Preface {
// 	public static void readPreface(BufferedReader in) throws IOException {
// 		String line = in.readLine();
// 
// 		if (line == null || line.charAt(0) != '#') {
// 			throw new IllegalArgumentException("File does not start with the mandatory preface.");
// 		}
// 
// 		while ((line = in.readLine()) != null) {
// 			if (line.isEmpty()) {
// 				break;
// 			}
// 			if (line.charAt(0) != '#') {
// 				throw new IllegalArgumentException("Uncommented line within preface.");
// 			}
// 		}
// 	}
// 
// 	public static void printPreface(PrintWriter out) {
// 		out.println("# mandatory preface");
// 		out.println("# mandatory preface");
// 		out.println();
// 	}
// }


import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.HashMap;
import io.Preface;
package model;



public class Lexicon {
	private HashMap<String,Integer> lexicon;
	// map from words and pos as strings to IDs

	public Lexicon(String file) throws IOException {
		this.lexicon = new HashMap<String,Integer>();
		readWordPosFile(file);
	}

	public int getID(String word) {
		// returns -1 if word not in lexicon
		Integer ID = lexicon.get(word);
		if (ID == null) {
			return -1;
		} else {
			return ID;
		}
	}

	/*
	 * not assuming an empty intersection between words and pos (ie word and pos
	 * can get the same id eg punctuation); this is fine since the feature types
	 * distinguish word and pos
	 */
	private void readWordPosFile(String file) throws IOException {
		try ( BufferedReader in = new BufferedReader(new FileReader(file)) ) {
// Path: src/io/Preface.java
// public class Preface {
// 	public static void readPreface(BufferedReader in) throws IOException {
// 		String line = in.readLine();
// 
// 		if (line == null || line.charAt(0) != '#') {
// 			throw new IllegalArgumentException("File does not start with the mandatory preface.");
// 		}
// 
// 		while ((line = in.readLine()) != null) {
// 			if (line.isEmpty()) {
// 				break;
// 			}
// 			if (line.charAt(0) != '#') {
// 				throw new IllegalArgumentException("Uncommented line within preface.");
// 			}
// 		}
// 	}
// 
// 	public static void printPreface(PrintWriter out) {
// 		out.println("# mandatory preface");
// 		out.println("# mandatory preface");
// 		out.println();
// 	}
// }


// Path: src/model/Lexicon.java
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.HashMap;
import io.Preface;

package model;



public class Lexicon {
	private HashMap<String,Integer> lexicon;
	// map from words and pos as strings to IDs

	public Lexicon(String file) throws IOException {
		this.lexicon = new HashMap<String,Integer>();
		readWordPosFile(file);
	}

	public int getID(String word) {
		// returns -1 if word not in lexicon
		Integer ID = lexicon.get(word);
		if (ID == null) {
			return -1;
		} else {
			return ID;
		}
	}

	/*
	 * not assuming an empty intersection between words and pos (ie word and pos
	 * can get the same id eg punctuation); this is fine since the feature types
	 * distinguish word and pos
	 */
	private void readWordPosFile(String file) throws IOException {
		try ( BufferedReader in = new BufferedReader(new FileReader(file)) ) {
			Preface.readPreface(in);