word completion in the C parser now returns information about the function which generates the token

This commit is contained in:
Krasimir Angelov
2017-09-06 14:37:51 +02:00
parent ef071d9157
commit 301b100988
5 changed files with 19 additions and 5 deletions

View File

@@ -731,8 +731,8 @@ Java_org_grammaticalframework_pgf_TokenIterator_fetchTokenProb(JNIEnv* env, jcla
return NULL;
jclass tp_class = (*env)->FindClass(env, "org/grammaticalframework/pgf/TokenProb");
jmethodID tp_constrId = (*env)->GetMethodID(env, tp_class, "<init>", "(DLjava/lang/String;Ljava/lang/String;)V");
jobject jtp = (*env)->NewObject(env, tp_class, tp_constrId, tp->prob, gu2j_string(env,tp->tok), gu2j_string(env,tp->cat));
jmethodID tp_constrId = (*env)->GetMethodID(env, tp_class, "<init>", "(DLjava/lang/String;Ljava/lang/String;Ljava/lang/String;)V");
jobject jtp = (*env)->NewObject(env, tp_class, tp_constrId, (double) tp->prob, gu2j_string(env,tp->tok), gu2j_string(env,tp->cat), gu2j_string(env,tp->fun));
return jtp;
}

View File

@@ -4,12 +4,14 @@ package org.grammaticalframework.pgf;
public class TokenProb {
private String tok;
private String cat;
private String fun;
private double prob;
public TokenProb(double prob, String tok, String cat) {
public TokenProb(double prob, String tok, String cat, String fun) {
this.prob = prob;
this.tok = tok;
this.cat = cat;
this.cat = cat;
this.fun = fun;
}
/** Returns the negative logarithmic probability. */
@@ -26,4 +28,9 @@ public class TokenProb {
public String getCategory() {
return cat;
}
/** Returns the function from which this word was predicted. */
public String getFunction() {
return fun;
}
}