001 package edu.upenn.cis.propbank_shen; 002 003 import java.io.*; 004 005 /** 006 This represents the overall "form" of the inflection. We note 007 whether each instance is an Infinitive, a gerund, a participle, 008 or in regular (finite, full) form. 009 010 <p> 011 Sometimes, no form is specified because this annotation isn't 012 very complete, so we have NoForm as well. 013 014 @author Scott Cotton 015 @see edu.upenn.cis.propbank_shen.Inflection 016 */ 017 public final class InflForm { 018 019 private String srep; 020 021 /** use a private constructor so that only static members 022 can be referenced. This helps us emulate an enumeration */ 023 private InflForm(String s) {srep = s;} 024 025 public static final InflForm Infinitive = new InflForm("i"); 026 public static final InflForm Gerund = new InflForm("g"); 027 public static final InflForm Participle = new InflForm("p"); 028 public static final InflForm Full = new InflForm("v"); 029 public static final InflForm NoForm = new InflForm("-"); 030 031 public String toString() { return srep; } 032 033 /** 034 return the "form" inflectional information from a string. 035 If the string doesn't make sense, print an error and 036 return the default "NoForm". 037 038 @return an InflForm instance 039 */ 040 public static InflForm ofString(String s) 041 { 042 if (s.equals("i")) { return InflForm.Infinitive; } 043 else if (s.equals("g")) { return InflForm.Gerund; } 044 else if (s.equals("p")) { return InflForm.Participle; } 045 else if (s.equals("v")) { return InflForm.Full; } 046 else if (s.equals("-")) { return InflForm.NoForm; } 047 else { 048 System.err.println("invalid string for inflection.form: " 049 + s 050 + ", defaulting to NoForm"); 051 return InflForm.NoForm; 052 } 053 } 054 }