added getFunctionProb in the Java and C API

This commit is contained in:
krasimir
2016-05-30 11:25:59 +00:00
parent a00532d5e4
commit 3381ae1aa0
4 changed files with 32 additions and 0 deletions

View File

@@ -178,6 +178,18 @@ Java_org_grammaticalframework_pgf_PGF_getFunctionType(JNIEnv* env, jobject self,
return jtype;
}
JNIEXPORT jdouble JNICALL
Java_org_grammaticalframework_pgf_PGF_getFunctionProb(JNIEnv* env, jobject self, jstring jid)
{
PgfPGF* pgf = get_ref(env, self);
GuPool* tmp_pool = gu_local_pool();
PgfCId id = j2gu_string(env, jid, tmp_pool);
double prob = pgf_function_prob(pgf, id);
gu_pool_free(tmp_pool);
return prob;
}
typedef struct {
GuMapItor fn;
JNIEnv *env;

View File

@@ -42,6 +42,12 @@ public class PGF {
*/
public native Type getFunctionType(String fun);
/** Returns the negative logarithmic probability of the function
* with the given name.
* @param fun The name of the function.
*/
public native double getFunctionProb(String fun);
/** Returns an iterable over the set of all expression in
* the given category. The expressions are enumerated in decreasing
* probability order.