forked from GitHub/gf-core
the Java API now also has access to the token's category while doing completion
This commit is contained in:
@@ -627,8 +627,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>", "(Ljava/lang/String;D)V");
|
||||
jobject jtp = (*env)->NewObject(env, tp_class, tp_constrId, gu2j_string(env,tp->tok), tp->prob);
|
||||
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));
|
||||
|
||||
return jtp;
|
||||
}
|
||||
|
||||
@@ -3,11 +3,18 @@ package org.grammaticalframework.pgf;
|
||||
/** Simply a pair of an expression and a probability value. */
|
||||
public class TokenProb {
|
||||
private String tok;
|
||||
private String cat;
|
||||
private double prob;
|
||||
|
||||
public TokenProb(String tok, double prob) {
|
||||
this.tok = tok;
|
||||
public TokenProb(double prob, String tok, String cat) {
|
||||
this.prob = prob;
|
||||
this.tok = tok;
|
||||
this.cat = cat;
|
||||
}
|
||||
|
||||
/** Returns the negative logarithmic probability. */
|
||||
public double getProb() {
|
||||
return prob;
|
||||
}
|
||||
|
||||
/** Returns the token. */
|
||||
@@ -15,8 +22,8 @@ public class TokenProb {
|
||||
return tok;
|
||||
}
|
||||
|
||||
/** Returns the negative logarithmic probability. */
|
||||
public double getProb() {
|
||||
return prob;
|
||||
/** Returns the category from which this word was predicted. */
|
||||
public String getCategory() {
|
||||
return cat;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user