001 /* 002 * Represents the Propbank itself, and reads in the file prop-all.idx. 003 */ 004 005 package edu.upenn.cis.propbank_shen; 006 007 import java.io.*; 008 import java.util.*; 009 010 /** 011 * This class encapsulates the actual Propbank annotation file as modified 012 * by Libin Shen. 013 * 014 * @author Lucas Champollion 015 */ 016 public class Propbank extends HashMap { 017 018 019 /** 020 * Creates a new instance of Propbank, using the default location 021 * as indicated in (@link PBConfig}. 022 */ 023 public Propbank() { 024 025 this(PBConfig.PropBankFile()); 026 027 } 028 029 /** 030 * Creates a new instance of Propbank from the file location indicated 031 * (e.g. <code>"/usr/local/propbank/prop-all.idx"</code>). 032 * @param location a path to Libin Shen's Propbank file 033 */ 034 public Propbank(String location) { 035 try { 036 037 BufferedReader br = new BufferedReader(new FileReader(location)); 038 039 String s; 040 Annotation current; 041 PASLoc currentLocation; 042 System.out.print("Reading in Propbank..."); 043 int counter=0; 044 while (br.ready()) { 045 counter++; 046 s = br.readLine(); 047 current = new Annotation(s); 048 currentLocation = current.getPASLoc(); 049 this.put(currentLocation, current); 050 } 051 System.out.println("done. ("+counter+" entries)"); 052 } catch (FileNotFoundException ex) { 053 ex.printStackTrace(); 054 } catch (IOException ex) { 055 ex.printStackTrace(); 056 } catch (CorruptDataException ex) { 057 ex.printStackTrace(); 058 } 059 060 if (this.isEmpty()) throw new RuntimeException(); 061 062 } 063 064 }