public void parse(List<PosTaggedToken> posTaggedSentence) throws ParserRunException { String taggedText = fixPosTaggedTokensAndConvertToString(posTaggedSentence); try { List<String> parserOutput = getParserOutputFromPosTaggedText(taggedText); parseParserOutput(parserOutput,null); } catch (IOException e) { throw new ParserRunException("Failed to run parser.\n*** Please make sure that the EasyFirst parser server is running, and listening on: "+parserUrl+"\nInput was the following tagger text:\n"+taggedText+"\nPlease see nested exception",e); } }
public void parse(String rawText) throws ParserRunException { List<String> parserOutput = getParserOutput(rawText); parseParserOutput(parserOutput,rawText); }
private String fixPosTaggedTokensAndConvertToString(List<PosTaggedToken> posTaggedTokens) { return posTaggedTokensToString(inspectPosTaggedTokens(posTaggedTokens)); }
client = new EasyFirstClient(tokenizer, posTagger, url); client.parse(sentence); client = new EasyFirstClient(url); client.parse(this.posTaggedSentence); nodesList = client.getNodesAsList(); mutableTree = client.getTree(); wordsNodesList = client.getWordsNodesList();
/** * Get some raw text and return parsed text * @param rawText each sentence is a line, and will produce several parses if you give it several lines * @return * @throws ParserRunException */ private List<String> getParserOutput(String rawText) throws ParserRunException { List<String> ret = null; try { List<PosTaggedToken> posTaggedTokensForRawText = tokenizeAndPosTag(rawText); String taggedText = fixPosTaggedTokensAndConvertToString(posTaggedTokensForRawText); ret = getParserOutputFromPosTaggedText(taggedText); } catch (IOException e) { throw new ParserRunException("Error openning a new URLConnection, or writing to or reading from the parser server", e); } finally { } return ret; }
}catch(NumberFormatException e){throw new ParserRunException("Bad antecedent id, when parsing "+pos+".\nParser output was:\n"+listStringToString(parserOutput)+rawTextForExceptionString,e);} antecedent = mapIdToNode.get(antecedentId); if (antecedent==null)throw new ParserRunException("Antecedent not found for node: "+counterString+".\nParser output was:\n"+listStringToString(parserOutput)+rawTextForExceptionString); serial = antecedent.getInfo().getNodeInfo().getSerial(); pos = InfoGetFields.getPartOfSpeech(antecedent.getInfo()); if (tree!=null)throw new ParserRunException("More than one root.\nParser output was:\n"+listStringToString(parserOutput)+"\n"+rawTextForExceptionString); tree=node; throw new ParserRunException("Wrong line returned by the parser: "+line+".\nParser output was:\n"+listStringToString(parserOutput)+"\n"+rawTextForExceptionString); throw new ParserRunException("Unsupported part-of-speech tag, occurred in line: \""+line+"\". See nested exception.\nParser output was:\n"+listStringToString(parserOutput)+"\n"+rawTextForExceptionString,e);