File tree Expand file tree Collapse file tree 4 files changed +20
-6
lines changed
src/main/java/org/fnlp/nlp Expand file tree Collapse file tree 4 files changed +20
-6
lines changed Original file line number Diff line number Diff line change 2121<scm >
2222<url >scm:git:git@github.com:xpqiu/fnlp.git</url >
2323<connection >scm:git:git@github.com:xpqiu/fnlp.git</connection >
24- <tag >fnlp-core-2.0 </tag >
24+ <tag >fnlp-core-2.1 </tag >
2525</scm >
2626
2727<properties >
Original file line number Diff line number Diff line change @@ -87,12 +87,15 @@ public AbstractTagger(String file) throws LoadModelException {
8787 * @param tagger 另一个标注器
8888 */
8989public AbstractTagger (AbstractTagger tagger ){
90+ //modify for parallel
91+ Linear originClassifier = tagger .getClassifier ();
92+ Linear newClassifier = new Linear (originClassifier .getInferencer (),originClassifier .getAlphabetFactory ());
93+ setClassifier (newClassifier );
9094
91- setClassifier (tagger .getClassifier ());
9295factory = getClassifier ().getAlphabetFactory ();
9396labels = factory .DefaultLabelAlphabet ();
9497IFeatureAlphabet features = factory .DefaultFeatureAlphabet ();
95- featurePipe = new Sequence2FeatureSequence (templets , features ,
98+ featurePipe = new Sequence2FeatureSequence (tagger . templets , features ,
9699labels );
97100}
98101
@@ -213,4 +216,4 @@ public Linear getClassifier() {
213216public void setClassifier (Linear cl ) {
214217this .cl = cl ;
215218}
216- }
219+ }
Original file line number Diff line number Diff line change @@ -62,6 +62,17 @@ public class POSTagger extends AbstractTagger {
6262public POSTagger (String cwsmodel , String str ) throws LoadModelException {
6363super (str );
6464cws = new CWSTagger (cwsmodel );
65+ }
66+
67+ /**
68+ * 构造函数
69+ * @param cwsmodel 分词模型文件
70+ * @param posmodel 词性模型文件
71+ */
72+ public POSTagger (CWSTagger cwsmodel , POSTagger posmodel ) throws LoadModelException {
73+ super (posmodel );
74+ prePipe = posmodel .prePipe ;
75+ cws = new CWSTagger (cwsmodel );
6576}
6677
6778//分词词典也被dict指定
@@ -360,4 +371,4 @@ public void SetTagType(String lang){
360371else if (lang .equals ("cn" ))
361372this .labels = factory .DefaultLabelAlphabet ();
362373}
363- }
374+ }
Original file line number Diff line number Diff line change @@ -46,7 +46,7 @@ public class WordCount {
4646public static void main (String [] args ) throws Exception {
4747
4848WordCount wc = new WordCount ();
49- wc .seg = new CWSTagger ("./models/seg.m" );
49+ wc .seg = new CWSTagger (".. /models/seg.m" );
5050
5151wc .count ("./tmp/filterTweets.y" );
5252wc .count ("./tmp/filterTweets.n" );
You can’t perform that action at this time.
0 commit comments