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;
|
return NULL;
|
||||||
|
|
||||||
jclass tp_class = (*env)->FindClass(env, "org/grammaticalframework/pgf/TokenProb");
|
jclass tp_class = (*env)->FindClass(env, "org/grammaticalframework/pgf/TokenProb");
|
||||||
jmethodID tp_constrId = (*env)->GetMethodID(env, tp_class, "<init>", "(Ljava/lang/String;D)V");
|
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, gu2j_string(env,tp->tok), tp->prob);
|
jobject jtp = (*env)->NewObject(env, tp_class, tp_constrId, tp->prob, gu2j_string(env,tp->tok), gu2j_string(env,tp->cat));
|
||||||
|
|
||||||
return jtp;
|
return jtp;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,11 +3,18 @@ package org.grammaticalframework.pgf;
|
|||||||
/** Simply a pair of an expression and a probability value. */
|
/** Simply a pair of an expression and a probability value. */
|
||||||
public class TokenProb {
|
public class TokenProb {
|
||||||
private String tok;
|
private String tok;
|
||||||
|
private String cat;
|
||||||
private double prob;
|
private double prob;
|
||||||
|
|
||||||
public TokenProb(String tok, double prob) {
|
public TokenProb(double prob, String tok, String cat) {
|
||||||
this.tok = tok;
|
|
||||||
this.prob = prob;
|
this.prob = prob;
|
||||||
|
this.tok = tok;
|
||||||
|
this.cat = cat;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Returns the negative logarithmic probability. */
|
||||||
|
public double getProb() {
|
||||||
|
return prob;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns the token. */
|
/** Returns the token. */
|
||||||
@@ -15,8 +22,8 @@ public class TokenProb {
|
|||||||
return tok;
|
return tok;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns the negative logarithmic probability. */
|
/** Returns the category from which this word was predicted. */
|
||||||
public double getProb() {
|
public String getCategory() {
|
||||||
return prob;
|
return cat;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user