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

删除comment63.md

parent 31f93d02
No related branches found
No related tags found
No related merge requests found
```待评审函数开始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;
response(STATUS_INVALID_ARGS, "Invalid Arguments");
response(STATUS_INVALID_ARGS, "Invalid Arguments");
}
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
map.put("took", Float.valueOf(df.format(c_time)));
map.put("sentence", sentence);
//response the request
response(STATUS_OK, map);
}```待评审函数结束这是一个Java函数,其主要功能是使用TextRank算法从给定的文本中提取出若干个关键句子。以下是该函数的主要步骤:
1. 检查输入参数是否有效。如果文本为空,则返回一个错误消息。
2. 获取一个JcsegGlobalResource对象和一个TokenizerEntry对象。
3. 创建一个ISegment对象和一个TextRankSummaryExtractor对象。
4. 设置TextRankSummaryExtractor对象的参数,包括要提取的句子数量。
5. 使用TextRankSummaryExtractor对象从文本中提取关键句子。
6. 计算提取过程所需的时间。
7. 创建一个Map对象,将提取所需的时间和提取出的关键句子添加到其中。
8. 将Map对象作为响应返回。
需要注意的是,该函数中使用了一些自定义的类和对象,这些类和对象可能需要在其他部分的代码中定义和初始化。此外,该函数中还使用了System.nanoTime()方法来获取当前的时间,这可能需要在其他部分的代码中配置和初始化。
\ 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