<!DOCTYPE article PUBLIC "-//NLM//DTD JATS (Z39.96) Journal Archiving and Interchange DTD v1.0 20120330//EN" "JATS-archivearticle1.dtd">
<article xmlns:xlink="http://www.w3.org/1999/xlink">
  <front>
    <journal-meta />
    <article-meta>
      <title-group>
        <article-title>Implementing Controlled Languages in GF</article-title>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author">
          <string-name>Aarne Ranta</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Krasimir Angelov</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <aff id="aff0">
          <label>0</label>
          <institution>Department of Computer Science and Engineering Chalmers University of Technology and University of Gothenburg</institution>
        </aff>
      </contrib-group>
      <abstract>
        <p>The paper introduces GF, Grammatical Framework, as a tool for implementing controlled languages. GF provides a high-level grammar formalism and a resource grammar library that make it easy to write grammars that cover similar fragments in several natural languages at the same time. Authoring help tools and automatic translation are provided for all grammars. As an example, a grammar of Attempto Controlled English is implemented and then ported to French, German, and Swedish.</p>
      </abstract>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>1 Introduction</title>
      <p>Controlled languages are fragments of natural languages. They are designed to be clear
and unambiguous. If they are mechanically processable, they have the benefits of formal
languages; moreover, since they look like natural languages, humans can understand
them without training. However, writing controlled language can be a problem, since
the author has to remain within a fragment whose limits she has to learn. Moreover,
implementing a controlled language on a computer requires a considerable effort, since
the syntax of even small fragments of natural languages is much more complex than the
syntax of formal languages.</p>
      <p>
        This paper addresses both the writing and the implementation problem, by using
GF
        <xref ref-type="bibr" rid="ref15">(Grammatical Framework, Ranta 2004)</xref>
        . GF is a multilingual grammar formalism,
which uses type-theoretical representations of semantic content and reversible
mappings from the content to various languages. These mappings work for both parsing and
generation; composing them gives automatic translation. The parsers moreover support
completion, which displays grammatically correct continuations to the user, thereby
helping her to stay within the fragment.
      </p>
      <p>Writing grammars in GF is helped by the resource grammar library (Ranta 2007),
a set of wide-coverage grammars currently implemented for 12 languages: Bulgarian,
Catalan, Danish, English, Finnish, French, German, Italian, Norwegian, Russian,
Spanish, and Swedish. The library takes care of linguistic details (inflection, agreement,
word order), allowing the grammarian to concentrate on the content.</p>
      <p>
        Starting with experiments
        <xref ref-type="bibr" rid="ref10">at Xerox (Dymetman &amp; al. 2000</xref>
        ), GF has been used
in numerous natural language applications: mathematical proof editing
        <xref ref-type="bibr" rid="ref9">(Hallgren and
Ranta 2000)</xref>
        , software specification authoring (Hähnle &amp; al. 2005), spoken dialogue
systems (Ranta and Cooper 2004, Lemon and Liu 2006, L
        <xref ref-type="bibr" rid="ref10">arsson and Ljunglöf 2008</xref>
        ),
translation of mathematical exercises (Caprotti 2006), multilingual Wiki p
        <xref ref-type="bibr" rid="ref10">ages (Meza
Moreno and Bringert 2008</xref>
        ), and multilingual generation in the cul
        <xref ref-type="bibr" rid="ref6">tural heritage domain
(Dannélls 2008</xref>
        ). Many of these applications can be described as domain-specific
controlled languages, but some of them are not controlled in all senses of the word; they
may, for instance, permit ambiguous input.
      </p>
      <p>
        In this paper, we will present a GF grammar for Attempto Controlled English (
        <xref ref-type="bibr" rid="ref10">ACE,
Attempto 2008</xref>
        ). We first implemented English as specified in the ACE documentation,
and then ported it to French German, and Swedish. Thus we can now translate Attempto
documents to all these languages, and use these languages to give input to Attempto
applications. We can also combine GF authoring tools with Attempto tools.
2
      </p>
    </sec>
    <sec id="sec-2">
      <title>Attempto in GF</title>
      <p>
        Our implementation of Attempto in GF follows the document "ACE 6.0 Construction
Rules" (
        <xref ref-type="bibr" rid="ref10">Attempto 2008</xref>
        ). The current grammar includes 98% of the syntactic
constructions reported there, as well as a lexicon containing the words that are used in the
examples in this document. The content word lexicon is a separate module that can easily be
replaced by the large Attempto lexicon, or some domain-specific terminology lexicon.
The more formal document "ACE 6.0 Synt
        <xref ref-type="bibr" rid="ref10">ax Report" (Attempto 2008</xref>
        ) was used as a
reference, but we did not follow it in detail; the main reason was that the Syntax Report
follows English too closely to be generalizable in the way we wanted.
      </p>
      <p>Following standard computer science concepts, GF distinguishes between abstract
syntax and concrete syntax. The abstract syntax is a system of trees, which encode the
structures of the language. It is up to the grammarian to decide if the tree structure is
semantic or syntactic, or something in between. As we followed the Attempto
construction rules, we ended up with structures with a rather syntactic flavour. In the resulting
grammar, the English sentence every rich customer is important receives the tree
(vpS (everyNP (adjCN (positAP rich_A) customer_CN))
(apVP (positAP important_A)))
Trees in GF are like Lisp terms: a tree is a function applied to zero or more trees; unlike
Lisp, GF trees are statically typed. The outermost function in the example tree is
vpS : NP -&gt; VP -&gt; S
which takes a noun phrase (NP) and a verb phrase (VP) to a sentence (S). An abstract
syntax in GF is a set of such functions and categories (basic types, such as NP); our
Attempto implementation has 28 categories and 120 (non-lexical) functions.</p>
      <p>A concrete syntax defines the linearizations of trees into strings and, more generally,
feature structures. Features are used for phenomena such as agreement and word order.
What features are needed depends heavily on language; the crucial property of GF (as
opposed to most grammar formalisms) is that the features are treated separately in each
concrete syntax, which enables a language-independent abstract syntax.</p>
      <p>Getting all details right in concrete syntax is highly non-trivial. This is where the
GF Resource Grammar Library comes in. When using the library, concrete syntax is not
written by using strings and features explicitly, but by calling functions in the library.
Thus the linearization of the predication rule of Attempto is simply</p>
      <p>lin vpS np vp = mkS presTense posPol (mkCl np vp)
The function mkCl takes a noun phrase and a verb phrase and builds a clause, whose
tense and polarity are not yet fixed. The function mkS is used to make it a present-tense
sentence with positive polarity. The grammar also uses mkS with the argument negPol
to express Attempto’s negative predication.</p>
      <p>The abstract syntax rules in the library are exactly the same for all 12 languages.
The Attempto syntax can therefore be implemented by using a shared parametrized
module (Ranta 2007). For example the German version is implemented as:
concrete AttemptoGer of Attempto = SymbolsC ** AttemptoI with
(Syntax = SyntaxGer),
(Symbolic = SymbolicGer),
(LexAttempto = LexAttemptoGer) ;
Here the main implementation module is AttemptoI. It provides the main
functionality but leaves some grammatical details unspecified. In fact in the implementation it
uses interfaces like Syntax and Symbolic as black boxes which are supposed to
deal with low-level details like the word order or the agreement in the target language.
When concrete language is selected (German in this case) the real implementations are
specified with the with clause. In this case the implementations for SyntaxGer and
SymbolicGer come from the resource library.</p>
      <p>This is not the case for the lexicon. Each language in the library has its own module
of inflection paradigms, since different pieces of information are needed to define the
inflection tables of words. To give an example, our Attempto lexicon has the abstract
syntax constant customer_N, which is linearized as follows:
mkN "customer" - English
mkN "client" - French
mkN "Kunde" "Kunden" masculine - German
mkN "kund" "kunder" - Swedish
Now we can map the example tree to English, French, German, and Swedish:
every rich customer is important
chaque client riche est important
jeder reiche Kunde ist wichtig
varje rik kund är viktig</p>
      <p>If syntactic combinations are implemented with a parametrized module, as in the
case of our Attempto grammar, adding a new language to a multilingual GF system
typically requires only a new implementation of the lexicon.</p>
      <p>In some cases, however, some changes are needed. It may happen that the new
language uses two different words in different contexts to express something that was a
single word before, just because it happened to be linearized in the same way in the
language that was the model of the first abstract syntax. This problem can mostly be
avoided when the development is guided by some language independent ontology,
instead of a particular language; this approach seems to be used in Attempto applications
as well.</p>
      <p>Another case in which more work is needed than just a new lexicon is when the
new target language uses different syntactic structures to express a certain
combination than those defined in the parametrized module. This problem is unavoidable, but
can be solved by simply overriding the parametrized solution in the language in
question. In our Attempto grammars, we didn’t use this possibility, but retained the same
constructions in all languages.
3</p>
    </sec>
    <sec id="sec-3">
      <title>Authoring Tools</title>
      <p>
        Most controlled language systems provide some kinds of authoring tools which guides
the user how to stay within the scope of the grammar. The following picture shows a
translator client using a GF web server. It has a completion parser, which here shows
grammatically correct completions of the letter B in the middle of a German sentence.
The system uses the parsing algorithm described in
        <xref ref-type="bibr" rid="ref1">(Angelov 2009)</xref>
        and the web
application toolkit described in (Bringert &amp; al. 2009).
      </p>
      <p>Usually tools like this work with context-free grammar and top-down incremental
parser. The problem with this is that the context-free grammars cannot represent well
all naturall languages. Even if this somehow works for English, it becomes hopeless for
languages with more complicated structure. The parser that we use works directly with
full GF and can therefore successfully handle long distance relations and discontinuous
phrases.
4</p>
    </sec>
    <sec id="sec-4">
      <title>Results</title>
      <p>Writing the GF implementation was quick and mostly smooth. The main problem was
that some ACE structures are not quite correct in standard English, and therefore not
covered by the library. One example is negated noun phrases, especially in the object
position: John meets not every customer. Porting the grammar to other languages was
made in the simplest possible way, by using a parametrized module. The result is mostly
acceptable: grammatically correct but sometimes strange, especially for constructs like
not every. This could be improved by making the concrete syntaxes more unlike
Attempto English than we did. On the other hand, since Attempto French, German, and
Swedish are artificial languages anyway, such artificialities might well be tolerable in
them, as long as they can be understood without training.</p>
      <p>The Attempto project has a system for parsing Attempto English, interpreting it
semantically, and generating it from formal descriptions such as ontologies. Similar
facilities can been defined in GF as well. However, in the case of Attempto this is not
necessary: we can quite as well rely on Attempto tools and use GF just as a translation
and authoring tool. Then we can communicate with Attempto tools by using Attempto
English (which is unambiguous): translate Attempto French, German, and Swedish to
English by using GF, and continue processing with Attempto tools. In the other
direction, we can generate Attempto English from logical descriptions using Attempto tools,
and then translate the results to French, German, and Swedish with GF.</p>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          <string-name>
            <surname>Angelov</surname>
            ,
            <given-names>K.</given-names>
          </string-name>
          (
          <year>2009</year>
          ).
          <article-title>Incremental Parsing with Parallel Multiple Context-Free Gram-</article-title>
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          <string-name>
            <surname>mars. In EACL</surname>
          </string-name>
          , Athens, Greece, to appear.
          <source>Attempto</source>
          (
          <year>2008</year>
          ).
          <article-title>Attempto Project Homepage</article-title>
          . attempto.ifi.uzh.ch/site/. Bringert,
          <string-name>
            <surname>B.</surname>
          </string-name>
          ,
          <string-name>
            <given-names>K.</given-names>
            <surname>Angelov</surname>
          </string-name>
          ,
          <article-title>and</article-title>
          <string-name>
            <given-names>A</given-names>
            .
            <surname>Ranta</surname>
          </string-name>
          (
          <year>2009</year>
          ). Grammatical Framework Web Ser-
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          <article-title>vice, System demo</article-title>
          .
          <source>In EACL</source>
          , Athens, Greece, to appear. Caprotti,
          <string-name>
            <surname>O.</surname>
          </string-name>
          (
          <year>2006</year>
          ).
          <article-title>WebALT! Deliver Mathematics Everywhere</article-title>
          .
          <source>In Proceedings of</source>
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          <string-name>
            <surname>SITE</surname>
          </string-name>
          <year>2006</year>
          .
          <source>Orlando March</source>
          <volume>20</volume>
          -24 . Dannélls,
          <string-name>
            <surname>D.</surname>
          </string-name>
          (
          <year>2008</year>
          ).
          <article-title>Generating Tailored Texts for Museum Exhibits</article-title>
          . In Proceed-
        </mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>
          <source>ings of the 6th edition of LREC. The 2nd Workshop on Language Technology for Cul-</source>
        </mixed-citation>
      </ref>
      <ref id="ref6">
        <mixed-citation>
          <string-name>
            <surname>tural Heritage</surname>
          </string-name>
          (LaTeCH
          <year>2008</year>
          ), Marrakech, Morocco, pp.
          <fpage>17</fpage>
          -
          <lpage>20</lpage>
          . Dymetman,
          <string-name>
            <surname>M.</surname>
          </string-name>
          ,
          <string-name>
            <given-names>V.</given-names>
            <surname>Lux</surname>
          </string-name>
          ,
          <article-title>and</article-title>
          <string-name>
            <given-names>A</given-names>
            .
            <surname>Ranta</surname>
          </string-name>
          (
          <year>2000</year>
          ).
          <article-title>XML and multilingual document</article-title>
        </mixed-citation>
      </ref>
      <ref id="ref7">
        <mixed-citation>
          <article-title>authoring: Convergent trends</article-title>
          . In COLING, Saarbrücken, Germany, pp.
          <fpage>243</fpage>
          -
          <lpage>249</lpage>
          . Hähnle, R.,
          <string-name>
            <given-names>K.</given-names>
            <surname>Johannisson</surname>
          </string-name>
          ,
          <article-title>and</article-title>
          <string-name>
            <given-names>A</given-names>
            .
            <surname>Ranta</surname>
          </string-name>
          (
          <year>2002</year>
          ).
          <article-title>An Authoring Tool for Infor-</article-title>
        </mixed-citation>
      </ref>
      <ref id="ref8">
        <mixed-citation>
          Fundamental Approaches to Software Engineering, Vol.
          <volume>2306</volume>
          of LNCS, pp.
          <fpage>233</fpage>
          -
          <lpage>248</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref9">
        <mixed-citation>
          Springer. Hallgren,
          <string-name>
            <surname>T.</surname>
          </string-name>
          and
          <string-name>
            <given-names>A</given-names>
            .
            <surname>Ranta</surname>
          </string-name>
          (
          <year>2000</year>
          ).
          <article-title>An extensible proof text editor</article-title>
          .
          <source>In M. Parigot and</source>
        </mixed-citation>
      </ref>
      <ref id="ref10">
        <mixed-citation>
          <string-name>
            <given-names>A.</given-names>
            <surname>Voronkov</surname>
          </string-name>
          (Eds.),
          <source>LPAR-2000</source>
          , Vol.
          <year>1955</year>
          of LNCS/LNAI, pp.
          <fpage>70</fpage>
          -
          <lpage>84</lpage>
          . Springer. Larsson,
          <string-name>
            <surname>S.</surname>
          </string-name>
          and
          <string-name>
            <given-names>P.</given-names>
            <surname>Ljunglöf</surname>
          </string-name>
          (
          <year>2008</year>
          ).
          <article-title>A grammar formalism for specifying ISU-based</article-title>
        </mixed-citation>
      </ref>
      <ref id="ref11">
        <mixed-citation>
          <string-name>
            <surname>Processing</surname>
          </string-name>
          (GoTAL
          <year>2008</year>
          ), Vol.
          <volume>5221</volume>
          of LNCS/LNAI, pp.
          <fpage>303</fpage>
          -
          <lpage>314</lpage>
          . Lemon,
          <string-name>
            <surname>O.</surname>
          </string-name>
          and
          <string-name>
            <given-names>X.</given-names>
            <surname>Liu</surname>
          </string-name>
          (
          <year>2006</year>
          ).
          <article-title>DUDE: a Dialogue and Understanding Development</article-title>
        </mixed-citation>
      </ref>
      <ref id="ref12">
        <mixed-citation>
          <string-name>
            <surname>systems. In EACL</surname>
          </string-name>
          2006. Meza Moreno,
          <string-name>
            <surname>M. S.</surname>
          </string-name>
          and
          <string-name>
            <given-names>B.</given-names>
            <surname>Bringert</surname>
          </string-name>
          (
          <year>2008</year>
          ). Interactive Multilingual Web Applica-
        </mixed-citation>
      </ref>
      <ref id="ref13">
        <mixed-citation>
          <string-name>
            <surname>Natural Language Processing</surname>
          </string-name>
          (GoTAL
          <year>2008</year>
          ), Vol.
          <volume>5221</volume>
          of LNCS/LNAI, pp.
          <fpage>336</fpage>
          -
          <lpage>347</lpage>
          . Ranta,
          <string-name>
            <surname>A.</surname>
          </string-name>
          (
          <year>2004</year>
          ). Grammatical Framework:
          <string-name>
            <given-names>A</given-names>
            <surname>Type-Theoretical Grammar</surname>
          </string-name>
          Formal-
        </mixed-citation>
      </ref>
      <ref id="ref14">
        <mixed-citation>
          ism.
          <source>The Journal of Functional Programming</source>
          <volume>14</volume>
          (
          <issue>2</issue>
          ),
          <fpage>145</fpage>
          -
          <lpage>189</lpage>
          . Ranta,
          <string-name>
            <surname>A.</surname>
          </string-name>
          (
          <year>2007</year>
          ). Modular Grammar Engineering in GF. Research on Language
        </mixed-citation>
      </ref>
      <ref id="ref15">
        <mixed-citation>
          <source>and Computation</source>
          <volume>5</volume>
          ,
          <fpage>133</fpage>
          -
          <lpage>158</lpage>
          . Ranta,
          <string-name>
            <surname>A.</surname>
          </string-name>
          and
          <string-name>
            <given-names>R.</given-names>
            <surname>Cooper</surname>
          </string-name>
          (
          <year>2004</year>
          ).
          <article-title>Dialogue Systems as Proof Editors</article-title>
          .
          <source>Journal of</source>
        </mixed-citation>
      </ref>
      <ref id="ref16">
        <mixed-citation>
          <string-name>
            <surname>Logic</surname>
          </string-name>
          ,
          <source>Language and Information</source>
          <volume>13</volume>
          ,
          <fpage>225</fpage>
          -
          <lpage>240</lpage>
          .
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>