mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-05-20 00:22:51 -06:00
linearization in the Java binding
This commit is contained in:
@@ -20,8 +20,10 @@ public class Test {
|
|||||||
System.out.println(entry.getKey()+" "+entry.getValue()+" "+entry.getValue().getName());
|
System.out.println(entry.getKey()+" "+entry.getValue()+" "+entry.getValue().getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
for (ExprProb ep : gr.getLanguages().get("ParseEng").parse("Phr", "test")) {
|
Concr eng = gr.getLanguages().get("ParseEng");
|
||||||
|
for (ExprProb ep : eng.parse("Phr", "where are you")) {
|
||||||
System.out.println("["+ep.getProb()+"] "+ep.getExpr());
|
System.out.println("["+ep.getProb()+"] "+ep.getExpr());
|
||||||
|
System.out.println(eng.linearize(ep.getExpr()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -244,6 +244,28 @@ Java_org_grammaticalframework_pgf_ExprIterator_fetchExprProb
|
|||||||
return jexpprob;
|
return jexpprob;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
JNIEXPORT jstring JNICALL
|
||||||
|
Java_org_grammaticalframework_pgf_Concr_linearize(JNIEnv* env, jobject self, jobject jexpr)
|
||||||
|
{
|
||||||
|
GuPool* tmp_pool = gu_local_pool();
|
||||||
|
GuExn* err = gu_new_exn(NULL, gu_kind(type), tmp_pool);
|
||||||
|
GuStringBuf* sbuf = gu_string_buf(tmp_pool);
|
||||||
|
GuWriter* wtr = gu_string_buf_writer(sbuf);
|
||||||
|
|
||||||
|
pgf_linearize(get_ref(env, self), gu_variant_from_ptr((void*) get_ref(env, jexpr)), wtr, err);
|
||||||
|
if (!gu_ok(err)) {
|
||||||
|
//
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
GuString str = gu_string_buf_freeze(sbuf, tmp_pool);
|
||||||
|
jstring jstr = gu2j_string(env, str);
|
||||||
|
|
||||||
|
gu_pool_free(tmp_pool);
|
||||||
|
|
||||||
|
return jstr;
|
||||||
|
}
|
||||||
|
|
||||||
JNIEXPORT void JNICALL
|
JNIEXPORT void JNICALL
|
||||||
Java_org_grammaticalframework_pgf_Pool_free(JNIEnv* env, jobject self, jlong ref)
|
Java_org_grammaticalframework_pgf_Pool_free(JNIEnv* env, jobject self, jlong ref)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -10,6 +10,8 @@ public class Concr {
|
|||||||
return new Parser(this, startCat, s);
|
return new Parser(this, startCat, s);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public native String linearize(Expr expr);
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////
|
||||||
// private stuff
|
// private stuff
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user