1
0
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:
krasimir
2016-05-25 12:39:51 +00:00
parent a3de37f3c7
commit e81b39a300
2 changed files with 14 additions and 7 deletions

View File

@@ -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;
}

View File

@@ -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;
}
}