Skip to content

Commit 03f1bba

Browse files
committed
修正了keywordcomputer中的一个bug,感谢@gavin1332 的意见
1 parent 10bdc37 commit 03f1bba

File tree

1 file changed

+1
-4
lines changed

1 file changed

+1
-4
lines changed

src/main/java/org/ansj/app/keyword/KeyWordComputer.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,13 @@
99

1010
import org.ansj.dic.LearnTool;
1111
import org.ansj.domain.Term;
12-
import org.ansj.recognition.NatureRecognition;
1312
import org.ansj.splitWord.analysis.NlpAnalysis;
1413

1514
public class KeyWordComputer {
1615

1716
private int nKeyword = 5;
1817

1918
public KeyWordComputer() {
20-
nKeyword = 5;
2119
}
2220

2321
/**
@@ -39,7 +37,6 @@ private List<Keyword> computeArticleTfidf(String content, int titleLength) {
3937

4038
LearnTool learn = new LearnTool();
4139
List<Term> parse = NlpAnalysis.parse(content, learn);
42-
parse = NlpAnalysis.parse(content, learn);
4340

4441
for (Term term : parse) {
4542
int weight = getWeight(term, content.length(), titleLength);
@@ -57,7 +54,7 @@ private List<Keyword> computeArticleTfidf(String content, int titleLength) {
5754
TreeSet<Keyword> treeSet = new TreeSet<Keyword>(tm.values());
5855

5956
ArrayList<Keyword> arrayList = new ArrayList<Keyword>(treeSet);
60-
if (treeSet.size() < nKeyword) {
57+
if (treeSet.size() <= nKeyword) {
6158
return arrayList;
6259
} else {
6360
return arrayList.subList(0, nKeyword);

0 commit comments

Comments
 (0)