Skip to content

Commit

Permalink
字长卷积小表 已经 应用了.
Browse files Browse the repository at this point in the history
  • Loading branch information
yaoguangluo committed May 26, 2019
1 parent 25f85ed commit da2d9b3
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 11 deletions.
22 changes: 11 additions & 11 deletions wordSegment/org/tinos/engine/nlp/imp/NLPControllerImp.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public int doSlangPartAndPOSCheckForTwoChar(int countInputStringLength, List<Str
, POSController posUtils, int charPosition, String textInputString){
String countWordNode= stringBuilder.toString();
if (prefixWord[StableData.INT_ZERO].length()== StableData.INT_ZERO){
if(wordsForest.containsKey(countWordNode)) {
if(StableMaps.CiTwo.containsKey(countWordNode)) {
prefixWord[StableData.INT_ZERO].delete(StableData.INT_ZERO, prefixWord[StableData.INT_ZERO].length());
prefixWord[StableData.INT_ZERO].append(countWordNode);
outputList.add(countWordNode);
Expand Down Expand Up @@ -45,7 +45,7 @@ public int doSlangPartAndPOSCheckForTwoChar(int countInputStringLength, List<Str
}
}
}
if (wordsForest.containsKey(countWordNode)){
if (StableMaps.CiTwo.containsKey(countWordNode)){
prefixWord[StableData.INT_ZERO].delete(StableData.INT_ZERO, prefixWord[StableData.INT_ZERO].length());
prefixWord[StableData.INT_ZERO].append(countWordNode);
outputList.add(countWordNode);
Expand All @@ -59,7 +59,7 @@ public int doPOSAndEMMCheckOfThree(int countInputLength, List<String> outputList
, Map<String, String> wordsForest, StringBuilder stringBuilder, StringBuilder[] prefixWord
, POSController posUtils, int charPosition, String textInputString){
String inputString= stringBuilder.toString();
if (wordsForest.containsKey(inputString)){
if (StableMaps.CiThree.containsKey(inputString)){
prefixWord[StableData.INT_ZERO].delete(StableData.INT_ZERO, prefixWord[StableData.INT_ZERO].length());
prefixWord[StableData.INT_ZERO].append(inputString);
outputList.add(inputString);
Expand All @@ -73,7 +73,7 @@ public int doPOSAndEMMCheckOfThree(int countInputLength, List<String> outputList
+ inputString.charAt(StableData.INT_TWO);
strings[StableData.INT_THREE]= String.valueOf(inputString.charAt(StableData.INT_TWO));
if (null== prefixWord[StableData.INT_ZERO]){
if (wordsForest.containsKey(inputString)){
if (StableMaps.CiThree.containsKey(inputString)){
prefixWord[StableData.INT_ZERO].delete(StableData.INT_ZERO, prefixWord[StableData.INT_ZERO].length());
prefixWord[StableData.INT_ZERO].append(inputString);
outputList.add(inputString);
Expand Down Expand Up @@ -135,7 +135,7 @@ public int doPOSAndEMMCheckOfThree(int countInputLength, List<String> outputList
countInputLength= posUtils.chuLiFuCiOfThree(wordsForest, outputList, countInputLength, strings, prefixWord);
return countInputLength;
}
if(wordsForest.containsKey(strings[StableData.INT_ONE])) {
if(StableMaps.CiTwo.containsKey(strings[StableData.INT_ONE])) {
StringBuilder stringsBuilder= new StringBuilder();
countInputLength= doSlangPartAndPOSCheckForTwoChar(--countInputLength, outputList, stringsBuilder.append(strings[StableData.INT_ONE])
, wordsForest, prefixWord, posUtils, charPosition, textInputString);
Expand All @@ -157,7 +157,7 @@ public int doPOSAndEMMCheckOfThree(int countInputLength, List<String> outputList
public int doSlangCheck(int countInputStringLength, List<String> output, StringBuilder stringBuilder,
Map<String, String> wordsForest, StringBuilder[] prefixWord, POSController posUtils, int charPosition, String textInputString){
String inputString = stringBuilder.toString();
if (wordsForest.containsKey(inputString)){
if (StableMaps.CiFour.containsKey(inputString)){
output.add(inputString);
prefixWord[StableData.INT_ZERO].delete(StableData.INT_ZERO, prefixWord[StableData.INT_ZERO].length());
prefixWord[StableData.INT_ZERO].append(inputString);
Expand All @@ -172,8 +172,8 @@ public int doSlangCheck(int countInputStringLength, List<String> output, StringB
, stringBuilder.delete(StableData.INT_THREE, StableData.INT_FOUR), prefixWord, posUtils, charPosition, textInputString);
return countInputStringLength;
}
if (wordsForest.containsKey(preRegister)){
if (wordsForest.containsKey(postRegister)){
if (StableMaps.CiTwo.containsKey(preRegister)){
if (StableMaps.CiTwo.containsKey(postRegister)){
String string= StableData.EMPTY_STRING+ inputString.charAt(StableData.INT_ZERO);
if(StableMaps.xingWeiCi.containsKey(prefixWord[StableData.INT_ZERO].toString())
&&StableMaps.shiTaiCi.containsKey(string)) {
Expand All @@ -199,18 +199,18 @@ public int doSlangCheck(int countInputStringLength, List<String> output, StringB
return countInputStringLength-StableData.INT_TWO;
}
}
if(wordsForest.containsKey(preRegister+ inputString.charAt(StableData.INT_TWO))&& !wordsForest.containsKey(postRegister)) {
if(StableMaps.CiThree.containsKey(preRegister+ inputString.charAt(StableData.INT_TWO))&& !StableMaps.CiTwo.containsKey(postRegister)) {
prefixWord[StableData.INT_ZERO].delete(StableData.INT_ZERO, prefixWord[StableData.INT_ZERO].length());
prefixWord[StableData.INT_ZERO].append(preRegister+ inputString.charAt(StableData.INT_TWO));
output.add(preRegister+ inputString.charAt(StableData.INT_TWO));
return countInputStringLength- StableData.INT_ONE ;
}
if(wordsForest.containsKey(preRegister)&& wordsForest.containsKey(inRegister)) {
if(StableMaps.CiTwo.containsKey(preRegister)&& StableMaps.CiTwo.containsKey(inRegister)) {
countInputStringLength= doPOSAndEMMCheckOfThree(--countInputStringLength, output, wordsForest
, stringBuilder.delete(StableData.INT_THREE, StableData.INT_FOUR), prefixWord, posUtils, charPosition, textInputString);
return countInputStringLength;
}
if(wordsForest.containsKey(preRegister)) {
if(StableMaps.CiTwo.containsKey(preRegister)) {
countInputStringLength= doSlangPartAndPOSCheckForTwoChar(countInputStringLength- StableData.INT_TWO, output
, stringBuilder.delete(StableData.INT_TWO, StableData.INT_FOUR), wordsForest, prefixWord, posUtils, charPosition, textInputString);
return countInputStringLength;
Expand Down
20 changes: 20 additions & 0 deletions wordSegment/org/tinos/ortho/fhmm/imp/FMHMMListOneTimeImp.java
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,22 @@ public void indexMixed() throws IOException {
&& cInputString.split(StableData.NLP_SYMBO_SLASH).length > StableData.INT_ONE )) {
continue Here;
}
if(StableData.INT_ONE== cInputString.split(StableData.NLP_SYMBO_SLASH)[StableData.INT_ZERO].length()) {
StableMaps.CiOne.put(cInputString.split(StableData.NLP_SYMBO_SLASH)[StableData.INT_ZERO],cInputString
.split(StableData.NLP_SYMBO_SLASH)[StableData.INT_ONE]);
}
if(StableData.INT_TWO== cInputString.split(StableData.NLP_SYMBO_SLASH)[StableData.INT_ZERO].length()) {
StableMaps.CiTwo.put(cInputString.split(StableData.NLP_SYMBO_SLASH)[StableData.INT_ZERO],cInputString
.split(StableData.NLP_SYMBO_SLASH)[StableData.INT_ONE]);
}
if(StableData.INT_THREE== cInputString.split(StableData.NLP_SYMBO_SLASH)[StableData.INT_ZERO].length()) {
StableMaps.CiThree.put(cInputString.split(StableData.NLP_SYMBO_SLASH)[StableData.INT_ZERO],cInputString
.split(StableData.NLP_SYMBO_SLASH)[StableData.INT_ONE]);
}
if(StableData.INT_FOUR== cInputString.split(StableData.NLP_SYMBO_SLASH)[StableData.INT_ZERO].length()) {
StableMaps.CiFour.put(cInputString.split(StableData.NLP_SYMBO_SLASH)[StableData.INT_ZERO],cInputString
.split(StableData.NLP_SYMBO_SLASH)[StableData.INT_ONE]);
}
if(!StableMaps.fuCi.containsKey(cInputString.split(StableData.NLP_SYMBO_SLASH)[StableData.INT_ZERO])
&& cInputString.split(StableData.NLP_SYMBO_SLASH)[StableData.INT_ONE].contains(StableData.NLP_CI_FU)) {
StableMaps.fuCi.put(cInputString.split(StableData.NLP_SYMBO_SLASH)[StableData.INT_ZERO], cInputString
Expand Down Expand Up @@ -530,6 +546,10 @@ public void indexMixed() throws IOException {
StableMaps.xingRongCi.remove("");
StableMaps.xingWeiCi.remove("");
StableMaps.zhuCi.remove("");
System.out.println(StableMaps.CiOne.size());
System.out.println(StableMaps.CiTwo.size());
System.out.println(StableMaps.CiThree.size());
System.out.println(StableMaps.CiFour.size());
}

public void index() throws IOException {
Expand Down

0 comments on commit da2d9b3

Please sign in to comment.