added fullFormLexicon in Java

This commit is contained in:
Krasimir Angelov
2017-08-30 08:08:19 +02:00
parent bee61fe4aa
commit 3e9de6ffbb
3 changed files with 9 additions and 4 deletions

View File

@@ -775,7 +775,7 @@ word form with its possible analyses:
Prelude PGF2> mapM_ print [(form,lemma,analysis,prob) | (form,analyses) <- fullFormLexicon eng, (lemma,analysis,prob) &lt- analyses]
</pre>
<pre class="java">
for (FullFormEntry entry in eng.fullFormLexicon()) { ///// TODO
for (FullFormEntry entry : eng.fullFormLexicon()) {
for (MorphoAnalysis analysis : entry.getAnalyses()) {
System.out.println(entry.getForm()+" "+analysis.getProb()+" "+analysis.getLemma()+" "+analysis.getField());
}

View File

@@ -1107,8 +1107,11 @@ Java_org_grammaticalframework_pgf_Lexicon_lookupWordPrefix
GuPool* pool = gu_new_pool();
GuExn* err = gu_new_exn(pool);
GuEnum* en = pgf_lookup_word_prefix(get_ref(env, jconcr), j2gu_string(env, prefix, pool),
pool, err);
GuEnum* en =
(prefix == NULL) ? pgf_fullform_lexicon(get_ref(env, jconcr),
pool)
: pgf_lookup_word_prefix(get_ref(env, jconcr), j2gu_string(env, prefix, pool),
pool, err);
if (!gu_ok(err)) {
if (gu_exn_caught(err, PgfExn)) {
GuString msg = (GuString) gu_exn_caught_data(err);

View File

@@ -70,7 +70,9 @@ public class Concr {
public native List<MorphoAnalysis> lookupMorpho(String sentence);
/** Creates an iterable over the full form lexicon in the grammar */
public native Iterable<FullFormEntry> fullFormLexicon();
public Iterable<FullFormEntry> fullFormLexicon() {
return new Lexicon(this, null);
}
/** Returns an iterable enumerating all words in the lexicon
* starting with a given prefix.