Skip to content
Snippets Groups Projects
Commit ef26a3f9 authored by 倪 泽文's avatar 倪 泽文
Browse files

删除comment57.md

parent 1ec9e531
No related branches found
No related tags found
Loading
```待评审函数开始protected void SentenceRun(String method) throws IOException
{
String text = getString("text");
int number = getInt("number", 6);
if ( text == null || "".equals(text) ) {
response(STATUS_INVALID_ARGS, "Invalid Arguments");
return;
}
final TextRankKeyphraseExtractor extractor = new TextRankKeyphraseExtractor(seg);
setKeywordsNum(number);
setMaxWordsNum(maxCombineLength);
extractor
final JcsegGlobalResource resourcePool = (JcsegGlobalResource)globalResource;
final JcsegTokenizerEntry tokenizerEntry = resourcePool.getTokenizerEntry("extractor");
if ( tokenizerEntry == null ) {
response(STATUS_INVALID_ARGS, "can't find tokenizer instance \"extractor\"");
return;
}
final ISegment seg = ISegment.COMPLEX.factory.create(tokenizerEntry.getConfig(), tokenizerEntry.getDict());
final TextRankSummaryExtractor extractor = new TextRankSummaryExtractor(seg, new SentenceSeg());
extractor.setSentenceNum(number);
long s_time = System.nanoTime();
final List<String> sentence = extractor.getKeySentenceFromString(text);
double c_time = (System.nanoTime() - s_time)/1E9;
final Map<String, Object> map = new HashMap<>();
final DecimalFormat df = new DecimalFormat("0.00000");
map.put("took", Float.valueOf(df.format(c_time)));
map.put("sentence", sentence);
//response the request
response(STATUS_OK, map);
}```待评审函数结束这个函数的作用是从一个字符串中提取出关键句子,并返回计算所需的时间。它使用了TextRank算法来提取关键句子。函数首先获取输入参数,如果输入参数为空或为"",则返回一个错误信息。然后创建一个TextRankKeyphraseExtractor对象,并设置其参数。接着,使用JCSEG库来获取tokenizer实例。如果tokenizer实例为空,则返回一个错误信息。然后,创建一个TextRankSummaryExtractor对象,并设置其参数。最后,使用TextRankSummaryExtractor来提取关键句子,并返回计算所需的时间。
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment