File tree Expand file tree Collapse file tree 3 files changed +18
-3
lines changed
fnlp-core/src/main/java/org/fnlp/nlp Expand file tree Collapse file tree 3 files changed +18
-3
lines changed Original file line number Diff line number Diff line change @@ -88,12 +88,15 @@ public AbstractTagger(String file) throws LoadModelException {
8888 * @throws LoadModelException
8989 */
9090public AbstractTagger (AbstractTagger tagger ){
91+ //modify for parallel
92+ Linear originClassifier = tagger .getClassifier ();
93+ Linear newClassifier = new Linear (originClassifier .getInferencer (),originClassifier .getAlphabetFactory ());
94+ setClassifier (newClassifier );
9195
92- setClassifier (tagger .getClassifier ());
9396factory = getClassifier ().getAlphabetFactory ();
9497labels = factory .DefaultLabelAlphabet ();
9598IFeatureAlphabet features = factory .DefaultFeatureAlphabet ();
96- featurePipe = new Sequence2FeatureSequence (templets , features ,
99+ featurePipe = new Sequence2FeatureSequence (tagger . templets , features ,
97100labels );
98101}
99102
Original file line number Diff line number Diff line change @@ -62,6 +62,18 @@ 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 str 词性模型文件
71+ * @throws Exception
72+ */
73+ public POSTagger (CWSTagger cwsmodel , POSTagger posmodel ) throws LoadModelException {
74+ super (posmodel );
75+ prePipe = posmodel .prePipe ;
76+ cws = new CWSTagger (cwsmodel );
6577}
6678
6779//分词词典也被dict指定
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