本文整理汇总了Java中org.apache.thrift.TApplicationException.INTERNAL_ERROR属性的典型用法代码示例。如果您正苦于以下问题:Java TApplicationException.INTERNAL_ERROR属性的具体用法?Java TApplicationException.INTERNAL_ERROR怎么用?Java TApplicationException.INTERNAL_ERROR使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.apache.thrift.TApplicationException
的用法示例。
在下文中一共展示了TApplicationException.INTERNAL_ERROR属性的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createTranslator
private MessageTransalator createTranslator(TProtocolFactory protocolFactory) {
return new MessageTransalator(protocolFactory, new AuthTokenExchanger<AuthToken, UserData>() {
@Override
public AuthToken createEmptyAuthToken() {
return new AuthToken();
}
@Override
public UserData process(AuthToken authToken) throws TException {
if ("sometoken".equals(authToken.getToken())) {
return new UserData().setId("user1");
}
if ("fataltoken".equals(authToken.getToken())) {
throw new TApplicationException(TApplicationException.INTERNAL_ERROR, "fatal!!!");
}
throw new UnauthorizedException("token is invalid");
}
});
}
示例2: parse_text
public List<ParseTree> parse_text(String text, List<String> outputFormat) throws TApplicationException
{
List<ParseTree> results = new ArrayList<ParseTree>();
try
{
treePrinter = ParserUtil.setOptions(outputFormat, tlp);
// assume no tokenization was done; use Stanford's default org.ets.research.nlp.stanford_thrift.tokenizer
DocumentPreprocessor preprocess = new DocumentPreprocessor(new StringReader(text));
Iterator<List<HasWord>> foundSentences = preprocess.iterator();
while (foundSentences.hasNext())
{
Tree parseTree = parser.apply(foundSentences.next());
results.add(new ParseTree(ParserUtil.TreeObjectToString(parseTree, treePrinter), parseTree.score()));
}
}
catch (Exception e)
{
// FIXME
throw new TApplicationException(TApplicationException.INTERNAL_ERROR, e.getMessage());
}
return results;
}
示例3: parse_tokens
/**
* @param tokens One sentence worth of tokens at a time.
* @return A ParseTree object of the String representation of the tree, plus its probability.
* @throws TApplicationException
*/
public ParseTree parse_tokens(List<String> tokens, List<String> outputFormat) throws TApplicationException
{
try
{
treePrinter = ParserUtil.setOptions(outputFormat, tlp);
// a single sentence worth of tokens
String[] tokenArray = new String[tokens.size()];
tokens.toArray(tokenArray);
List<CoreLabel> crazyStanfordFormat = Sentence.toCoreLabelList(tokenArray);
Tree parseTree = parser.apply(crazyStanfordFormat);
return new ParseTree(ParserUtil.TreeObjectToString(parseTree, treePrinter), parseTree.score());
}
catch (Exception e)
{
// FIXME
throw new TApplicationException(TApplicationException.INTERNAL_ERROR, e.getMessage());
}
}
示例4: parse_tagged_sentence
public ParseTree parse_tagged_sentence(String taggedSentence, List<String> outputFormat, String divider) throws TApplicationException
{
try
{
treePrinter = ParserUtil.setOptions(outputFormat, tlp);
// a single sentence worth of tagged text, better be properly tokenized >:D
Tree parseTree = parser.apply(CoreNLPThriftUtil.getListOfTaggedWordsFromTaggedSentence(taggedSentence, divider));
return new ParseTree(ParserUtil.TreeObjectToString(parseTree, treePrinter), parseTree.score());
}
catch (Exception e)
{
// FIXME
throw new TApplicationException(TApplicationException.INTERNAL_ERROR, e.getMessage());
}
}
示例5: lexicalize_parse_tree
/** If one were to call any of these other methods to get a parse tree for some input sentence
* with the -outputFormatOptions flag of "lexicalize", they would receive their parse tree,
* in the -outputFormat of their choice, with every leaf marked with it's head word.
* This function does exactly that on an existing parse tree.
* NOTE that this WILL re-lexicalize a pre-lexicalized tree, so don't pass in a tree that
* has been lexicalized and expect to get back the same thing as what you passed in.
*/
public String lexicalize_parse_tree(String tree) throws TApplicationException
{
try
{
Tree parseTree = Tree.valueOf(tree);
Tree lexicalizedTree = Trees.lexicalize(parseTree, tlp.headFinder());
treePrinter = ParserUtil.setOptions(null, tlp); // use defaults
Function<Tree, Tree> a = TreeFunctions.getLabeledToDescriptiveCoreLabelTreeFunction();
lexicalizedTree = a.apply(lexicalizedTree);
return ParserUtil.TreeObjectToString(lexicalizedTree, treePrinter);
}
catch (Exception e)
{
// FIXME
throw new TApplicationException(TApplicationException.INTERNAL_ERROR, e.getMessage());
}
}
示例6: sr_parse_text
public List<ParseTree> sr_parse_text(String untokenizedText, List<String> outputFormat) throws TApplicationException
{
try
{
List<ParseTree> results = new ArrayList<ParseTree>();
List<List<TaggedToken>> posTaggedText = tagger.tag_text(untokenizedText);
for (List<TaggedToken> taggedSentence : posTaggedText)
{
List<TaggedWord> taggedWords = CoreNLPThriftUtil.convertTaggedTokensToTaggedWords(taggedSentence);
results.add(srparser.parseTaggedWords(taggedWords, outputFormat));
}
return results;
}
catch (Exception e)
{
// FIXME
throw new TApplicationException(TApplicationException.INTERNAL_ERROR, e.getMessage());
}
}
示例7: sumbitTask
private void sumbitTask(TProtocol out, final TMessage msg, final WriterHandler onComplete, Runnable task){
try {
serverDef.executor.submit(task);
} catch (RejectedExecutionException e) {
TApplicationException x = new TApplicationException(TApplicationException.INTERNAL_ERROR, "TooBusy");
writeException(out, msg, onComplete, x, null);
logger.error("RejectedExecutionException: "+e.getLocalizedMessage());
}
}
示例8: sr_parse_tagged_sentence
public ParseTree sr_parse_tagged_sentence(String taggedSentence, List<String> outputFormat, String divider) throws TApplicationException
{
try
{
// a single sentence worth of tagged text, better be properly tokenized >:D
List<TaggedWord> taggedWords = CoreNLPThriftUtil.getListOfTaggedWordsFromTaggedSentence(taggedSentence, divider);
return parseTaggedWords(taggedWords, outputFormat);
}
catch (Exception e)
{
// FIXME
throw new TApplicationException(TApplicationException.INTERNAL_ERROR, e.getMessage());
}
}
示例9: sr_parse_tokens
public ParseTree sr_parse_tokens(List<String> tokenizedSentence, List<String> outputFormat) throws TApplicationException
{
try
{
List<TaggedToken> taggedSentence = tagger.tag_tokenized_sentence(tokenizedSentence);
return srparser.parseTaggedWords(CoreNLPThriftUtil.convertTaggedTokensToTaggedWords(taggedSentence), outputFormat);
}
catch (Exception e)
{
// FIXME
throw new TApplicationException(TApplicationException.INTERNAL_ERROR, e.getMessage());
}
}
示例10: createApplicationException
private TApplicationException createApplicationException(TException e) {
return new TApplicationException(TApplicationException.INTERNAL_ERROR, e.getMessage());
}