diff --git a/lib/src/abstract/Documentation.gf b/lib/src/abstract/Documentation.gf index 22771a59c..3c959bbe5 100644 --- a/lib/src/abstract/Documentation.gf +++ b/lib/src/abstract/Documentation.gf @@ -5,6 +5,7 @@ abstract Documentation = Cat ** { cat Inflection ; -- inflection table + Definition ; Document ; Tag ; @@ -29,7 +30,12 @@ fun InflectionPrep : Prep -> Inflection ; fun - MkDocument : String -> Inflection -> String -> Document ; + NoDefinition : Definition ; + MkDefinition : String -> Definition ; + MkDefinitionEx : String -> String -> Definition ; + +fun + MkDocument : Definition -> Inflection -> String -> Document ; MkTag : Inflection -> Tag ; } diff --git a/lib/src/bulgarian/DocumentationBul.gf b/lib/src/bulgarian/DocumentationBul.gf index a3bcaabfa..5ba52d9d1 100644 --- a/lib/src/bulgarian/DocumentationBul.gf +++ b/lib/src/bulgarian/DocumentationBul.gf @@ -6,6 +6,7 @@ flags coding=utf8 ; lincat Inflection = {t : Str; s1,s2,s3 : Str} ; + Definition = {s : Str} ; Document = {s : Str} ; Tag = {s : Str} ; @@ -390,7 +391,12 @@ oper pp : Str -> Str = \s -> "<"+s+">"; lin - MkDocument b i e = {s = i.s1 ++ "

"++b.s++"

" ++ i.s2 ++ i.s3 ++ e.s} ; + NoDefinition = {s=""}; + MkDefinition d = {s="

Дефиниция:"++d.s++"

"}; + MkDefinitionEx d e = {s="

Дефиниция:"++d.s++"

Пример:"++e.s++"

"}; + +lin + MkDocument d i e = {s = i.s1 ++ d.s ++ i.s2 ++ i.s3 ++ e.s} ; MkTag i = {s = i.t} ; } diff --git a/lib/src/catalan/DocumentationCatFunctor.gf b/lib/src/catalan/DocumentationCatFunctor.gf index 1e9dca2b6..b9c72db3d 100644 --- a/lib/src/catalan/DocumentationCatFunctor.gf +++ b/lib/src/catalan/DocumentationCatFunctor.gf @@ -16,6 +16,7 @@ flags coding=utf8 ; lincat Inflection = {t : Str; s1,s2 : Str} ; + Definition = {s : Str} ; Document = {s : Str} ; Tag = {s : Str} ; @@ -132,7 +133,12 @@ lin s2 = inflVerb v } ; - MkDocument b i e = ss (i.s1 ++ "

"++b.s++"

" ++ i.s2 ++ paragraph e.s) ; -- explanation appended in a new paragraph +lin + NoDefinition = {s=""}; + MkDefinition d = {s="

Definició:"++d.s++"

"}; + MkDefinitionEx d e = {s="

Definició:"++d.s++"

Exemple:"++e.s++"

"}; + + MkDocument d i e = ss (i.s1 ++ d.s ++ i.s2 ++ paragraph e.s) ; -- explanation appended in a new paragraph MkTag i = ss i.t ; oper diff --git a/lib/src/chinese/DocumentationChi.gf b/lib/src/chinese/DocumentationChi.gf index 216f3af10..67cc2b25a 100644 --- a/lib/src/chinese/DocumentationChi.gf +++ b/lib/src/chinese/DocumentationChi.gf @@ -5,6 +5,7 @@ in { lincat Inflection = {t : Str; s1,s2 : Str} ; + Definition = {s : Str} ; Document = {s : Str} ; Tag = {s : Str} ; @@ -124,7 +125,12 @@ oper pp : Str -> Str = \s -> "<"+s+">" ; lin - MkDocument b i e = {s=i.s1 ++ "

"++b.s++"

" ++ i.s2 ++ paragraph e.s} ; + NoDefinition = {s=""}; + MkDefinition d = {s="

定义:"++d.s++"

"}; + MkDefinitionEx d e = {s="

定义:"++d.s++"

例子:"++e.s++"

"}; + +lin + MkDocument d i e = {s=i.s1 ++ d.s ++ i.s2 ++ paragraph e.s} ; MkTag i = {s=i.t} ; } diff --git a/lib/src/dutch/DocumentationDutFunctor.gf b/lib/src/dutch/DocumentationDutFunctor.gf index 9cda67211..cc712c171 100644 --- a/lib/src/dutch/DocumentationDutFunctor.gf +++ b/lib/src/dutch/DocumentationDutFunctor.gf @@ -14,6 +14,7 @@ in { lincat Inflection = {t : Str; s1,s2 : Str} ; + Definition = {s : Str} ; Document = {s : Str} ; Tag = {s : Str} ; @@ -140,7 +141,12 @@ lin s2 = inflVerb v } ; - MkDocument b i e = ss (i.s1 ++ "

"++b.s++"

" ++ i.s2 ++ paragraph e.s) ; -- explanation appended in a new paragraph +lin + NoDefinition = {s=""}; + MkDefinition d = {s="

Definitie:"++d.s++"

"}; + MkDefinitionEx d e = {s="

Definitie:"++d.s++"

Voorbeeld:"++e.s++"

"}; + + MkDocument d i e = ss (i.s1 ++ d.s ++ i.s2 ++ paragraph e.s) ; -- explanation appended in a new paragraph MkTag i = ss i.t ; oper diff --git a/lib/src/english/DocumentationEng.gf b/lib/src/english/DocumentationEng.gf index 8cbb46bc3..b86573820 100644 --- a/lib/src/english/DocumentationEng.gf +++ b/lib/src/english/DocumentationEng.gf @@ -5,6 +5,7 @@ concrete DocumentationEng of Documentation = CatEng ** open lincat Inflection = {t : Str; s1,s2 : Str} ; + Definition = {s : Str} ; Document = {s : Str} ; Tag = {s : Str} ; @@ -178,7 +179,12 @@ oper pp : Str -> Str = \s -> "<"+s+">"; lin - MkDocument b i e = {s = i.s1 ++ paragraph b.s ++ i.s2 ++ paragraph e.s} ; + NoDefinition = {s=""}; + MkDefinition d = {s="

Definition:"++d.s++"

"}; + MkDefinitionEx d e = {s="

Definition:"++d.s++"

Example:"++e.s++"

"}; + +lin + MkDocument d i e = {s = i.s1 ++ d.s ++ i.s2 ++ paragraph e.s} ; MkTag i = {s = i.t} ; } diff --git a/lib/src/estonian/DocumentationEstFunctor.gf b/lib/src/estonian/DocumentationEstFunctor.gf index c1eb44704..5215a206e 100644 --- a/lib/src/estonian/DocumentationEstFunctor.gf +++ b/lib/src/estonian/DocumentationEstFunctor.gf @@ -13,6 +13,7 @@ in { lincat Inflection = {t : Str; s1,s2 : Str} ; + Definition = {s : Str} ; Document = {s : Str} ; Tag = {s : Str} ; @@ -263,6 +264,11 @@ oper tr (th (heading instructive_Parameter) ++ td (nouns (NCase Sg Termin)) ++ td (nouns (NCase Pl Termin)) )) ; +lin + NoDefinition = {s=""}; + MkDefinition d = {s="

Definitsioon:"++d.s++"

"}; + MkDefinitionEx d e = {s="

Definitsioon:"++d.s++"

Eeskuju:"++e.s++"

"}; + lin MkDocument b i e = ss (i.s1 ++ paragraph b.s ++ i.s2 ++ paragraph e.s) ; -- explanation appended in a new paragraph MkTag i = ss (i.t) ; diff --git a/lib/src/finnish/DocumentationFinFunctor.gf b/lib/src/finnish/DocumentationFinFunctor.gf index 78902ec81..e91ae0520 100644 --- a/lib/src/finnish/DocumentationFinFunctor.gf +++ b/lib/src/finnish/DocumentationFinFunctor.gf @@ -14,6 +14,7 @@ in { lincat Inflection = {t : Str; s1,s2 : Str} ; + Definition = {s : Str} ; Document = {s : Str} ; Tag = {s : Str} ; @@ -290,7 +291,12 @@ oper ) ; lin - MkDocument b i e = ss (i.s1 ++ "

"++b.s++"

" ++ i.s2 ++ paragraph e.s) ; -- explanation appended in a new paragraph + NoDefinition = {s=""}; + MkDefinition d = {s="

Rajaus:"++d.s++"

"}; + MkDefinitionEx d e = {s="

Rajaus:"++d.s++"

Esimerkki:"++e.s++"

"}; + +lin + MkDocument d i e = ss (i.s1 ++ d.s ++ i.s2 ++ paragraph e.s) ; -- explanation appended in a new paragraph MkTag i = ss (i.t) ; {- --# notpresent diff --git a/lib/src/french/DocumentationFreFunctor.gf b/lib/src/french/DocumentationFreFunctor.gf index 08e1c2cd2..07efac4c8 100644 --- a/lib/src/french/DocumentationFreFunctor.gf +++ b/lib/src/french/DocumentationFreFunctor.gf @@ -16,6 +16,7 @@ flags coding=utf8 ; lincat Inflection = {t : Str; s1,s2 : Str} ; + Definition = {s : Str} ; Document = {s : Str} ; Tag = {s : Str} ; @@ -132,7 +133,12 @@ lin s2 = inflVerb v } ; - MkDocument b i e = ss (i.s1 ++ "

"++b.s++"

" ++ i.s2 ++ paragraph e.s) ; -- explanation appended in a new paragraph +lin + NoDefinition = {s=""}; + MkDefinition d = {s="

Définition:"++d.s++"

"}; + MkDefinitionEx d e = {s="

Définition:"++d.s++"

Exemple:"++e.s++"

"}; + + MkDocument d i e = ss (i.s1 ++ d.s ++ i.s2 ++ paragraph e.s) ; -- explanation appended in a new paragraph MkTag i = ss i.t ; oper diff --git a/lib/src/german/DocumentationGerFunctor.gf b/lib/src/german/DocumentationGerFunctor.gf index 2d58b4258..f9e9ed753 100644 --- a/lib/src/german/DocumentationGerFunctor.gf +++ b/lib/src/german/DocumentationGerFunctor.gf @@ -15,6 +15,7 @@ flags coding=utf8 ; lincat Inflection = {t : Str; s1,s2 : Str} ; + Definition = {s : Str} ; Document = {s : Str} ; Tag = {s : Str} ; @@ -144,7 +145,12 @@ lin s2 = inflVerb v } ; - MkDocument b i e = ss (i.s1 ++ "

"++b.s++"

" ++ i.s2 ++ paragraph e.s) ; -- explanation appended in a new paragraph +lin + NoDefinition = {s=""}; + MkDefinition d = {s="

Definierung:"++d.s++"

"}; + MkDefinitionEx d e = {s="

Definierung:"++d.s++"

Beispiel:"++e.s++"

"}; + + MkDocument d i e = ss (i.s1 ++ d.s ++ i.s2 ++ paragraph e.s) ; -- explanation appended in a new paragraph MkTag i = ss i.t ; oper diff --git a/lib/src/hindi/DocumentationHin.gf b/lib/src/hindi/DocumentationHin.gf index abd0ad44b..87fb38c9c 100644 --- a/lib/src/hindi/DocumentationHin.gf +++ b/lib/src/hindi/DocumentationHin.gf @@ -6,6 +6,7 @@ in { lincat Inflection = {t : Str; s1,s2 : Str} ; + Definition = {s : Str} ; Document = {s : Str} ; Tag = {s : Str} ; @@ -120,7 +121,12 @@ lin } ; lin - MkDocument b i e = {s = i.s1 ++ "

"++b.s++"

" ++ i.s2 ++ paragraph e.s} ; + NoDefinition = {s=""}; + MkDefinition d = {s="

परिभाषा:"++d.s++"

"}; + MkDefinitionEx d e = {s="

परिभाषा:"++d.s++"

नमूना:"++e.s++"

"}; + +lin + MkDocument d i e = {s = i.s1 ++ d.s ++ i.s2 ++ paragraph e.s} ; MkTag i = {s = i.t} ; } diff --git a/lib/src/italian/DocumentationItaFunctor.gf b/lib/src/italian/DocumentationItaFunctor.gf index 07f664efd..964543dac 100644 --- a/lib/src/italian/DocumentationItaFunctor.gf +++ b/lib/src/italian/DocumentationItaFunctor.gf @@ -16,6 +16,7 @@ flags coding=utf8 ; lincat Inflection = {t : Str; s1,s2 : Str} ; + Definition = {s : Str} ; Document = {s : Str} ; Tag = {s : Str} ; @@ -132,7 +133,13 @@ lin s2 = inflVerb v } ; - MkDocument b i e = ss (i.s1 ++ "

"++b.s++"

" ++ i.s2 ++ paragraph e.s) ; -- explanation appended in a new paragraph +lin + NoDefinition = {s=""}; + MkDefinition d = {s="

Definizione:"++d.s++"

"}; + MkDefinitionEx d e = {s="

Definizione:"++d.s++"

Esempio:"++e.s++"

"}; + +lin + MkDocument d i e = ss (i.s1 ++ d.s ++ i.s2 ++ paragraph e.s) ; -- explanation appended in a new paragraph MkTag i = ss i.t ; oper diff --git a/lib/src/spanish/DocumentationSpaFunctor.gf b/lib/src/spanish/DocumentationSpaFunctor.gf index 04d17bb79..3fa6a3ed8 100644 --- a/lib/src/spanish/DocumentationSpaFunctor.gf +++ b/lib/src/spanish/DocumentationSpaFunctor.gf @@ -16,6 +16,7 @@ flags coding=utf8 ; lincat Inflection = {t : Str; s1,s2 : Str} ; + Definition = {s : Str} ; Document = {s : Str} ; Tag = {s : Str} ; @@ -132,6 +133,12 @@ lin s2 = inflVerb v } ; +lin + NoDefinition = {s=""}; + MkDefinition d = {s="

Definición:"++d.s++"

"}; + MkDefinitionEx d e = {s="

Definición:"++d.s++"

Ejemplo:"++e.s++"

"}; + +lin MkDocument b i e = ss (i.s1 ++ "

"++b.s++"

" ++ i.s2 ++ paragraph e.s) ; -- explanation appended in a new paragraph MkTag i = ss i.t ; diff --git a/lib/src/swedish/DocumentationSwe.gf b/lib/src/swedish/DocumentationSwe.gf index 3f531a8b0..b6068f64c 100644 --- a/lib/src/swedish/DocumentationSwe.gf +++ b/lib/src/swedish/DocumentationSwe.gf @@ -6,6 +6,7 @@ in { flags coding=utf8 ; lincat Inflection = {t : Str; s1,s2 : Str} ; + Definition = {s : Str} ; Document = {s : Str} ; Tag = {s : Str} ; @@ -178,7 +179,12 @@ lin s2 = inflVerb v } ; - MkDocument b i e = {s = i.s1 ++ "

"++b.s++"

" ++ i.s2 ++ paragraph e.s} ; -- explanation appended in a new paragraph +lin + NoDefinition = {s=""}; + MkDefinition d = {s="

Definition:"++d.s++"

"}; + MkDefinitionEx d e = {s="

Definition:"++d.s++"

Exempel:"++e.s++"

"}; + + MkDocument d i e = {s = i.s1 ++ d.s ++ i.s2 ++ paragraph e.s} ; -- explanation appended in a new paragraph MkTag i = {s = i.t} ; oper diff --git a/src/ui/android/src/org/grammaticalframework/ui/android/SemanticGraphManager.java b/src/ui/android/src/org/grammaticalframework/ui/android/SemanticGraphManager.java index 19080dfef..0d5d5e227 100644 --- a/src/ui/android/src/org/grammaticalframework/ui/android/SemanticGraphManager.java +++ b/src/ui/android/src/org/grammaticalframework/ui/android/SemanticGraphManager.java @@ -76,22 +76,39 @@ public class SemanticGraphManager implements Closeable { } } - public Expr getGloss(Expr lemma) { - Expr obj = null; + public Expr getDefinition(Expr lemma, boolean withExample) { + Expr gloss = null; + Expr example = null; try { createDatabaseFromAssets(); - TripleResult res = mDB.queryTriple(lemma, Expr.readExpr("gloss"), null); - if (res.hasNext()) { - obj = res.getObject(); + + { + TripleResult res = mDB.queryTriple(lemma, Expr.readExpr("gloss"), null); + if (res.hasNext()) { + gloss = res.getObject(); + } + res.close(); + } + + if (withExample) { + TripleResult res = mDB.queryTriple(lemma, Expr.readExpr("example"), null); + if (res.hasNext()) { + example = res.getObject(); + } + res.close(); } - res.close(); } catch (IOException e) { // nothing } catch (SGError e) { // nothing } - return obj; + if (gloss == null) + return null; + else if (example == null) + return new Expr("MkDefinition", gloss); + else + return new Expr("MkDefinitionEx", gloss, example); } } diff --git a/src/ui/android/src/org/grammaticalframework/ui/android/Translator.java b/src/ui/android/src/org/grammaticalframework/ui/android/Translator.java index aaae8368f..e6d5362f3 100644 --- a/src/ui/android/src/org/grammaticalframework/ui/android/Translator.java +++ b/src/ui/android/src/org/grammaticalframework/ui/android/Translator.java @@ -367,26 +367,31 @@ public class Translator { } public String getInflectionTable(String lemma) { - Expr lemmaExpr = Expr.readExpr(lemma); - Expr gloss = mSGManager.getGloss(lemmaExpr); - Expr empty = Expr.readExpr("\"\""); + boolean withExample = + (getSourceLanguage().getLangCode().equals("en-US") || + getTargetLanguage().getLangCode().equals("en-US")); + Expr def = + mSGManager.getDefinition(Expr.readExpr(lemma), withExample); Concr targetLang = getTargetConcr(); String cat = getGrammar().getFunctionType(lemma).getCategory(); if (targetLang.hasLinearization(lemma) && targetLang.hasLinearization("Inflection"+cat)) { - if (gloss == null) - gloss = empty; + if (def == null) + def = new Expr("NoDefinition"); - Expr e = new Expr("MkDocument", gloss, Expr.readExpr("Inflection"+cat+" "+lemma), empty); + Expr e = new Expr("MkDocument", + def, + Expr.readExpr("Inflection"+cat+" "+lemma), + Expr.readExpr("\"\"")); String html = "" + targetLang.linearize(e) + ""; return html; - } else if (gloss != null) { - return "

"+targetLang.linearize(gloss)+"

"; + } else if (def != null) { + return targetLang.linearize(def); } else { return null; }