/// <exception cref="System.Exception"/> public static void Main(string[] args) { bool mergeType = Usesum; bool prettyPrint = true; bool debug = false; string parseGram = null; string filename = args[0]; for (int i = 1; i < args.Length; i++) { if (Sharpen.Runtime.EqualsIgnoreCase(args[i], "-debug")) { debug = true; } else { if (Sharpen.Runtime.EqualsIgnoreCase(args[i], "-useMax")) { mergeType = Usemax; } else { if (Sharpen.Runtime.EqualsIgnoreCase(args[i], "-useSum")) { mergeType = Usesum; } else { if (Sharpen.Runtime.EqualsIgnoreCase(args[i], "-noPrettyPrint")) { prettyPrint = false; } else { if (Sharpen.Runtime.EqualsIgnoreCase(args[i], "-parser")) { parseGram = args[++i]; } else { log.Info("unrecognized flag: " + args[i]); log.Info("usage: java LatticeReader <file> [ -debug ] [ -useMax ] [ -useSum ] [ -noPrettyPrint ] [ -parser parserFile ]"); System.Environment.Exit(0); } } } } } } Edu.Stanford.Nlp.Parser.Lexparser.HTKLatticeReader lr = new Edu.Stanford.Nlp.Parser.Lexparser.HTKLatticeReader(filename, mergeType, debug, prettyPrint); if (parseGram != null) { Options op = new Options(); // TODO: these options all get clobbered by the Options object // stored in the LexicalizedParser (unless it's a text file?) op.doDep = false; op.testOptions.maxLength = 80; op.testOptions.maxSpanForTags = 80; LexicalizedParser lp = LexicalizedParser.LoadModel(parseGram, op); // TODO: somehow merge this into ParserQuery instead of being // LexicalizedParserQuery specific LexicalizedParserQuery pq = lp.LexicalizedParserQuery(); pq.Parse(lr); Tree t = pq.GetBestParse(); t.PennPrint(); } }