001 package edu.upenn.cis.propbank_shen; 002 003 import java.io.*; 004 005 /** 006 This class represents the voice part of the inflection of 007 a verb. A voice is either active or passive or "NoVoice" 008 in the case that it just hasn't been specified or doesn't 009 make sense, such as when the form is infinitival. 010 011 @author Scott Cotton 012 @see Inflection 013 */ 014 public final class InflVoice { 015 016 private String srep; 017 /** use a private constructor so that only static members 018 can be referenced. This helps us emulate an enumeration */ 019 private InflVoice(String s) {srep = s;} 020 021 /** the active inflection */ 022 public static final InflVoice Active = new InflVoice("a"); 023 /** the passive inflection */ 024 public static final InflVoice Passive = new InflVoice("p"); 025 /** none specified */ 026 public static final InflVoice NoVoice = new InflVoice("-"); 027 028 /** convert the voide to a string */ 029 public String toString() { return srep; } 030 031 /** convert a string to a InflVoice instance */ 032 public static InflVoice ofString(String s) 033 { 034 if (s.equals("a")) { return InflVoice.Active; } 035 else if (s.equals("p")) { return InflVoice.Passive; } 036 else if (s.equals("-")) { return InflVoice.NoVoice; } 037 else { 038 System.err.println("invalid string for inflection.voice: " 039 + s 040 + ", defaulting to NoVoice."); 041 return InflVoice.NoVoice; 042 } 043 } 044 }