Skip to content

Commit

Permalink
基于用户词典的合并提前到紧接NGram切分后
Browse files Browse the repository at this point in the history
  • Loading branch information
hankcs committed Jul 12, 2015
1 parent 8d388ba commit b219c3a
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
11 changes: 6 additions & 5 deletions src/main/java/com/hankcs/hanlp/seg/Dijkstra/DijkstraSegment.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@ public List<Term> segSentence(char[] sentence)
}
List<Vertex> vertexList = dijkstra(graph);
// fixResultByRule(vertexList);

if (config.useCustomDictionary)
{
combineByCustomDictionary(vertexList);
}

if (HanLP.Config.DEBUG)
{
System.out.println("粗分结果" + convert(vertexList, false));
Expand Down Expand Up @@ -110,11 +116,6 @@ public List<Term> segSentence(char[] sentence)
speechTagging(vertexList);
}

if (config.useCustomDictionary)
{
combineByCustomDictionary(vertexList);
}

return convert(vertexList, config.offset);
}

Expand Down
11 changes: 6 additions & 5 deletions src/main/java/com/hankcs/hanlp/seg/Viterbi/ViterbiSegment.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@ protected List<Term> segSentence(char[] sentence)
// start = System.currentTimeMillis();
List<Vertex> vertexList = viterbi(wordNetAll);
// System.out.println("最短路:" + (System.currentTimeMillis() - start));

if (config.useCustomDictionary)
{
combineByCustomDictionary(vertexList);
}

if (HanLP.Config.DEBUG)
{
System.out.println("粗分结果" + convert(vertexList, false));
Expand Down Expand Up @@ -112,11 +118,6 @@ protected List<Term> segSentence(char[] sentence)
speechTagging(vertexList);
}

if (config.useCustomDictionary)
{
combineByCustomDictionary(vertexList);
}

return convert(vertexList, config.offset);
}

Expand Down
2 changes: 1 addition & 1 deletion src/test/java/com/hankcs/test/seg/TestSegment.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public void testViterbi() throws Exception
HanLP.Config.ShowTermNature = false;
Segment segment = new DijkstraSegment();
System.out.println(segment.seg(
"巴曙松:房地产如何估价才合理"
"上外日本文化经济学院的陆晚霞教授正在教授泛读课程"
));
}

Expand Down

0 comments on commit b219c3a

Please sign in to comment.