forked from NLPchina/ansj_seg
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
128 additions
and
30 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
java学习 j 100 | ||
java不学习 j 100 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
php学习 j 100 | ||
php不学习 j 100 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package org.ansj.demo; | ||
|
||
import java.util.HashMap; | ||
import java.util.List; | ||
|
||
import org.ansj.domain.Term; | ||
import org.ansj.library.UserDefineLibrary; | ||
import org.ansj.splitWord.analysis.ToAnalysis; | ||
|
||
import love.cq.domain.Forest; | ||
|
||
/** | ||
* 这个例子是根据不同的,用户自定义词典来加载分词器 | ||
* @author ansj | ||
* | ||
*/ | ||
public class UserDefineAnalysisDemo { | ||
private static HashMap<String,Forest> userForestMap = new HashMap<String,Forest>() ; | ||
|
||
public static void main(String[] args) { | ||
//创建一些用户词典结构树 | ||
Forest forest = UserDefineLibrary.makeUserDefineForest(false, "library/user1.dic") ; | ||
userForestMap.put("user1", forest) ; | ||
forest = UserDefineLibrary.makeUserDefineForest(false, "library/user2.dic") ; | ||
userForestMap.put("user2", forest) ; | ||
|
||
List<Term> paser = null ; | ||
paser = ToAnalysis.paser("java学习是一个很难的过程.", userForestMap.get("user1")) ; | ||
System.out.println(paser); | ||
paser = ToAnalysis.paser("java学习是一个很难的过程.", userForestMap.get("user2")) ; | ||
System.out.println(paser); | ||
paser = ToAnalysis.paser("php学习是一个很难的过程.", userForestMap.get("user2")) ; | ||
System.out.println(paser); | ||
|
||
} | ||
} |