mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-05-23 09:52:55 -06:00
bugfix for unknown words
This commit is contained in:
@@ -11,7 +11,8 @@ public class UnknownLiteralCallback implements LiteralCallback {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public CallbackResult match(int lin_idx, String sentence, int offset) {
|
public CallbackResult match(int lin_idx, String sentence, int offset) {
|
||||||
if (!Character.isUpperCase(sentence.charAt(offset))) {
|
if (offset < sentence.length() &&
|
||||||
|
!Character.isUpperCase(sentence.charAt(offset))) {
|
||||||
int start_offset = offset;
|
int start_offset = offset;
|
||||||
while (offset < sentence.length() &&
|
while (offset < sentence.length() &&
|
||||||
!Character.isWhitespace(sentence.charAt(offset))) {
|
!Character.isWhitespace(sentence.charAt(offset))) {
|
||||||
@@ -19,7 +20,7 @@ public class UnknownLiteralCallback implements LiteralCallback {
|
|||||||
}
|
}
|
||||||
int end_offset = offset;
|
int end_offset = offset;
|
||||||
String word = sentence.substring(start_offset,end_offset);
|
String word = sentence.substring(start_offset,end_offset);
|
||||||
|
|
||||||
if (concr.lookupMorpho(word).size() == 0) {
|
if (concr.lookupMorpho(word).size() == 0) {
|
||||||
Expr expr = new Expr("MkSymb", new Expr(word));
|
Expr expr = new Expr("MkSymb", new Expr(word));
|
||||||
return new CallbackResult(new ExprProb(expr, 0), end_offset);
|
return new CallbackResult(new ExprProb(expr, 0), end_offset);
|
||||||
|
|||||||
Reference in New Issue
Block a user