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

来自大模型的评审

parent 9db9e347
No related branches found
No related tags found
No related merge requests found
```待评审函数开始protected void keyPraseRun(String method) throws IOException
{
String text = getString("");
int number = getInt("number", 10),
maxCombineLength = getInt("maxCombineLength", 4),
autoMinLength = getInt("autoMinLength", 4);
if ( text == null || "".equals(text) ) {
response(STATUS, "Invalid Arguments");
return;
}
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 TextRankKeyphraseExtractor extractor = new TextRankKeyphraseExtractor(seg);
extractor.setKeywordsNum(number);
extractor.setMaxWordsNum(maxCombineLength);
extractor.setAutoMinLength();
long s_time = System.nanoTime();
final List<String> keyphrase = extractor.getKeyphraseFromString(text);
double c_time = (System.nanoTime() - s_time)/1E9;
inal Map<String, Object> map = new HashMap<>();
DecimalFormat df = new DecimalFormat("0.00000");
map.put("took", Float.valueOf(df.format(c_time)));
final Map<String, Object> map = new HashMap<>();
DecimalFormat df = new DecimalFormat("0.00000");
map.put("took", Float.valueOf(df.format(c_time)));
//response the request
response(0, map);
}```待评审函数结束This is a Java method that performs a keyword extraction task using the TextRank algorithm. The method takes four parameters: a string `text` that contains the text to be processed, an integer `number` that specifies the number of keywords to extract, an integer `maxCombineLength` that specifies the maximum length of each keyword, and an integer `autoMinLength` that specifies the minimum length of each keyword.
The method first checks if the input `text` is null or empty, and if so, it returns an error response. Otherwise, it creates a `JcsegTokenizerEntry` object using a `JcsegGlobalResource` object, which is a global resource pool that provides access to a tokenizer. The method then creates an `ISegment` object using the `complex` factory and the `tokenizerEntry` object, and it creates a `TextRankKeyphraseExtractor` object using the `ISegment` object.
The method sets the number of keywords to extract, the maximum number of words per keyword, and the auto minimum length for each keyword using the `setKeywordsNum`, `setMaxWordsNum`, and `setAutoMinLength` methods of the `TextRankKeyphraseExtractor` object, respectively. The method then extracts the keywords from the input `text` using the `getKeyphraseFromString` method of the `TextRankKeyphraseExtractor` object.
The method calculates the time taken to extract the keywords using the `System.nanoTime()` method and returns the extracted keywords and the time taken as a JSON response.
\ 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