-
-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
체언+조사 결합 규칙 및 동사+전성어미 결합 규칙 추가 (#91)
- Loading branch information
Showing
9 changed files
with
353 additions
and
120 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
src/main/java/kr/co/shineware/nlp/komoran/core/model/MorphUtil.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package kr.co.shineware.nlp.komoran.core.model; | ||
|
||
import kr.co.shineware.util.common.string.StringUtil; | ||
|
||
public class MorphUtil { | ||
|
||
public MorphUtil() { | ||
; | ||
} | ||
|
||
public boolean isSameJaso(String sourceMorph, String compareMorph) { | ||
String compareMorphJaso = StringUtil.korean2JasoString(compareMorph); | ||
if (sourceMorph.length() == compareMorphJaso.length()) { | ||
for (int i = 0; i < compareMorphJaso.length(); i++) { | ||
if (sourceMorph.charAt(i) != compareMorphJaso.charAt(i)) { | ||
return false; | ||
} | ||
} | ||
return true; | ||
} | ||
return false; | ||
} | ||
|
||
public boolean hasJongsung(String morph) { | ||
char prevLastJaso = morph.charAt(morph.length() - 1); | ||
if (0x3131 <= prevLastJaso && prevLastJaso <= 0x314e) { | ||
return prevLastJaso != 0x3138 && prevLastJaso != 0x3143 && prevLastJaso != 0x3149; | ||
} | ||
return false; | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
src/main/java/kr/co/shineware/nlp/komoran/core/model/TagUtil.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package kr.co.shineware.nlp.komoran.core.model; | ||
|
||
import kr.co.shineware.nlp.komoran.constant.SYMBOL; | ||
import kr.co.shineware.nlp.komoran.modeler.model.PosTable; | ||
|
||
public class TagUtil { | ||
|
||
private final PosTable posTable; | ||
|
||
public TagUtil(PosTable posTable) { | ||
this.posTable = posTable; | ||
} | ||
|
||
public int getId(String tagName) { | ||
return this.posTable.getId(tagName); | ||
} | ||
|
||
private boolean hasTagName(int tagId, String[] symbols) { | ||
for (String tagName : symbols) { | ||
if (tagId == this.posTable.getId(tagName)) { | ||
return true; | ||
} | ||
} | ||
return false; | ||
} | ||
|
||
public boolean isJosa(int tagId) { | ||
return hasTagName(tagId, SYMBOL.JOSA); | ||
} | ||
|
||
public boolean isNoun(int tagId) { | ||
return hasTagName(tagId, SYMBOL.NOUN); | ||
} | ||
|
||
public boolean isEomi(int tagId) { | ||
return hasTagName(tagId, SYMBOL.EOMI); | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
.../java/kr/co/shineware/nlp/komoran/core/model/combinationrules/CombinationRuleChecker.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package kr.co.shineware.nlp.komoran.core.model.combinationrules; | ||
|
||
public interface CombinationRuleChecker { | ||
boolean isValidRule(String prevMorph, int prevTagId, String morph, int tagId); | ||
} |
20 changes: 20 additions & 0 deletions
20
.../co/shineware/nlp/komoran/core/model/combinationrules/NounEomiCombinationRuleChecker.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package kr.co.shineware.nlp.komoran.core.model.combinationrules; | ||
|
||
import kr.co.shineware.nlp.komoran.core.model.TagUtil; | ||
|
||
public class NounEomiCombinationRuleChecker implements CombinationRuleChecker { | ||
|
||
private final TagUtil tagUtil; | ||
|
||
public NounEomiCombinationRuleChecker(TagUtil tagUtil) { | ||
this.tagUtil = tagUtil; | ||
} | ||
|
||
@Override | ||
public boolean isValidRule(String prevMorph, int prevTagId, String morph, int tagId) { | ||
if (this.tagUtil.isNoun(prevTagId) && this.tagUtil.isEomi(tagId)) { | ||
return false; | ||
} | ||
return true; | ||
} | ||
} |
Oops, something went wrong.