Skip to content

Commit c363c31

Browse files
author
Ansj
committed
增加测试用例,发布一版.可能是3.x最后一个relase版本
1 parent 9cdf23d commit c363c31

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

src/main/java/org/ansj/app/summary/TagContent.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public String tagContent(List<Keyword> keyWords, String content) {
4545
beginOffe = sgw.offe + temp.length();
4646
}
4747

48-
if (beginOffe < content.length() - 1) {
48+
if (beginOffe <= content.length() - 1) {
4949
sb.append(content.substring(beginOffe, content.length()));
5050
}
5151

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package org.ansj.test;
2+
3+
import java.util.ArrayList;
4+
import java.util.List;
5+
6+
import org.ansj.app.keyword.Keyword;
7+
import org.ansj.app.summary.TagContent;
8+
import org.junit.Test;
9+
10+
public class TagWordTest {
11+
@Test
12+
public void test(){
13+
TagContent tw = new TagContent("<em>", "</em>");
14+
String content = "abc123中国人";
15+
List<Keyword> keywords = new ArrayList<Keyword>();
16+
keywords.add(new Keyword("中国人民", 1.0));
17+
keywords.add(new Keyword("中国", 1.0));
18+
keywords.add(new Keyword("abc", 1.0));
19+
keywords.add(new Keyword("abc12", 1.0));
20+
System.out.println(tw.tagContent(keywords, content));
21+
}
22+
}

0 commit comments

Comments
 (0)