Skip to content

Commit 7742e5a

Browse files
committed
small changes
2 parents 87af35e + 8997fc8 commit 7742e5a

File tree

4 files changed

+20
-6
lines changed

4 files changed

+20
-6
lines changed

fnlp-core/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
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>

fnlp-core/src/main/java/org/fnlp/nlp/cn/tag/AbstractTagger.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,12 +87,15 @@ public AbstractTagger(String file) throws LoadModelException {
8787
* @param tagger 另一个标注器
8888
*/
8989
public 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());
9295
factory = getClassifier().getAlphabetFactory();
9396
labels = factory.DefaultLabelAlphabet();
9497
IFeatureAlphabet features = factory.DefaultFeatureAlphabet();
95-
featurePipe = new Sequence2FeatureSequence(templets, features,
98+
featurePipe = new Sequence2FeatureSequence(tagger.templets, features,
9699
labels);
97100
}
98101

@@ -213,4 +216,4 @@ public Linear getClassifier() {
213216
public void setClassifier(Linear cl) {
214217
this.cl = cl;
215218
}
216-
}
219+
}

fnlp-core/src/main/java/org/fnlp/nlp/cn/tag/POSTagger.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,17 @@ public class POSTagger extends AbstractTagger {
6262
public POSTagger(String cwsmodel, String str) throws LoadModelException {
6363
super(str);
6464
cws = 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){
360371
else if(lang.equals("cn"))
361372
this.labels = factory.DefaultLabelAlphabet();
362373
}
363-
}
374+
}

fnlp-core/src/main/java/org/fnlp/nlp/corpus/WordCount.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public class WordCount {
4646
public static void main(String[] args) throws Exception {
4747

4848
WordCount wc = new WordCount();
49-
wc.seg = new CWSTagger("./models/seg.m");
49+
wc.seg = new CWSTagger("../models/seg.m");
5050

5151
wc.count("./tmp/filterTweets.y");
5252
wc.count("./tmp/filterTweets.n");

0 commit comments

Comments
 (0)