1
0
forked from GitHub/gf-core
This commit is contained in:
Krasimir Angelov
2018-06-16 07:09:17 +02:00
33 changed files with 389 additions and 6967 deletions

View File

@@ -1,23 +0,0 @@
-- Use darcs show authors to see the number of patches per person
Aarne Ranta <aarne@chalmers.se>, aarne@cs.chalmers.se, aarne
Björn Bringert <bjorn@bringert.net>, bringert@cs.chalmers.se, bringert
Krasimir Angelov <krasimir@chalmers.se>, kr.angelov@chalmers.se,kr.angelov@gmail.com,kr_angelov@gmail.com
Peter Ljunglöf <peb@ling.gu.se>, peb,peb@cs.chalmers.se
Thomas Hallgren <hallgren@chalmers.se>, hallgren@altocumulus.org
Janna Khegai <janna@cs.chalmer.se>, janna,janna@cs.chalmers.se
Jordi Saludes <jordi.saludes@upc.edu>
Ramona Enache <ramona.enache@chalmers.se>, ra.monique@gmail.com
Hans-Joachim Daniels <hdaniels>
Jean-Philippe Bernardy <bernardy@chalmers.se>
Kevin Kofler <kevin.kofler@chello.at>
Harald Hammarström <harald2>
Olga Caprotti <caprotti@chalmers.se>, olga.caprotti@gmail.com
Adam Slaski <adam.slaski@gmail.com>, Adam Slaski <adam.slaski@gmail.com>
Moisés Salvador Meza Moreno<meza@student.chalmers.se>, 'Moises Meza <meza@student.chalmers.se>'
Ali El Dada <eldada@student.chalmers.se>, 'ali.eldada@gmail.com'
Markus Forsberg <markus>
Server Cimen <e1560697@ceng.metu.edu.tr>
Grégoire Détrez <gdetrez@crans.org>
Ketil Malde <ketil@ii.uib.no>
John J. Camilleri <john.j.camilleri@chalmers.se>, john@johnjcamilleri.com, john

View File

@@ -1,43 +0,0 @@
/* Found it at http://article.olduse.net/771@mit-eddie.UUCP */
@font-face {
font-family: GlassTTYVT220;
src: local("Glass TTY VT220"), local("Glass TTY VT220 Medium"), url(/font/Glass_TTY_VT220.ttf) format("truetype");
}
body {
font-size: 20px;
font-family: GlassTTYVT220;
color: #e5b800;
background-color: #0a0600;
}
h1,h2,h3,h4 { font-size: 20px; }
img.logo, img.grow { display: none; }
a { color: #ecc800; }
a:hover { color: #fcd800; }
div.links {
display: inline-block;
vertical-align: top;
margin-right: 1em;
}
table.news td {
background: inherit;
border: 0;
vertical-align: baseline;
padding: 0.25ex 0.5ex;
}
table.news td:nth-child(1) {
/* Don't want the hyphens in dates (2012-06-29) to cause line breaks */
white-space: nowrap;
}
ol.languages {
column-width: 12em;
-moz-column-width: 12em;
}

View File

@@ -17,8 +17,10 @@ h1 img.nofloat { float: none; }
img.right { float: right; }
ol.languages {
column-width: 12em;
-moz-column-width: 12em;
display: flex;
flex-direction: column;
flex-wrap: wrap;
height: 12em;
}
.grow {

View File

@@ -1,43 +0,0 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<META NAME="generator" CONTENT="http://txt2tags.sf.net">
<TITLE>Portable Numeral Translator</TITLE>
</HEAD><BODY BGCOLOR="white" TEXT="black">
<P ALIGN="center"><CENTER><H1>Portable Numeral Translator</H1>
<FONT SIZE="4">
<I>15 August 2008</I><BR>
</FONT></CENTER>
<P>
Here is the first GF application for the iPhone. It translates
numerals from digits into number words in 15 languages. It works for
numerals in the range 1-999,999. You can use the demo online in your iPhone's
browser, or download and install it by using FileMagnet (from AppStore).
</P>
<P>
The demo should work in any web browser supporting JavaScript, but it has been
specially dimensioned for the iPhone screen. It is an application of a general
technology, namely the compilation of GF grammars to JavaScript. Thus you can
easily build similar applications from your own grammars.
</P>
<P>
The
<A HREF="http://www.cs.chalmers.se/~bringert/gf/translate/">full numeral translator</A>, which
works in 88 language and permits arbitrary cross translations, cannot yet be ported
to the iPhone because of memory problems.
</P>
<P>
The current version has some encoding/font issues in Hebrew and Hindi.
</P>
<P>
<A HREF="numbers/numbers.html">Use the translator online</A>
</P>
<P>
<A HREF="numbers.tgz">Download the translator</A>. To install: unpack the file and move
the directory <CODE>numbers</CODE> to your FileMagnet uploader.
</P>
<!-- html code generated by txt2tags 2.4 (http://txt2tags.sf.net) -->
<!-- cmdline: txt2tags -thtml index-numbers.txt -->
</BODY></HTML>

View File

@@ -1,875 +0,0 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<META NAME="generator" CONTENT="http://txt2tags.org">
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
<LINK REL="stylesheet" TYPE="text/css" HREF="../css/style.css">
<meta name = "viewport" content = "width = device-width"><TITLE>Grammatical Framework Bibliography</TITLE>
</HEAD><BODY BGCOLOR="white" TEXT="black">
<CENTER>
<H1><a href="../"><IMG src="../doc/Logos/gf0.png"></a>Grammatical Framework Bibliography</H1>
<FONT SIZE="4"><I>Aarne Ranta</I></FONT><BR>
<FONT SIZE="4">Tue Nov 27 16:47:06 2012</FONT>
</CENTER>
<P></P>
<HR NOSHADE SIZE=1>
<P></P>
<UL>
<LI><A HREF="#toc1">Publications on GF</A>
<LI><A HREF="#toc2">Background for GF</A>
</UL>
<P></P>
<HR NOSHADE SIZE=1>
<P></P>
<A NAME="toc1"></A>
<H2>Publications on GF</H2>
<P>
In reverse temporal order:
</P>
<P>
H. Burden and R. Heldal.
Natural Language Generation from Class Diagrams.
<I>Proceedings of the 8th International Workshop on Model-Driven Engineering, Verification and Validation (MoDeVVa 2011)</I>,
Wellington, New Zealand,
ACM,
2011.
<A HREF="http://www.grammaticalframework.org/doc/archive/a9-burden.pdf">Draft PDF</A>
<br>
<I>Using GF to verbalize platform-independent requirement specifications as a part of a software engineering tool chain.</I>
</P>
<P>
C. España-Bonet, R. Enache, A. Slaski, A. Ranta, L. Màrquez, and M. Gonzàlez.
Patent translation within the MOLTO project.
Proceedings of the 4th Workshop on Patent Translation,
MT Summit XIII, Xiamen, China, September 23, 2011.
<A HREF="http://www.lsi.upc.edu/~cristinae/CV/docs/MTS11PatEspanaetal.pdf">PDF</A>
<br>
<I>First steps to a hybrid GF-SMT system.</I>
</P>
<P>
Seyed M. Montazeri, Nivir Roy, and Gerardo Schneider.
From Contracts in Structured English to CL Specifications.
<I>5th International Workshop on Formal Languages and Analysis of Contract-Oriented Software (FLACOS'11)</I>,
volume 68 of EPTCS, pages 55-69,
Málaga, Spain, 22-23 September 2011.
<A HREF="http://dx.doi.org/10.4204/EPTCS.68.6">PDF/DOI</A>
<br>
<I>Formal analysis of contracts written in controlled English.</I>
</P>
<P>
S. Virk, M. Humayoun, and A. Ranta.
An Open-Source Punjabi Resource Grammar.
Proceedings of RANLP-2011, Recent Advances in Natural Language Processing,
Hissar, Bulgaria, 12-14 September, 2011.
pp. 70-76.
<A HREF="http://lml.bas.bg/~iva/ranlp2011/RANLR2011_Proceedings.PDF">PDF</A>
<br>
<I>Punjabi syntax, building on Humayoun and Ranta 2010.</I>
</P>
<P>
D. Dannélls, M. Damova, R.Enache, M. Chechev.
A Framework for Improved Access to Museum Databases in the Semantic Web.
Proceedings of the Workshop on Language Technologies for Digital Humanities and Cultural Heritage,
RANLP-2011, Recent Advances in Natural Language Processing,
Hissar, Bulgaria, 12-14 September, 2011,
pp 8-15
<A HREF="http://publications.lib.chalmers.se/cpl/record/index.xsql?pubid=145395">PDF</A>
<br>
<I>Representing and verbalizing in GF of an Cultural Heritage ontology.</I>
</P>
<P>
A. Ranta.
Translating between Language and Logic: What Is Easy and What is Difficult?
In N. Bjørner and V. Sofronie-Stokkermans (eds.),
<I>CADE-23. Automated Deduction</I>,
LNCS/LNAI 6803,
pp. 5-25,
2011.
<A HREF="http://www.springerlink.com/content/42n685777k846810/">PDF at Springer</A>
<A HREF="http://www.cse.chalmers.se/~aarne/articles/cade2011.pdf">Draft PDF</A>
<br>
<I>Invited talk at the CADE conference, showing how GF can help writing natural language interfaces</I>
<I>to proof systems, and also exploring how to make the language richer, e.g. how to get from</I>
<I>"for all numbers x, x is even or x is odd" to "every number is even or odd".</I>
</P>
<P>
A. Ranta.
<I>Grammatical Framework: Programming with Multilingual Grammars</I>,
CSLI Publications, Stanford, 2011.
<A HREF="http://www.grammaticalframework.org/gf-book/">Book web page</A>
<br>
<I>Meant as the standard reference and textbook on GF.</I>
</P>
<P>
O. Caprotti, K. Angelov, R. Enache, T. Hallgren, A. Ranta.
The MOLTO Phrasebook.
Swedish Language Technology Conference SLTC 2010.
<A HREF="http://publications.lib.chalmers.se/cpl/record/index.xsql?pubid=131251">PDF</A>
<br>
<I>Tourist Phrasebook grammar, available in 14 European languages.</I>
</P>
<P>
G. Détrez and R. Enache.
A Framework for Multilingual Applications on the Android Platform
Swedish Language Technology Conference SLTC 2010.
<A HREF="http://www.grammaticalframework.org/doc/archive/sltc10_submission_24.pdf">PDF</A>
<br>
<I>A description of the Java implementation of the GF runtime system, which makes it possible</I>
to create grammar-based applications running on an Android phone.//
</P>
<P>
Normunds Gruzitis and Guntis Barzdins.
Towards a More Natural Multilingual Controlled Language Interface to OWL,
<I>9th International Conference on Computational Semantics (IWCS)</I>,
pp. 335-339,
2011.
<A HREF="http://www.aclweb.org/anthology/W/W11/W11-0138.pdf">PDF</A>
<br>
<I>Access to ontologies in English and Latvian.</I>
</P>
<P>
M. Humayoun and A. Ranta.
Developing Punjabi Morphology, Corpus and Lexicon.
<I>The 24th Pacific Asia conference on Language, Information and Computation (PACLIC24)</I>,
2010.
<br>
<I>Yet another South-East Asian language, spoken by 88 million people.</I>
</P>
<P>
J. Camilleri, Gordon J. Pace, and Mike Rosner.
Playing Nomic using a Controlled Natural Language.
<I>CNL 2010, Controlled Natural Language</I>,
Marettimo,
2010.
<br>
<I>Using GF for defining the rules of a game.</I>
</P>
<P>
R. Enache and K. Angelov
Typeful Ontologies with Direct Multilingual Verbalization.
<I>CNL 2010, Controlled Natural Language</I>,
Marettimo,
2010.
<br>
<I>Investigating the benefits of using GF as a language for representing ontologies.</I>
<A HREF="http://www.grammaticalframework.org/doc/archive/cnl2010_submission_2.pdf">PDF</A>
</P>
<P>
S. Virk, M. Humayoun, and A. Ranta.
An Open Source Urdu Resource Grammar.
<I>Proceedings of the 8th Workshop on Asian Language Resources (Coling 2010 workshop)</I>,
2010.
<br>
<I>The national language of Pakistan, spoken by 60 million people; almost the same as Hindi.</I>
</P>
<P>
A. Ranta, K. Angelov, and T. Hallgren.
Tools for multilingual grammar-based translation on the web.
<I>Proceedings of the ACL 2010 System Demonstrations</I>,
ACM Digital Library,
2010.
<A HREF="http://www.aclweb.org/anthology-new/P/P10/P10-4012.pdf">PDF</A>
<br>
<I>An overview of GF for developers and users of translation systems.</I>
</P>
<P>
D. Dannélls and J. Camilleri.
Verb Morphology of Hebrew and Maltese - Towards an Open Source Type Theoretical Resource Grammar in GF.
<I>Proceedings of the Language Resources (LRs) and Human Language Technologies (HLT) for Semitic Languages Status, Updates, and Prospects, LREC-2010 Workshop</I>,
Malta, pp. 57-61.
2010.
<A HREF="http://spraakdata.gu.se/svedd/pub/lrec10.pdf">PDF</A>
<br>
<I>A study of Semitic non-concatenative morphology from the GF point of view.</I>
</P>
<P>
M. Humayoun and C. Raffalli.
MathNat - Mathematical Text in a Controlled Natural Language.
<I>Special issue: Natural Language Processing and its Applications. Journal on Research in Computing Science</I>, Volume 46.
2010.
<br>
<I>Natural language interface to a proof system, implemented in GF.</I>
</P>
<P>
D. Dannélls.
Discourse Generation from Formal Specifications Using the Grammatical Framework, GF.
<I>Special issue: Natural Language Processing and its Applications. Journal on Research in Computing Science (RCS)</I>,
volume 46. pp. 167-178,
2010.
<br>
<I>Interfacing GF with ontology, with a natural language generation perspective.</I>
</P>
<P>
R. Enache, A. Ranta, and K. Angelov.
An Open-Source Computational Grammar of Romanian.
A. Gelbukh (ed.), <I>CiCLING-2010</I>,
LNCS 6008,
2010.
<br>
<I>A Romance language different enough not to follow the Romance functor.</I>
</P>
<P>
K. Angelov and A. Ranta.
Implementing Controlled Languages in GF.
N. Fuchs (ed.), <I>CNL-2009 Controlled Natural Languages</I>,
LNCS/LNAI 5972,
2010.
</P>
<P>
K. Angelov, B. Bringert and A. Ranta.
PGF: A Portable Run-time Format for Type-theoretical Grammars,
<I>Journal of Logic, Language and Information</I>,
19(2),
pp. 201-228,
2009.
<A HREF="http://www.springerlink.com/content/y32q021028747k70/">SpringerLink</A>
</P>
<P>
A. Ranta.
The GF Resource Grammar Library.
<I>Linguistic Issues in Language Technology</I>,
2 (2),
2009.
<A HREF="http://elanguage.net/journals/index.php/lilt/article/viewFile/214/158">PDF</A>
<br>
<I>A systematic presentation of the library from the linguistic point of view.</I>
</P>
<P>
A. Ranta.
Grammatical Framework: A Multilingual Grammar Formalism,
<I>Language and Linguistics Compass</I>,
Vol. 3, <A HREF="http://www.blackwell-compass.com/subject/linguistics/article_view?parent=section&amp;last_results=section%3Dlnco-computational&amp;sortby=date&amp;section=lnco-computational&amp;browse_id=lnco_articles_bpl155&amp;article_id=lnco_articles_bpl155">on-line</A>
2009.
<br>
<I>An overview of GF for readers with a general academic brackground.</I>
</P>
<P>
A. Ranta and K. Angelov.
Implementing Controlled Languages in GF.
<I>CNL-2009</I>,
<I>CEUR Workshop Proceedings</I>,
vol. 448,
<A HREF="http://sunsite.informatik.rwth-aachen.de/Publications/CEUR-WS/Vol-448/">on-line</A>,
2009.
<br>
<I>Makes a case for using GF in controlled language implementation, illustrated by Attempto Controlled English ported to French, German, and Swedish; longer version in 2010.</I>
</P>
<P>
A. Ranta. Grammars as Software Libraries.
In Y. Bertot, G. Huet, J-J. Lévy, and G. Plotkin (eds.),
<I>From Semantics to Computer Science</I>,
Cambridge University Press, Cambridge,
pp. 281-308,
2009.
<A HREF="http://www.cse.chalmers.se/~aarne/articles/libraries-kahn.pdf">pdf (preliminary version)</A>
<br>
<I>Grammar-libraries from the software engineering point of view, with an example application to mathematical language.</I>
</P>
<P>
K. Angelov.
Incremental Parsing in Parallel Multiple Context-Free Grammars.
EACL 2009.
<br>
<I>Describes the algorithm used in parsing with GF.</I>
</P>
<P>
A. Ranta, B. Bringert, and K. Angelov.
The GF Grammar Development Environment.
System demo. Proceedings of <I>EACL-2009</I>,
2009.
<A HREF="http://www.aclweb.org/anthology-new/E/E09/E09-2015.pdf">PDF</A>
<br>
<I>An overview of GF from the grammarian's point of view.</I>
</P>
<P>
B. Bringert, K. Angelov, and A. Ranta.
Grammatical Framework Web Service,
System demo. Proceedings of <I>EACL-2009</I>,
2009.
<A HREF="http://www.aclweb.org/anthology-new/E/E09/E09-2003.pdf">PDF</A>
<br>
<I>An overview of how to build web services on top of PGF using the Google Web Toolkit.</I>
</P>
<P>
A. Ranta and K. Angelov.
Implementing Controlled Languages in GF,
To appear in the proceedings of <I>CNL-2009</I>, LNCS, Springer,
2009.
<br>
<I>On the use of GF for controlled languages, exemplified by an implementation of Attempto Controlled English then ported to three other language.</I>
</P>
<P>
R. Cooper and A. Ranta.
Natural Languages as Collections of Resources.
In <I>Language in Flux: Dialogue Coordination, Language Variation, Change</I>,
ed. by R. Cooper and R. Kempson, pp. 109-120. London: College Publications,
2008.
<br>
<I>The resource grammar idea applied to language learning and evolution.</I>
</P>
<P>
Moisés Salvador Meza Moreno and B. Bringert.
Interactive Multilingual Web Applications with Grammatical Framework.
In B. Nordström and A. Ranta (eds),
<I>Advances in Natural Language Processing (GoTAL 2008)</I>,
LNCS/LNAI 5221, Springer,
2008.
<br>
<I>Shows how GF compiled to JavaScript is used in dynamic multilingual web pages.</I>
</P>
<P>
Peter Ljunglöf and Staffan Larsson.
A grammar formalism for specifying ISU-based dialogue systems.
In B. Nordström and A. Ranta (eds),
<I>Advances in Natural Language Processing (GoTAL 2008)</I>,
LNCS/LNAI 5221, Springer,
2008.
<A HREF="http://www.ling.gu.se/~peb/pubs/LjunglofLarsson-2008a.pdf">pdf</A>
<br>
<I>Explains how GoDiS dialogue systems are specified by GF grammars.</I>
</P>
<P>
K. Angelov.
Type-Theoretical Bulgarian Grammar.
In B. Nordström and A. Ranta (eds),
<I>Advances in Natural Language Processing (GoTAL 2008)</I>,
LNCS/LNAI 5221, Springer,
2008.
<br>
<I>Explains the implementation of a Bulgarian resource grammar in GF.</I>
</P>
<P>
B. Bringert.
High-precision Domain-specific Interlingua-based Speech Translation
with Grammatical Framework.
<I>Coling 2008 Workshop on Speech Translation for Medical and Other Safety-Critical Applications</I>,
Manchester, UK, August 23,
2008.
<br>
<I>Shows how to build spoken language translators based on GF grammars and their compilation to Nuance.</I>
</P>
<P>
A. Ranta.
How predictable is Finnish morphology? An experiment on lexicon construction.
In J. Nivre, M. Dahllöf and B. Megyesi (eds),
<I>Resourceful Language Technology: Festschrift in Honor of Anna Sågvall Hein</I>,
University of Uppsala,
2008.
Available from <A HREF="http://publications.uu.se/abstract.xsql?dbid=8933">series homepage</A>
<br>
<I>Presents an experiment on smart paradigms in Finnish.</I>
</P>
<P>
A. Ranta.
Example-based grammar writing.
To appear in L. Borin and S. Larsson (eds),
Festschrift for Robin Cooper,
2007.
<br>
<I>Presents and discusses the ideas of grammar composition and example-based grammar writing.</I>
</P>
<P>
B. Bringert.
Rapid Development of Dialogue Systems by Grammar Compilation.
<I>8th SIGdial Workshop on Discourse and Dialogue</I>,
Antwerp, Belgium, September 1-2,
2007.
<A HREF="http://www.cse.chalmers.se/~bringert/publ/gf-voicexml/gf-voicexml.pdf">pdf</A>
<br>
<I>Shows how to build a web-based spoken dialogue system by generating VoiceXML and JavaScript.</I>
</P>
<P>
A. El Dada and A. Ranta.
Implementing an Open Source Arabic Resource Grammar in GF.
In M. Mughazy (ed),
<I>Perspectives on Arabic Linguistics XX. Papers from the Twentieth Annual Symposium on Arabic Linguistics, Kalamazoo, March 26</I>
John Benjamins Publishing Company.
2007.
<br>
<I>An outline of the Arabic resource grammar project, focusing on linguistic aspects.</I>
</P>
<P>
A. El Dada.
Implementation of the Arabic Numerals and their Syntax in GF.
Computational Approaches to Semitic Languages: Common Issues and Resources,
ACL-2007 Workshop,
June 28, 2007, Prague.
2007.
<br>
<I>A case study with the resource grammar, focusing on the morphosyntax</I>
<I>and agreement of constructions with numerals.</I>
</P>
<P>
A. Ranta.
Modular Grammar Engineering in GF.
<I>Research on Language and Computation</I>,
5:133-158, 2007.
Draft available as <A HREF="http://www.cse.chalmers.se/~aarne/articles/multieng3.pdf">pdf</A>.
<br>
<I>Adapts library-based software engineering methods to grammar writing</I>
<I>and introduces the module system of GF.</I>
</P>
<P>
A. Ranta.
The GF Grammar Compiler.
<I>Workshop on New Directions in Type-theoretic Grammars</I>,
Dublin, August 2007 (ESSLLI workshop).
2007.
<A HREF="http://www.cse.chalmers.se/~aarne/articles/ar-compiler.pdf">pdf</A>
<br>
<I>Describes the compilation of GF source code to lower-level run-time formats.</I>
</P>
<P>
M. Humayoun, H. Hammarström, and A. Ranta.
Urdu Morphology, Orthography and Lexicon Extraction.
<I>CAASL-2: The Second Workshop on Computational Approaches to Arabic Script-based Languages</I>,
July 21-22, 2007, LSA 2007 Linguistic Institute, Stanford University.
2007.
<br>
<I>Fairly complete open-source Urdu morphology and elemenraty syntax in GF.</I>
</P>
<P>
N. Perera and A. Ranta.
Dialogue System Localization with the GF Resource Grammar Library.
<I>SPEECHGRAM 2007: ACL Workshop on Grammar-Based Approaches to Spoken Language Processing</I>,
June 29, 2007, Prague.
2007.
<A HREF="http://www.cse.chalmers.se/~aarne/articles/perera-ranta.pdf">pdf</A>
<br>
<I>An experiment in porting an in-car dialogue system from two to six languages.</I>
</P>
<P>
B. Bringert.
Speech Recognition Grammar Compilation in Grammatical Framework
<I>SPEECHGRAM 2007: ACL Workshop on Grammar-Based Approaches to Spoken Language Processing</I>,
June 29, 2007, Prague.
2007.
<br>
<I>Generation of speech recognition language models from GF in several formats:</I>
<I>GSL (Nuance), SRGS, JSGF, and HTK SLF, with embedded semantic interpretation.</I>
</P>
<P>
A. Ranta.
Features in Abstract and Concrete Syntax.
<I>The 2nd International Workshop on Typed Feature Structure Grammars</I>,
Tartu, 24 May 2007 (NODALIDA workshop).
2007.
<A HREF="http://www.cse.chalmers.se/~aarne/articles/ranta-tfsg2007.pdf">pdf</A>
<br>
<I>Explores the design choices of incorporating features in a GF-like grammar,</I>
<I>with comparisons to feature-based unification grammars.</I>
</P>
<P>
O. Caprotti and M. Seppälä.
Multilingual Delivery of Online Tests in mathematics.
Proceedings of Online Educa Berlin 2006. 29 November - 1 December 2006.
Berlin, Germany.
2006.
<A HREF="http://webalt.math.helsinki.fi/content/e16/e301/e785/MultilingualDeliveryofOnlineTestsinMathematics_eng.pdf">pdf</A>
<br>
<I>This papers shows screenshots of multilingual generation in the</I>
<I>WebALT project, using GF and the resource grammar library.</I>
</P>
<P>
J. Khegai.
Language engineering in Grammatical Framework (GF).
Phd thesis, Computer Science, Chalmers University of Technology,
2006.
<A HREF="http://www.cse.chalmers.se/~janna/Janna_Khegai_phd.pdf">pdf</A>
<br>
<I>Collection of articles and technical reports on multilingual authoring</I>
<I>and the Russian resource grammar.</I>
</P>
<P>
B. Bringert and A. Ranta.
A Pattern for Almost Compositional Functions.
<I>ICFP 2006, The 11th ACM SIGPLAN International Conference on Functional Programming, Portland, Oregon, September 18-20, 2006</I>,
2006.
<A HREF="http://www.cse.chalmers.se/~bringert/publ/composOp/composOp.pdf">pdf</A>.
<br>
<I>A method of generic programming useful for compiler construction</I>
<I>and transfer-based translation.</I>
</P>
<P>
M. Forsberg, H. Hammarstrom, and A. Ranta.
Morphological Lexicon Extraction from Raw Text Data.
<I>FinTAL 2006</I>,
Turku, August 23-25, 2006.
Springer LNCS/LNAI 4139,
pp. 488-499,
2006.
<br>
<I>A method for automatical production of morphological lexica based</I>
<I>on inflection engines such as those of GF resource grammar library.</I>
</P>
<P>
A. Ranta.
Type Theory and Universal Grammar.
<I>Philosophia Scientiae, Constructivism: Mathematics, Logic, Philosophy and Linguistics</I>,
cahier spécial 6,
pp. 115-131,
2006.
<br>
<I>A philosophical study of the medieval thesis that</I>
<I>grammar is the same in all languages and the difference is only in words.</I>
</P>
<P>
J. Khegai.
GF parallel resource grammars and Russian.
In proceedings of ACL2006
(The joint conference of the International Committee on Computational
Linguistics and the Association for Computational Linguistics) (pp. 475-482),
Sydney, Australia, July 2006.
<br>
<I>Gives an outline of the Russian resource grammar project.</I>
</P>
<P>
J. Khegai.
Grammatical Framework (GF) for MT in sublanguage domains.
Proceedings of 11th Annual conference of the European Association for
Machine Translation, , Oslo.
pp. 95-104,
2005.
<br>
<I>Shows how GF is used in controlled language translation.</I>
</P>
<P>
W. Ng'ang'a.
Multilingual content development for eLearning in Africa.
eLearning Africa: 1st Pan-African Conference on ICT for Development,
Education and Training. 24-26 May 2006, Addis Ababa, Ethiopia.
2006.
<A HREF="http://webalt.math.helsinki.fi/content/e16/e301/e583/MultilingualContentDevelopmentforeLearninginAfrica-final1_eng.pdf">pdf</A>
<br>
<I>Presents a programme for producing educational material in African languages</I>
<I>via multilingual generation in GF.</I>
</P>
<P>
R. Jonson.
Generating statistical language models from interpretation grammars in dialogue system.
In Proceedings of EACL'06, Trento, Italy.
2006.
<br>
<I>Uses GF grammars to generate statistical language models for speech recognition.</I>
</P>
<P>
A. El Dada and A. Ranta.
Arabic Resource Grammar.
<I>Arabic Language Processing (JETALA)</I>,
5-6 June 2006, IERA, Rabat, Morocco,
2006.
<br>
<I>An outline of the Arabic resource grammar project, focusing on software aspects.</I>
</P>
<P>
D. A. Burke and K. Johannisson.
Translating Formal Software Specifications to Natural Language. A Grammar-Based Approach.
In P. Blache, E. Stabler, J. Busquets and R. Moot (eds),
Logical Aspects of Computational Linguistics (LACL 2005),
Springer LNAI 3402,
pp. 51-66,
2005.
<br>
<I>A paper explaining how a multilingual GF grammar is completed with</I>
<I>Natural Language Generation techniques to improve text quality.</I>
</P>
<P>
B. Bringert, R. Cooper, P. Ljunglöf, A. Ranta,
Multimodal Dialogue System Grammars.
<I>Proceedings of DIALOR'05, Ninth Workshop on the Semantics and Pragmatics of Dialogue, Nancy, France, June 9-11, 2005</I>,
2005.
<A HREF="http://www.cse.chalmers.se/~bringert/publ/mm-grammars-dialor/mm-grammars-dialor.pdf">pdf</A>.
<br>
<I>Shows how mouse clicks can be integrated in GF grammars</I>
<I>alongside with speech input.</I>
</P>
<P>
K. Johannisson,
Formal and Informal Software Specifications.
PhD thesis,
Computer Science, Göteborg University,
2005.
[<A HREF="http://www.cse.chalmers.se/~krijo/thesis/thesisA4.pdf">http://www.cse.chalmers.se/~krijo/thesis/thesisA4.pdf</A>]
<br>
<I>Collection of articles in the GF-KeY project, with an introduction.</I>
</P>
<P>
P. Ljunglöf.
Expressivity and Complexity of the Grammatical Framework.
PhD thesis, Computer Science,
Göteborg University,
2004.
<A HREF="http://www.cse.chalmers.se/~peb/pubs/Ljunglof-2004a.pdf">pdf</A>
<br>
<I>Language-theoretical study of GF and its parsing problem.</I>
</P>
<P>
A. Ranta.
Grammatical Framework: A Type-Theoretical Grammar Formalism.
<I>Journal of Functional Programming</I>, 14(2),
pp. 145-189,
2004.
Draft available as <A HREF="http://www.cse.chalmers.se/~aarne/articles/gf-jfp.ps.gz">ps.gz</A>.
<br>
<I>Theoretical paper explaining the GF formalism and its implementation.</I>
<I>The standard reference on GF, but doesn't cover the module system.</I>
</P>
<P>
A. Ranta.
Computational semantics in type theory.
<I>Mathematics and Social Sciences</I>, 165,
pp. 31-57,
2004.
Draft available as <A HREF="http://www.cse.chalmers.se/~aarne/articles/3formsem.pdf">pdf</A>.
<br>
// Shows how Montague-style grammars are implemented in GF and extends//
<I>this to type-theoretical grammars for anaphoric expressions.</I>
</P>
<P>
H. Hammarström and A. Ranta.
Cardinal Numerals Revisited in GF.
<I>Workshop on Numerals in the World's Languages</I>.
Dept. of Linguistics Max Planck Institute for Evolutionary Anthropology, Leipzig,
2004.
<br>
<I>An overview of the numeral grammar project, covering 88 languages.</I>
</P>
<P>
A. Ranta.
Grammatical Framework Tutorial.
In A. Beckmann and N. Preining, editors,
<I>ESSLLI 2003 Course Material I</I>,
<I>Collegium Logicum</I>,
volume V,
pp. 1-86.
Kurt Gödel Society,
Vienna,
2004.
<br>
<I>A revised version of the on-line GF tutorial, v1.0.</I>
</P>
<P>
J. Khegai and A. Ranta.
Building and Using a Russian Resource Grammar in GF.
In A. Gelbukh (ed),
<I>Intelligent Text Processing and Computational Linguistics (CICLing-2004)</I>,
Seoul, Korea, February 2003,
Springer LNCS 945,
pp. 38-41,
2004.
<A HREF="http://www.cse.chalmers.se/~aarne/articles/mexico.ps.gz">ps.gz</A>.
<br>
<I>An introduction to the GF resource grammar project, with Russian as prime example.</I>
</P>
<P>
A. Ranta and R. Cooper.
Dialogue Systems as Proof Editors.
<I>Journal of Logic, Language and Information</I>, 13,
pp. 225-240,
2004.
Conference version (IJCAR/ICoS-3, Siena, June 2001) available as
<A HREF="http://www.cse.chalmers.se/~aarne/articles/dialogue3.ps.gz">ps.gz</A>.
<I>Shows a close analogy between task-oriented dialogue systems</I>
<I>and metavariable-based proof editors.</I>
</P>
<P>
J. Khegai and A. Ranta.
Building and Using a Russian Resource Grammar in GF.
In A. Gelbukh (ed),
<I>Intelligent Text Processing and Computational Linguistics (CICLing-2004)</I>,
Seoul, Korea, February 2003,
Springer LNCS 945,
pp. 38-41,
2004.
<A HREF="http://www.cse.chalmers.se/~aarne/articles/mexico.ps.gz">ps.gz</A>.
<br>
<I>Explains how the GF GUI is used in syntax editing and discusses</I>
<I>how new grammars are created.</I>
</P>
<P>
R. Hähnle, K. Johannisson, and A. Ranta.
An Authoring Tool for Informal and Formal Requirements Specifications.
In R. D. Kutsche and H. Weber (eds),
<I>ETAPS/FASE-2002: Fundamental Approaches to Software Engineering</I>,
Springer LNCS,
vol. 2306,
pp. 233--248,
2002.
<A HREF="http://www.cse.chalmers.se/~krijo/GF/FASE.pdf">pdf</A>
<br>
<I>Describes a GF-based authoring tool for object-oriented</I>
<I>specifications in OCL and English. Carries out in full</I>
<I>the work proposed in the position paper (Hähnle &amp; Ranta 2001).</I>
</P>
<P>
K. Johannisson and A.Ranta,
Formal Verification of Multilingual Instructions.
<I>Proceedings of the Joint Winter Meeting 2001</I>.
Departments of Computer Science and Computer Engineering,
Chalmers University of Technology and Göteborg University.
2001.
<A HREF="http://www.cse.chalmers.se/~aarne/articles/aarne+krijo.ps.gz">ps.gz</A>.
<br>
<I>Instructions for an alarm system in four languages, verified in the proof editor Alfa.</I>
</P>
<P>
R. Hähnle and A. Ranta,
Connecting OCL with the Rest of the World.
<I>ETAPS 2001 Workshop on Transformations in UML (WTUML)</I>,
Genova,
2001.
<A HREF="http://www.cse.chalmers.se/~reiner/papers/wtuml.ps.gz">ps.gz</A>.
<br>
<I>A position paper explaining how GF can be used to help in object-oriented</I>
<I>modelling, with some examples on natural-language interaction with</I>
<I>OCL (Object Constraint Language)</I>.
</P>
<P>
T. Hallgren, "The Correctness of Insertion Sort",
Manuscript, Chalmers University, Göteborg, 2001.
Available in
<A HREF="http://www.cse.chalmers.se/~hallgren/Papers/insertion_sort.ps">ps</A>
<br>
<I>A seven-page text generated by GF-Alfa</I>.
</P>
<P>
A. Ranta. "Bescherelle bricolé",
<A HREF="../../GF2.0/doc/BeschBric.ps.gz">ps.gz</A>,
2001.
<br>
<I>A machine-generated book on French conjugation implemented in GF.</I>
</P>
<P>
T. Hallgren and A. Ranta,
An Extensible Proof Text Editor.
In M. Parigot and A. Voronkov (eds),
<I>Logic for Programming and Automated Reasoning (LPAR'2000)</I>,
LNCS/LNAI 1955,
pp. 70-84,
Springer Verlag, Heidelberg,
2000.
<A HREF="http://www.cse.chalmers.se/~aarne/articles/lpar2000.ps.gz">ps.gz</A>.
<br>
<I>Describes an interface to the proof editor Alfa written in GF</I>.
</P>
<P>
M. Dymetman, V. Lux, and A. Ranta,
XML and multilingual document authoring: converging trends.
<I>Proceedings of the The 18th International Conference on Computational Linguistics (COLING 2000)</I>,
pp. 243-249,
Saarbruecken,
2000.
<A HREF="http://www.cse.chalmers.se/~aarne/articles/coling2000.ps.gz">ps.gz</A>.
<br>
<I>Relates GF not only with XML but also with definite clause grammars</I>.
</P>
<P>
P. Mäenpää and A. Ranta.
The type theory and type checker of GF.
<I>Colloquium on Principles, Logics, and Implementations of High-Level Programming Languages, Workshop on Logical Frameworks and Meta-languages, Paris, 28 September 1999</I>.
1999.
<A HREF="href=http://www.cse.chalmers.se/~aarne/papers/lfm1999.ps.gz">ps.gz</A>.
<br>
<I>Concise theoretical presentation of GF, using the old notation prior to v0.9</I>.
</P>
<A NAME="toc2"></A>
<H2>Background for GF</H2>
<P>
In alphabetical order:
</P>
<P>
L. Magnusson.
<I>The Implementation of ALF - a Proof Editor based on Martin-Löf's</I>
<I>Monomorphic Type Theory with Explicit Substitutions</I>.
PhD Thesis, Department of Computing Science,
Chalmers University of Technology and Göteborg University,
1994.
<br>
<I>Back in 1992 the most wonderful program in the world, ALF is</I>
<I>a model that GF directly follows: GF is Yet ALF.</I>
</P>
<P>
P. Martin-Löf.
<I>Intuitionistic Type Theory</I>.
Bibliopolis, Naples, 1984.
<br>
<I>A very accessible book (if you have access to it!) on type theory directly from the source.</I>
</P>
<P>
B. Nordström, K. Petersson, and J. Smith.
<I>Programming in Martin-Löf's Type Theory: an Introduction</I>.
Oxford University Press, 1990.
The book is out of print, but a free version can be picked up from
<A HREF="http://www.cse.chalmers.se/Cs/Research/Logic/book/">www.cse.chalmers.se/Cs/Research/Logic/book/</A>
<br>
<I>Standard reference on the subject</I>.
</P>
<P>
A. Ranta.
<I>Type Theoretical Grammar</I>.
Oxford University Press, Oxford,
1994.
<br>
<I>Monograph on type theory in linguistics. Includes an introduction</I>
<I>to type theory. Focused on semantics, in particular anaphora. A first,</I>
<I>very rudimentary implementation of linearization in the proof system ALF.</I>
</P>
<P>
A. Ranta.
Syntactic categories in the language of mathematics.
In P. Dybjer, B. Nordström, and J. Smith, eds.,
<I>Types for Proofs and Programs</I>,
pp. 162-182,
Lecture Notes in Computer Science
996,
Springer-Verlag,
Heidelberg,
1995.
<A HREF="http://www.cse.chalmers.se/~aarne/articles/baastad.ps.gz">ps.gz</A>
<br>
<I>Predecessor of GF: grammar defined in type theory and implemented in ALF</I>.
</P>
<P>
A. Ranta.
Context-relative syntactic categories and the formalization of mathematical text.
In S. Berardi and M. Coppo, eds.,
<I>Types for Proofs and Programs</I>,
pp. 231-248,
Lecture Notes in Computer Science
1158,
Springer-Verlag,
Heidelberg,
1996.
<A HREF="http://www.cse.chalmers.se/~aarne/articles/torino.ps.gz">ps.gz</A>.
<br>
<I>Extending the theory of the previous paper. The implementation in ALF</I>
<I>eventually became so heavy that the need arose for GF.</I>
</P>
<P>
A. Ranta.
Structures grammaticales dans le français mathématique.
<I>Mathématiques, informatique et Sciences Humaines.</I>,
vol. 138 pp. 5-56 and 139 pp. 5-36,
1997.
<br>
<I>A rather comprehensive French grammar presented in a type-theoretical style.</I>
</P>
<P>
A. Ranta.
Syntactic calculus with dependent types.
<I>Journal of Logic, Language and Information</I>, vol. 4,
pp. 413-431, 1998.
<br>
<I>Interprets Lambek Calculus in type theory and defines some extensions</I>.
</P>
<!-- html code generated by txt2tags 2.6 (http://txt2tags.org) -->
<!-- cmdline: txt2tags -thtml ./doc/gf-bibliography.t2t -->
</BODY></HTML>

View File

@@ -13,16 +13,17 @@ welcome!
==Emacs==
[gf.el ../src/tools/gf.el] by Johan Bockgård provides syntax highlighting and
automatic indentation and lets you run the GF Shell in an emacs buffer.
See installation instructions inside.
[gf.el https://github.com/GrammaticalFramework/gf-emacs-mode] by Johan
Bockgård provides syntax highlighting and automatic indentation and
lets you run the GF Shell in an emacs buffer. See installation
instructions inside.
==Atom==
[language-gf https://atom.io/packages/language-gf], by John J. Camilleri
==Eclipse==
[GF Eclipse Plugin http://www.grammaticalframework.org/eclipse/index.html], by John J. Camilleri
[GF Eclipse Plugin https://github.com/GrammaticalFramework/gf-eclipse-plugin/], by John J. Camilleri
==Gedit==

View File

@@ -1,664 +0,0 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<META NAME="generator" CONTENT="http://txt2tags.org">
<LINK REL="stylesheet" TYPE="text/css" HREF="../css/style.css">
<meta name = "viewport" content = "width = device-width"><TITLE>GF Quick Reference</TITLE>
</HEAD><BODY BGCOLOR="white" TEXT="black">
<CENTER>
<H1><a href="../"><IMG src="../doc/Logos/gf0.png"></a>GF Quick Reference</H1>
<FONT SIZE="4"><I>Aarne Ranta</I></FONT><BR>
<FONT SIZE="4">April 4, 2006</FONT>
</CENTER>
<P></P>
<HR NOSHADE SIZE=1>
<P></P>
<UL>
<LI><A HREF="#toc1">A complete example</A>
<LI><A HREF="#toc2">Modules and files</A>
<LI><A HREF="#toc3">Judgements</A>
<LI><A HREF="#toc4">Types</A>
<LI><A HREF="#toc5">Expressions</A>
<LI><A HREF="#toc6">Pattern matching</A>
<LI><A HREF="#toc7">Sample library functions</A>
<LI><A HREF="#toc8">Flags</A>
<LI><A HREF="#toc9">File paths</A>
<LI><A HREF="#toc10">Alternative grammar formats</A>
<LI><A HREF="#toc11">References</A>
</UL>
<P></P>
<HR NOSHADE SIZE=1>
<P></P>
<P>
This is a quick reference on GF grammars. It aims to
cover all forms of expression available when writing
grammars. It assumes basic knowledge of GF, which
can be acquired from the
<A HREF="http://www.grammaticalframework.org/doc/tutorial/gf-tutorial.html">GF Tutorial</A>.
Help on GF commands is obtained on line by the
help command (<CODE>help</CODE>), and help on invoking
GF with (<CODE>gf -help</CODE>).
</P>
<A NAME="toc1"></A>
<H3>A complete example</H3>
<P>
This is a complete example of a GF grammar divided
into three modules in files. The grammar recognizes the
phrases <I>one pizza</I> and <I>two pizzas</I>.
</P>
<P>
File <CODE>Order.gf</CODE>:
</P>
<PRE>
abstract Order = {
cat
Order ;
Item ;
fun
One, Two : Item -&gt; Order ;
Pizza : Item ;
}
</PRE>
<P>
File <CODE>OrderEng.gf</CODE> (the top file):
</P>
<PRE>
--# -path=.:prelude
concrete OrderEng of Order =
open Res, Prelude in {
flags startcat=Order ;
lincat
Order = SS ;
Item = {s : Num =&gt; Str} ;
lin
One it = ss ("one" ++ it.s ! Sg) ;
Two it = ss ("two" ++ it.s ! Pl) ;
Pizza = regNoun "pizza" ;
}
</PRE>
<P>
File <CODE>Res.gf</CODE>:
</P>
<PRE>
resource Res = open Prelude in {
param Num = Sg | Pl ;
oper regNoun : Str -&gt; {s : Num =&gt; Str} =
\dog -&gt; {s = table {
Sg =&gt; dog ;
_ =&gt; dog + "s"
}
} ;
}
</PRE>
<P>
To use this example, do
</P>
<PRE>
% gf -- in shell: start GF
&gt; i OrderEng.gf -- in GF: import grammar
&gt; p "one pizza" -- parse string
&gt; l Two Pizza -- linearize tree
</PRE>
<A NAME="toc2"></A>
<H3>Modules and files</H3>
<P>
One module per file.
File named <CODE>Foo.gf</CODE> contains module named
<CODE>Foo</CODE>.
</P>
<P>
Each module has the structure
</P>
<PRE>
moduletypename =
Inherits ** -- optional
open Opens in -- optional
{ Judgements }
</PRE>
<P>
Inherits are names of modules of the same type.
Inheritance can be restricted:
</P>
<PRE>
Mo[f,g], -- inherit only f,g from Mo
Lo-[f,g] -- inheris all but f,g from Lo
</PRE>
<P>
Opens are possible in <CODE>concrete</CODE> and <CODE>resource</CODE>.
They are names of modules of these two types, possibly
qualified:
</P>
<PRE>
(M = Mo), -- refer to f as M.f or Mo.f
(Lo = Lo) -- refer to f as Lo.f
</PRE>
<P>
Module types and judgements in them:
</P>
<PRE>
abstract A -- cat, fun, def, data
concrete C of A -- lincat, lin, lindef, printname
resource R -- param, oper
interface I -- like resource, but can have
oper f : T without definition
instance J of I -- like resource, defines opers
that I leaves undefined
incomplete -- functor: concrete that opens
concrete CI of A = one or more interfaces
open I in ...
concrete CJ of A = -- completion: concrete that
CI with instantiates a functor by
(I = J) instances of open interfaces
</PRE>
<P>
The forms
<CODE>param</CODE>, <CODE>oper</CODE>
may appear in <CODE>concrete</CODE> as well, but are then
not inherited to extensions.
</P>
<P>
All modules can moreover have <CODE>flags</CODE> and comments.
Comments have the forms
</P>
<PRE>
-- till the end of line
{- any number of lines between -}
--# used for compiler pragmas
</PRE>
<P>
A <CODE>concrete</CODE> can be opened like a <CODE>resource</CODE>.
It is translated as follows:
</P>
<PRE>
cat C ---&gt; oper C : Type =
lincat C = T T ** {lock_C : {}}
fun f : G -&gt; C ---&gt; oper f : A* -&gt; C* = \g -&gt;
lin f = t t g ** {lock_C = &lt;&gt;}
</PRE>
<P>
An <CODE>abstract</CODE> can be opened like an <CODE>interface</CODE>.
Any <CODE>concrete</CODE> of it then works as an <CODE>instance</CODE>.
</P>
<A NAME="toc3"></A>
<H3>Judgements</H3>
<PRE>
cat C -- declare category C
cat C (x:A)(y:B x) -- dependent category C
cat C A B -- same as C (x : A)(y : B)
fun f : T -- declare function f of type T
def f = t -- define f as t
def f p q = t -- define f by pattern matching
data C = f | g -- set f,g as constructors of C
data f : A -&gt; C -- same as
fun f : A -&gt; C; data C=f
lincat C = T -- define lin.type of cat C
lin f = t -- define lin. of fun f
lin f x y = t -- same as lin f = \x y -&gt; t
lindef C = \s -&gt; t -- default lin. of cat C
printname fun f = s -- printname shown in menus
printname cat C = s -- printname shown in menus
printname f = s -- same as printname fun f = s
param P = C | D Q R -- define parameter type P
with constructors
C : P, D : Q -&gt; R -&gt; P
oper h : T = t -- define oper h of type T
oper h = t -- omit type, if inferrable
flags p=v -- set value of flag p
</PRE>
<P>
Judgements are terminated by semicolons (<CODE>;</CODE>).
Subsequent judgments of the same form may share the
keyword:
</P>
<PRE>
cat C ; D ; -- same as cat C ; cat D ;
</PRE>
<P>
Judgements can also share RHS:
</P>
<PRE>
fun f,g : A -- same as fun f : A ; g : A
</PRE>
<A NAME="toc4"></A>
<H3>Types</H3>
<P>
Abstract syntax (in <CODE>fun</CODE>):
</P>
<PRE>
C -- basic type, if cat C
C a b -- basic type for dep. category
(x : A) -&gt; B -- dep. functions from A to B
(_ : A) -&gt; B -- nondep. functions from A to B
(p,q : A) -&gt; B -- same as (p : A)-&gt; (q : A) -&gt; B
A -&gt; B -- same as (_ : A) -&gt; B
Int -- predefined integer type
Float -- predefined float type
String -- predefined string type
</PRE>
<P>
Concrete syntax (in <CODE>lincat</CODE>):
</P>
<PRE>
Str -- token lists
P -- parameter type, if param P
P =&gt; B -- table type, if P param. type
{s : Str ; p : P}-- record type
{s,t : Str} -- same as {s : Str ; t : Str}
{a : A} **{b : B}-- record type extension, same as
{a : A ; b : B}
A * B * C -- tuple type, same as
{p1 : A ; p2 : B ; p3 : C}
Ints n -- type of n first integers
</PRE>
<P>
Resource (in <CODE>oper</CODE>): all those of concrete, plus
</P>
<PRE>
Tok -- tokens (subtype of Str)
A -&gt; B -- functions from A to B
Int -- integers
Strs -- list of prefixes (for pre)
PType -- parameter type
Type -- any type
</PRE>
<P>
As parameter types, one can use any finite type:
<CODE>P</CODE> defined in <CODE>param P</CODE>,
<CODE>Ints n</CODE>, and record types of parameter types.
</P>
<A NAME="toc5"></A>
<H3>Expressions</H3>
<P>
Syntax trees = full function applications
</P>
<PRE>
f a b -- : C if fun f : A -&gt; B -&gt; C
1977 -- : Int
3.14 -- : Float
"foo" -- : String
</PRE>
<P>
Higher-Order Abstract syntax (HOAS): functions as arguments:
</P>
<PRE>
F a (\x -&gt; c) -- : C if a : A, c : C (x : B),
fun F : A -&gt; (B -&gt; C) -&gt; C
</PRE>
<P>
Tokens and token lists
</P>
<PRE>
"hello" -- : Tok, singleton Str
"hello" ++ "world" -- : Str
["hello world"] -- : Str, same as "hello" ++ "world"
"hello" + "world" -- : Tok, computes to "helloworld"
[] -- : Str, empty list
</PRE>
<P>
Parameters
</P>
<PRE>
Sg -- atomic constructor
VPres Sg P2 -- applied constructor
{n = Sg ; p = P3} -- record of parameters
</PRE>
<P>
Tables
</P>
<PRE>
table { -- by full branches
Sg =&gt; "mouse" ;
Pl =&gt; "mice"
}
table { -- by pattern matching
Pl =&gt; "mice" ;
_ =&gt; "mouse" -- wildcard pattern
}
table {
n =&gt; regn n "cat" -- variable pattern
}
table Num {...} -- table given with arg. type
table ["ox"; "oxen"] -- table as course of values
\\_ =&gt; "fish" -- same as table {_ =&gt; "fish"}
\\p,q =&gt; t -- same as \\p =&gt; \\q =&gt; t
t ! p -- select p from table t
case e of {...} -- same as table {...} ! e
</PRE>
<P>
Records
</P>
<PRE>
{s = "Liz"; g = Fem} -- record in full form
{s,t = "et"} -- same as {s = "et";t= "et"}
{s = "Liz"} ** -- record extension: same as
{g = Fem} {s = "Liz" ; g = Fem}
&lt;a,b,c&gt; -- tuple, same as {p1=a;p2=b;p3=c}
</PRE>
<P>
Functions
</P>
<PRE>
\x -&gt; t -- lambda abstract
\x,y -&gt; t -- same as \x -&gt; \y -&gt; t
\x,_ -&gt; t -- binding not in t
</PRE>
<P>
Local definitions
</P>
<PRE>
let x : A = d in t -- let definition
let x = d in t -- let defin, type inferred
let x=d ; y=e in t -- same as
let x=d in let y=e in t
let {...} in t -- same as let ... in t
t where {...} -- same as let ... in t
</PRE>
<P>
Free variation
</P>
<PRE>
variants {x ; y} -- both x and y possible
variants {} -- nothing possible
</PRE>
<P>
Prefix-dependent choices
</P>
<PRE>
pre {"a" ; "an" / v} -- "an" before v, "a" otherw.
strs {"a" ; "i" ;"o"}-- list of condition prefixes
</PRE>
<P>
Typed expression
</P>
<PRE>
&lt;t:T&gt; -- same as t, to help type inference
</PRE>
<P>
Accessing bound variables in <CODE>lin</CODE>: use fields <CODE>$1, $2, $3,...</CODE>.
Example:
</P>
<PRE>
fun F : (A : Set) -&gt; (El A -&gt; Prop) -&gt; Prop ;
lin F A B = {s = ["for all"] ++ A.s ++ B.$1 ++ B.s}
</PRE>
<A NAME="toc6"></A>
<H3>Pattern matching</H3>
<P>
These patterns can be used in branches of <CODE>table</CODE> and
<CODE>case</CODE> expressions. Patterns are matched in the order in
which they appear in the grammar.
</P>
<PRE>
C -- atomic param constructor
C p q -- param constr. applied to patterns
x -- variable, matches anything
_ -- wildcard, matches anything
"foo" -- string
56 -- integer
{s = p ; y = q} -- record, matches extensions too
&lt;p,q&gt; -- tuple, same as {p1=p ; p2=q}
p | q -- disjunction, binds to first match
x@p -- binds x to what p matches
- p -- negation
p + "s" -- sequence of two string patterns
p* -- repetition of a string pattern
</PRE>
<A NAME="toc7"></A>
<H3>Sample library functions</H3>
<PRE>
-- lib/prelude/Predef.gf
drop : Int -&gt; Tok -&gt; Tok -- drop prefix of length
take : Int -&gt; Tok -&gt; Tok -- take prefix of length
tk : Int -&gt; Tok -&gt; Tok -- drop suffix of length
dp : Int -&gt; Tok -&gt; Tok -- take suffix of length
occur : Tok -&gt; Tok -&gt; PBool -- test if substring
occurs : Tok -&gt; Tok -&gt; PBool -- test if any char occurs
show : (P:Type) -&gt; P -&gt;Tok -- param to string
read : (P:Type) -&gt; Tok-&gt; P -- string to param
toStr : (L:Type) -&gt; L -&gt;Str -- find "first" string
-- lib/prelude/Prelude.gf
param Bool = True | False
oper
SS : Type -- the type {s : Str}
ss : Str -&gt; SS -- construct SS
cc2 : (_,_ : SS) -&gt; SS -- concat SS's
optStr : Str -&gt; Str -- string or empty
strOpt : Str -&gt; Str -- empty or string
bothWays : Str -&gt; Str -&gt; Str -- X++Y or Y++X
init : Tok -&gt; Tok -- all but last char
last : Tok -&gt; Tok -- last char
prefixSS : Str -&gt; SS -&gt; SS
postfixSS : Str -&gt; SS -&gt; SS
infixSS : Str -&gt; SS -&gt; SS -&gt; SS
if_then_else : (A : Type) -&gt; Bool -&gt; A -&gt; A -&gt; A
if_then_Str : Bool -&gt; Str -&gt; Str -&gt; Str
</PRE>
<A NAME="toc8"></A>
<H3>Flags</H3>
<P>
Flags can appear, with growing priority,
</P>
<UL>
<LI>in files, judgement <CODE>flags</CODE> and without dash (<CODE>-</CODE>)
<LI>as flags to <CODE>gf</CODE> when invoked, with dash
<LI>as flags to various GF commands, with dash
</UL>
<P>
Some common flags used in grammars:
</P>
<PRE>
startcat=cat use this category as default
lexer=literals int and string literals recognized
lexer=code like program code
lexer=text like text: spacing, capitals
lexer=textlit text, unknowns as string lits
unlexer=code like program code
unlexer=codelit code, remove string lit quotes
unlexer=text like text: punctuation, capitals
unlexer=textlit text, remove string lit quotes
unlexer=concat remove all spaces
unlexer=bind remove spaces around "&amp;+"
optimize=all_subs best for almost any concrete
optimize=values good for lexicon concrete
optimize=all usually good for resource
optimize=noexpand for resource, if =all too big
</PRE>
<P>
For the full set of values for <CODE>FLAG</CODE>,
use on-line <CODE>h -FLAG</CODE>.
</P>
<A NAME="toc9"></A>
<H3>File paths</H3>
<P>
Colon-separated lists of directories searched in the
given order:
</P>
<PRE>
--# -path=.:../abstract:../common:prelude
</PRE>
<P>
This can be (in order of growing preference), as
first line in the top file, as flag to <CODE>gf</CODE>
when invoked, or as flag to the <CODE>i</CODE> command.
The prefix <CODE>--#</CODE> is used only in files.
</P>
<P>
If the environment variabls <CODE>GF_LIB_PATH</CODE> is defined, its
value is automatically prefixed to each directory to
extend the original search path.
</P>
<A NAME="toc10"></A>
<H3>Alternative grammar formats</H3>
<P>
<B>Old GF</B> (before GF 2.0):
all judgements in any kinds of modules,
division into files uses <CODE>include</CODE>s.
A file <CODE>Foo.gf</CODE> is recognized as the old format
if it lacks a module header.
</P>
<P>
<B>Context-free</B> (file <CODE>foo.cf</CODE>). The form of rules is e.g.
</P>
<PRE>
Fun. S ::= NP "is" AP ;
</PRE>
<P>
If <CODE>Fun</CODE> is omitted, it is generated automatically.
Rules must be one per line. The RHS can be empty.
</P>
<P>
<B>Extended BNF</B> (file <CODE>foo.ebnf</CODE>). The form of rules is e.g.
</P>
<PRE>
S ::= (NP+ ("is" | "was") AP | V NP*) ;
</PRE>
<P>
where the RHS is a regular expression of categories
and quoted tokens: <CODE>"foo", CAT, T U, T|U, T*, T+, T?</CODE>, or empty.
Rule labels are generated automatically.
</P>
<P>
<B>Probabilistic grammars</B> (not a separate format).
You can set the probability of a function <CODE>f</CODE> (in its value category) by
</P>
<PRE>
--# prob f 0.009
</PRE>
<P>
These are put into a file given to GF using the <CODE>probs=File</CODE> flag
on command line. This file can be the grammar file itself.
</P>
<P>
<B>Example-based grammars</B> (file <CODE>foo.gfe</CODE>). Expressions of the form
</P>
<PRE>
in Cat "example string"
</PRE>
<P>
are preprocessed by using a parser given by the flag
</P>
<PRE>
--# -resource=File
</PRE>
<P>
and the result is written to <CODE>foo.gf</CODE>.
</P>
<A NAME="toc11"></A>
<H3>References</H3>
<P>
<A HREF="http://www.grammaticalframework.org/">GF Homepage</A>
</P>
<P>
A. Ranta, Grammatical Framework: A Type-Theoretical Grammar Formalism.
<I>The Journal of Functional Programming</I>, vol. 14:2. 2004, pp. 145-189.
</P>
<!-- html code generated by txt2tags 2.6 (http://txt2tags.org) -->
<!-- cmdline: txt2tags -thtml ./doc/gf-reference.t2t -->
</BODY></HTML>

View File

@@ -1,54 +0,0 @@
<html>
<body>
GF Version 2.8, released 8 July 2007; updated 12 September.
<ul>
<li> <a href="download/GF-2.8.tgz"><tt>GF-2.8.tgz</tt></a>,
Haskell and Java sources, grammar library sources, examples, documentation.
To compile and install: read <a href="src/INSTALL"><tt>src/INSTALL</tt></a>.
<li> <a href="download/GF-2.8-lib.tgz"><tt>GF-2.8-lib.tgz</tt></a>,
Compiled grammar libraries</a>. To install:
unpack this in the directory pointed by <tt>GF_LIB_PATH</tt>.
<li> <a href="download/GF-2.8-i386-pc-linux-gnu.tgz"><tt>GF-2.8-i386-pc-linux-gnu.tgz</tt></a>,
Linux binary, with precompiled grammar libraries. To install:
<pre>
tar xvfz GF-2.8-i386-pc-linux-gnu.tgz
cd GF-2.8-i386-pc-linux-gnu
./configure
make install
</pre>
You may need <tt>sudo make install</tt>; if you cannot write in
<tt>/usr/local/</tt>, you can change the target directory
by <tt>./configure --prefix=MYDIR</tt>.
<li> <a href="download/GF-2.8-i386-apple-darwin8.9.1.tgz"><tt>GF-2.8-i386-apple-darwin8.9.1.tgz</tt></a>, Mac OS X binary (Intel), with precompiled grammar libraries. Requires Readline from
<a href="http://www.macports.org/">MacPorts</a>. To install, see above item.
<li> <a href="download/GF-2.8-windows-cygwin.tgz"><tt>GF-2.8-windows-cygwin.tgz</tt></a>, Windows Cygwin binary. Requires
<a href="http://www.cygwin.com/">Cygwin</a>. To install, see above item.
</ul>
The <a href=
"http://sourceforge.net/project/showfiles.php?group_id=132285">Sourceforge GF site</a>
has currently only v 2.7 and older versions.
<p>
Don't forget that you can always get the current sources from the
<a href="http://www.cs.chalmers.se/Cs/Research/Language-technology/darcs/GF/doc/darcs.html">GF Darcs Repository</a>. First time you do
<pre>
darcs get --partial --set-scripts-executable http://www.cs.chalmers.se/Cs/Research/Language-technology/darcs/GF/
</pre>
and subsequent times
<pre>
darcs pull -a
</pre>
Then compile and install as described in
<a href="src/INSTALL"><tt>GF/src/INSTALL</tt></a>.
</body>
</html>

View File

@@ -1,93 +0,0 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<META NAME="generator" CONTENT="http://txt2tags.sf.net">
<TITLE>Grammatical Framework Download and Installation</TITLE>
</HEAD><BODY BGCOLOR="white" TEXT="black">
<P ALIGN="center"><CENTER><H1>Grammatical Framework Download and Installation</H1>
<FONT SIZE="4">
<I>Version 3.1.6, 23 April 2010</I><BR>
</FONT></CENTER>
<H2>Latest developer code</H2>
<P>
<A HREF="../doc/darcs.html">GF darcs repository</A>
</P>
<H2>Latest release</H2>
<P>
GF 3.1.6 released 23 April 2010.
</P>
<UL>
<LI>MacOS X installer package:
<A HREF="gf-3.1.6-leopard.pkg"><CODE>gf-3.1.6-leopard.pkg</CODE></A> (7.7MB)
<LI>MacOS X (gzipped executable, Leopard and Snow Leopard):
<A HREF="gf-3.1.6-bin-intel-mac.gz"><CODE>gf-3.1.6-bin-intel-mac.gz</CODE></A> (1.9MB)
<LI>Windows (zipped executable):
<A HREF="gf-3.1.6-bin-i486-windows.zip"><CODE>gf-3.1.6-bin-i486-windows.zip</CODE></A>
(1.6 MB)
<LI>Ubuntu Linux (gzipped executable):
<A HREF="gf-3.1.6-bin-i486-linux.gz"><CODE>gf-3.1.6-bin-i486-linux.gz</CODE></A>
(1.7 MB)
<LI>compiled library package:
<A HREF="gf-3.1.6-lib.tar.gz"><CODE>gf-3.1.6-lib.tar.gz</CODE></A>
(4.4 MB)
<LI>full source package (GF system, libraries, examples, documentation):
<A HREF="gf-3.1.6-src.tar.gz"><CODE>gf-3.1.6-src.tar.gz</CODE></A>
(11 MB)
<P></P>
GF is also on <A HREF="http://hackage.haskell.org/package/gf">Hackage</A>
</UL>
<P>
What's new? See the <A HREF="release-3.1.6.html">release notes</A>.
</P>
<H2>Previous releases</H2>
<P>
<A HREF="old-index.html">Follow this link</A>.
</P>
<H2>Installation instructions</H2>
<P>
The Windows package is installed by just unpacking it anywhere.
It finds the libraries relative to the <CODE>.exe</CODE> file.
</P>
<P>
To install a binary package for MacOS X or Linux: uncompress the executable and
put it somewhere on your path, renaming it to just <CODE>gf</CODE>. For instance:
</P>
<PRE>
gunzip gf-bin-[version].gz
sudo mv gf-bin-[version] /usr/local/bin/gf
</PRE>
<P>
To install the libraries (if done separately), unpack them in the place to which your
<CODE>GF_LIB_PATH</CODE> points.
</P>
<PRE>
cd $GF_LIB_PATH
gtar xvfz gf-lib-[VERSION].tgz
</PRE>
<P>
If this variable hasn't been defined, it is useful define it, e.g.
</P>
<PRE>
export GF_LIB_PATH=/usr/local/lib/gf/
</PRE>
<P></P>
<P>
To compile and install from source on Mac or Linux, do:
</P>
<PRE>
tar xvfz gf-[VERSION].tgz
cd GF/src
runghc Setup configure --user
runghc Setup build
runghc Setup install
</PRE>
<P>
The last command must be prefixed by <CODE>sudo</CODE>, if the installation is outside
user-writeable area.
</P>
<!-- html code generated by txt2tags 2.5 (http://txt2tags.sf.net) -->
<!-- cmdline: txt2tags -thtml ./download/index-3.1.6.t2t -->
</BODY></HTML>

View File

@@ -1,146 +0,0 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<HTML>
<HEAD>
<META NAME="generator" CONTENT="http://txt2tags.sf.net">
<TITLE>Grammatical Framework Download and Installation</TITLE>
<style>
h1 { text-align: center; }
h1,h2,h3 { font-family: sans-serif; }
ul.downloads a { font-family: monospace; }
</style>
</HEAD>
<BODY BGCOLOR="white" TEXT="black">
<H1>Grammatical Framework<br>Download and Installation</H1>
<H2>Latest developer code</H2>
<P>
<A HREF="../doc/gf-developers.html">GF darcs repository</A>
</P>
<H2>Latest release</h2>
<dl>
<dt>GF 3.1, 15 December 2009
<dd>
<p>
<ul class=downloads>
<li>For Linux (32-bit):
<a href="gf-3.1-bin-i486-linux.tar.gz">gf-3.1-bin-i468-linux.tar.gz</a>
<li>For Linux (64-bit):
<a href="gf-3.1-bin-x86_64-linux.tar.gz">gf-3.1-bin-x86_64-linux.tar.gz</a>
<li>For Mac:
<a href="gf-3.1-bin-intel-mac.tar.gz">gf-3.1-bin-intel-mac.tar.gz</a>
(Leopard &amp; Snow Leopard)
<li>For Windows:
<a href="gf-3.1-bin-i486-windows.zip">gf-3.1-bin-i486-windows.zip</a>
<li>Source package:
<a href="gf-3.1-src.tar.gz">gf-3.1-src.tar.gz</a>
(a dump of the darcs repo)
<li>Libraries: <a href="gf-lib-1.7.tar.gz">gf-lib-1.7.tar.gz</a>
(sources, compiled as alltenses/present, docs)
</ul>
<H3>Installation instructions</H3>
<ul>
<li>Linux &amp; Mac binaries: <tt>tar xvfz</tt> in /
<li>Windows binary: unzip in c:\
<li>Compiled library:
<tt>tar xvfz</tt> in some DIR and point the variable GF_LIB_PATH to DIR/lib.
<li>
Source package: <tt>tar xvfz</tt> somewhere and compile as follows:
<P>
<PRE>
tar xvfz gf-3.0.tgz
cd gf-3.0
# alternative 1:
runghc Setup configure
runghc Setup build
runghc Setup install
# alternative 2:
make
make install
</PRE>
</dl>
<H2>Old releases</H2>
<dl>
<dt>GF 3.0, 24 June 2009.
<dd>
<P>
<ul>
<li><A HREF="gf-3.0-mac.gz">Mac OS X Leopard (intel) executable</A>
(requires Readline from <A HREF="http://www.macports.org/">Mac Ports</A>)
<li><A HREF="gf-3.0-mac-noreadline.gz">Mac OS X Leopard (Intel) executable</A>
(doesn't require Readline)
<li><A HREF="gf-linux.tar.gz">Linux (intel) binary package</A>
<li><A HREF="gf-win32.zip">Windows binary package</A>
<li><A HREF="gf-lib-1.6.tgz">Compiled libraries, v. 1.6</A>
<li><A HREF="gf-3.0-src.tgz">Source package for GF system (a dump of the darcs repo)</A>
</ul>
<H3>Installation instructions</H3>
<p>
Mac binary: gunzip and put somewhere on your path.
<P>
Linux: <tt>tar xvfz</tt> in /
<P>
Windows: unzip in c:\
<p>
Compiled library: <tt>tar xvfz</tt> in some DIR and point the variable GF_LIB_PATH to DIR/lib.
<p>
Source package: <tt>tar xvfz</tt> somewhere and compile as follows:
<P>
<PRE>
tar xvfz gf-3.0.tgz
cd gf-3.0
# alternative 1:
runghc Setup configure
runghc Setup build
runghc Setup install
# alternative 2:
make
make install
</PRE>
</dl>
GF 3.0 beta3, April 2009.
<UL>
<LI>
<A HREF="GF-3.0-beta3-i386-apple-darwin9.6.0.tgz">Mac OS X Leopard (intel) binary package</A>
<LI>
<A HREF="gf-3.0-beta3.zip">Windows binary</A>
<LI><A HREF="GF-3.0-beta3.tgz">GF 3.0 beta3 sources</A> (both system and library)
</UL>
3.0 beta2
<UL>
<LI><A HREF="GF-3.0-beta2-i686-pc-linux-gnu.tgz">GF 3.0 beta2 Linux binary package</A> (Intel, Ubuntu)
<P></P>
<LI>GF 3.0 beta2 MacOS X binary package:
<A HREF="GF-3.0-beta2-i386-apple-darwin9.4.0.tgz">Leopard</A> (Intel Mac with MacOS X Leopard)
<A HREF="GF-3.0-beta2-i386-apple-darwin8.11.1.tgz">Tiger</A> (Intel Mac with MacOS X Tiger)
<P></P>
<LI><A HREF="gf-3.0-beta2.zip">GF 3.0 beta2 Windows package</A> (includes libraries)
<P></P>
<LI><A HREF="GF-3.0-beta2.tgz">GF 3.0 beta2 sources</A> (both system and library)
<P></P>
<LI><A HREF="gf-lib-1.4.tgz">GF libraries v 1.4</A> (compiled resource grammar libraries)
</UL>
<!--
<UL>
<LI><A HREF="../../GF2/download/index.html">GF 2.9 download page</A>
</UL>
-->
<!-- html code generated by txt2tags 2.4 (http://txt2tags.sf.net) -->
<!-- cmdline: txt2tags -thtml index.txt -->
</BODY></HTML>

View File

@@ -1,87 +0,0 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<META NAME="generator" CONTENT="http://txt2tags.sf.net">
<TITLE>GF Version 3.1.6 Release Notes</TITLE>
</HEAD><BODY BGCOLOR="white" TEXT="black">
<P ALIGN="center"><CENTER><H1>GF Version 3.1.6 Release Notes</H1>
<FONT SIZE="4">
<I>23 April 2010</I><BR>
</FONT></CENTER>
<H1>Installation</H1>
<P>
The binaries now work out of the box for each platform and support
completions (file names and parsing), because readline has been
changed to haskeline.
</P>
<P>
To compile from source, GHC 6.12 is now required. But GHC is not needed
if the binary executables are used.
</P>
<P>
Binaries (<CODE>.gfo</CODE> and <CODE>.pgf</CODE> files) compiled with GF 3.1 are incompatible
with 3.1.6 and must either be removed; alternatively, the <CODE>-src</CODE> flag can be
used when compiling.
</P>
<P>
Notice the new place to send bug reports (see GF's welcome message)!
</P>
<H1>New features</H1>
<P>
Grammar language
</P>
<UL>
<LI>improved support for dependent types (see <CODE>SUMO</CODE>, <CODE>nqueens</CODE> in <CODE>examples</CODE>)
</UL>
<P>
Shell commands and options (see <CODE>help</CODE> in GF for more information)
</P>
<UL>
<LI><CODE>eb</CODE>: example-based grammar file conversion
(see <CODE>examples/animals/QuestionI.gf</CODE>)
<LI><CODE>vd = visualize_dependency</CODE>: show dependency tree
<LI><CODE>vp = visualize_parse</CODE>: show parse tree
<LI><CODE>gr, gt, mq, tq</CODE>: use a seed tree with metavariables
<LI><CODE>gr, p, tq</CODE>: use <CODE>-probs=FILE</CODE> to bias or rank generated trees
<LI><CODE>gt</CODE> now tries the different alternatives in the order in which they appear in the source code
<LI><CODE>dg</CODE>: hide modules when printing dependency graph
<LI>-output-format=lambda_prolog let us to use Lambda Prolog for exhaustive generation with dependent types
</UL>
<P>
Libraries
</P>
<UL>
<LI>Urdu completed (Shafqat Virk)
<LI>Turkish morphology + Zamberek's dictionary in GF (Server Cimen)
</UL>
<P>
Examples
</P>
<UL>
<LI>SUMO
<LI>phrasebook
<LI>nqueens
</UL>
<P>
Internal
</P>
<UL>
<LI>single PMCFG format for both linearization and parsing
<LI>use of Haskeline for completion - more portable than Readline
<LI>unicode support from Haskell 6.12 instead of home-made coding
</UL>
<H2>Issues</H2>
<P>
Javascript generation is not updated to the new PGF format.
<A HREF="old-index.html">GF 3.1</A> should still be used for building Javascript applications.
</P>
<!-- html code generated by txt2tags 2.5 (http://txt2tags.sf.net) -->
<!-- cmdline: txt2tags -thtml release-3.1.6.txt -->
</BODY></HTML>

View File

@@ -1,5 +0,0 @@
# Images in this folder have moved, now hosted at GitHub
# John 2013-01-10
RewriteEngine On
RewriteRule ^(.*)$ https://raw.github.com/GrammaticalFramework/gf-eclipse-plugin/master/doc/images/$1 [L,R=301]

View File

@@ -1,446 +0,0 @@
<html>
<head>
<title>
GF Eclipse Plugin
</title>
<link rel="stylesheet" type="text/css" href="http://www.grammaticalframework.org/css/style.css" /> <meta name="viewport" content="width=device-width" />
</head>
<body>
<h1 id="the-gf-eclipse-plugin">The GF Eclipse Plugin</h1>
<p>John J. Camilleri<br />Updated: 22 February 2013</p>
<p><em>The research leading to these results has received funding from the European Union's Seventh Framework Programme (FP7/2007-2013) under grant agreement no. FP7-ICT-247914 (the <a href="http://www.molto-project.eu/">MOLTO Project</a>).</em></p>
<h2 id="introduction">Introduction</h2>
<p>The aim behind developing a desktop IDE for GF is to provide more powerful tools than may be possible and/or practical in a web-based environment (the <a href="http://www.grammaticalframework.org/demos/gfse/">GF Web IDE</a>). In particular, the ability to resolve identifier cross-references and browse external libraries quickly during development time is one of the primary motivations for the project.</p>
<p>The choice was made to develop this desktop IDE as a plugin for the Eclipse Platform as it emerged as the most popular choice among the GF developer community. Support for the platform is vast and many tools for adapting Eclipse to domain-specific languages already exist. Unlike the zero-click Web IDE approach, using the GF Eclipse plugin requires some manual installation and configuration on the development machine.</p>
<h3 id="license">License</h3>
<p>The GF Eclipse Plugin is open-source under the <strong><a href="http://www.gnu.org/licenses/gpl-3.0.txt">GNU General Public License (GPL)</a></strong>.<br /><em>The licenses that cover the rest of GF are listed <a href="http://www.grammaticalframework.org/LICENSE">here</a>.</em> <em>Xtext and Eclipse are released under the <a href="http://www.eclipse.org/legal/epl-v10.html">Eclipse Public License (EPL)</a>.</em></p>
<h3 id="links">Links</h3>
<ul>
<li>This document shall contain all collected information about the plugin. The most up-to-date version of this file can always be found <a href="https://github.com/GrammaticalFramework/gf-eclipse-plugin/blob/master/README.md">here</a></li>
<li>This documentation is also available at the <a href="http://www.grammaticalframework.org/eclipse/">GF website</a> and the <a href="http://www.molto-project.eu/node/1395">MOLTO Project Wiki</a>.</li>
<li>Source code repository is at <a href="https://github.com/GrammaticalFramework/gf-eclipse-plugin">github.com/GrammaticalFramework/gf-eclipse-plugin</a></li>
<li>For reporting bugs and requesting features, please use the <a href="https://github.com/GrammaticalFramework/gf-eclipse-plugin/issues">GitHub Issue Tracker</a></li>
<li>Here are some <a href="https://github.com/GrammaticalFramework/gf-eclipse-plugin/tree/master/workspace-demo/GF%20Project">example GF projects</a> for testing out the plugin features.</li>
<li>Software update site URL for installing through Eclipse: <code>http://www.grammaticalframework.org/eclipse/release/</code></li>
</ul>
<h3 id="publications">Publications</h3>
<ul>
<li><a href="http://academic.johnjcamilleri.com/presentations/2012-05%20EAMT%20poster.pdf">Poster</a> at EAMT 2012 in Trento, Italy</li>
<li><a href="http://academic.johnjcamilleri.com/papers/freerbmt2012.pdf">Paper</a> presented at FreeRBMT 2012 in Gothenburg, Sweden.</li>
</ul>
<h2 id="features">Features</h2>
<ul>
<li>Syntax highlighting and error detection</li>
<li>Code folding, quick block-commenting, automatic code formatting</li>
<li>Definition outlining, jump to declaration, find usage</li>
<li>Warnings for problems in module dependency hierarchy</li>
<li>Launch configurations, i.e. compilation directly from IDE</li>
<li>Use GF Shell from within Eclipse</li>
<li>Auto-completion for declared identifiers</li>
<li>Background compilation (shallow) using project builder</li>
<li>Support for <em>Open Declaration</em> (F3), including qualified names</li>
<li>Code generation for new languages in application grammars</li>
<li>Inline documentation for function calls, overloads</li>
<li>Proper cross-reference handling with qualified names</li>
<li>Test management and testing tool</li>
<li>External library browser</li>
</ul>
<h2 id="release-history">Release history</h2>
<p><strong>22/02/13</strong> : (1.5.2.x) New option for specifying include/exclude build files. Progress indicators during build.</p>
<p><strong>12/06/12</strong> : (1.5.1.x) Support for scoping when library sources not available. Performance and implementational improvements to External Library View.</p>
<p><strong>19/04/12</strong> : (1.5.0.x) Removed need for <code>.gfexternal</code> folder. Much improved &quot;External Libraries&quot; view allows you to search in current scope. Memory usage improvements in scoping implementation. Validation now occurs on file open. Re-added GF Library Path field in preferences.</p>
<p><strong>04/04/12</strong> : (1.4.3.x) Improvements to the Test Manager. Added support for arbitrary commands in launch. Made the license information clearer.</p>
<p><strong>22/03/12</strong> : (1.4.2.x) Added wizard for context-free grammars (no syntax support, though). Context-menu option for toggling the GF Nature and Builder together. Test Manager now parses languages &amp; parameters, and includes filtering and toggling options.</p>
<p><strong>14/03/12</strong> : (1.4.1.x) GF source files can now be anywhere in project, not necessarily at top level.</p>
<p><strong>06/03/12</strong> : (1.4.0.x) Test manager view. Updated launch configurations. UI improvements, new icons. Inline contextual documentation. Correct resolution of qualified identifiers. Bug fixes and some refactoring.</p>
<p><strong>07/02/12</strong> : (1.3.0.x) Re-written underlying GF grammar.</p>
<p><strong>02/02/12</strong> : (1.2.5.x) Hugely improved scoping performance. New &quot;Clone to new language&quot; wizard. Improved code formatting. More efficient builder. Removed library path preference. GF runtime is now automatically found.</p>
<p><strong>23/01/12</strong> : (1.2.4.x) Logging is now done to the Eclipse Platform Log (use &quot;Error Log&quot; view). Tested with Eclipse 3.6.2. Bug fixes.</p>
<p><strong>11/01/12</strong> : (1.2.3.x) Updated to use Xtext 2.1.0. Links to external files now moved into new &quot;GF Library View&quot;.</p>
<p><strong>24/11/11</strong> : (1.2.0.x) with support for &quot;Open Declaration&quot; (F3) function, including for external libraries.</p>
<p><strong>18/11/11</strong> : Third BETA (1.1.0.x) released, overhauled to take advantage of new compiler features. Tag-based scoping with caching for better performance. Interactive console (GF Shell) for launch configs.</p>
<p><strong>11/10/11</strong> : Second BETA (1.0.0.x) released, with improved support for qualified names, local variable bindings, selective inheritance, module outlining, and launch configurations. Also new GF Project type.</p>
<p><strong>01/10/11</strong> : Initial BETA released.</p>
<!----------------------------------------------------------------------------->
<h2 id="installation-updating">Installation &amp; updating</h2>
<h3 id="system-requirements">System requirements</h3>
<ol style="list-style-type: decimal">
<li><a href="http://www.eclipse.org/downloads/">Eclipse</a> 3.6 or above.</li>
<li><a href="http://www.grammaticalframework.org/download/release-3.3.3.html">GF 3.3.3</a> or above. The path to GF must be set within the plugin preferences (see below).</li>
</ol>
<p>Using the GF Resource Grammar Library requires that the RGL binaries are also installed on your system. If you are using the <a href="http://www.grammaticalframework.org/download/index.html">pre-compiled binaries</a> but have separately downloaded the RGL sources to your system, you can optionally specify this path in the plugin preferences (see below).</p>
<h3 id="installing-the-plugin-for-the-first-time">Installing the plugin for the first time</h3>
<h4 id="available-software-sites">Available Software Sites</h4>
<p>In order for dependencies to be satisfied, you need to ensure that your Eclipse has the following update site URLs set:</p>
<ul>
<li>Eclipse releases (change version name to match): <code>http://download.eclipse.org/releases/indigo</code></li>
<li>Xtext: <code>http://download.eclipse.org/modeling/tmf/xtext/updates/composite/releases/</code></li>
</ul>
<p>You can set these from <strong>Preferences → Install/Update → Available Software Sites</strong>.</p>
<h4 id="eclipse-preferences">Eclipse preferences</h4>
<p>How to find the <strong>Eclipse preferences</strong> window depends on your Eclipse version and/or OS, and may be either of:</p>
<ul>
<li><strong>Window → Preferences</strong></li>
<li><strong>Eclipse → Preferences</strong></li>
</ul>
<h3 id="installation">Installation</h3>
<ol style="list-style-type: decimal">
<li>Inside Eclipse, go to <strong>Help → Install New Software</strong>.</li>
<li>Add new software site using the URL: <code>http://www.grammaticalframework.org/eclipse/release/</code></li>
<li>Select the <strong>GF Eclipse Plugin</strong>, and make sure the <strong>Contact all update sites during install to find required software</strong> option is checked.</li>
<li>Click Next, accept the license agreement and install.</li>
<li>Accept the prompt warning that the software is unsigned.</li>
<li>Restart Eclipse when prompted.</li>
</ol>
<h4 id="settings-preferences">Settings &amp; preferences</h4>
<ol style="list-style-type: decimal">
<li>Add the GF perspective by clicking <strong>Window → Open Perspective → Other</strong> and choosing <strong>GF</strong>.</li>
<li>Open the plugin settings by going to <strong>Preferences → Grammatical Framework</strong> (image below).</li>
<li>The plugin will try to determine the path to your GF executable automatically, but this may need to be corrected.<br />The path should include the name of the GF binary itself, e.g. <code>/home/john/.cabal/bin/gf</code> or <code>C:\Users\John\GF\bin\gf.exe</code>.</li>
<li>The <em>Additional path directive</em> setting can be used if you want to avoid writing <code>--# -path=...</code> directives in your source files. By default it is set to <code>.:alltenses:prelude</code>, but can also be left blank. This is passed to GF using the <code>--path</code> flag.</li>
<li>If you are using a pre-compiled version of the Resource Grammar Library (i.e. you didn't build it from source yourself) but you have the sources available on your system, then you can enter their path in the <em>Library source path</em> setting. This is optional and is only used for jumping to source definitions.<br />You should enter an absolute system path, up to and including the <code>src</code> folder, e.g. <code>/home/john/GF/lib/src/</code> or <code>C:\Users\John\GF\lib\src\</code>.</li>
<li>You can also adjust the verbosity level of the GFEP console log in the preferences window.</li>
</ol>
<div class="figure">
<img src="https://raw.github.com/GrammaticalFramework/gf-eclipse-plugin/master/doc/images/eclipse-preferences.png" alt="Plugin preferences window" /><p class="caption">Plugin preferences window</p>
</div>
<h3 id="updating-the-plugin">Updating the plugin</h3>
<ol style="list-style-type: decimal">
<li>In Eclipse, go to <strong>Help → Check for updates</strong>.</li>
<li>Any available updates will appear in the dialog. Select them and follow the usual steps.</li>
</ol>
<p><em>Note:</em> You will probably want to uncheck the <strong>Contact all update sites during install to find required software</strong> option, which is not usually needed when simply updating the plugin (it makes things go a lot slower).</p>
<h4 id="deprecations">Deprecations</h4>
<ul>
<li>Any folders <code>.gfexternal</code> can safely deleted as of GFEP ≥ 1.5. Using Eclipse's <strong>Clean</strong> function from the <strong>Run</strong> menu will do this for you automatically.</li>
<li>If your project has a folder named <code>(External)</code> you can safely delete this <strong>via the Eclipse Project Explorer</strong>. It is no longer used in GFEP ≥ 1.2.3</li>
<li>If your workspace contains a log file <code>gfep.log</code> then you can safely delete it from your system. As of version 1.2.4, GFEP uses Eclipse's standard log file at <code>&lt;workspace&gt;/.metadata/.log</code></li>
</ul>
<h3 id="project-settings">Project settings</h3>
<p>Although the plugin should take care of your project settings for you, in case anything gets messed up you can always correct them manually as follows:</p>
<h4 id="project-nature">Project nature</h4>
<p>Your <code>.project</code> file should include the GF Project Nature as follows:</p>
<pre><code>&lt;natures&gt;
&lt;nature&gt;org.grammaticalframework.eclipse.ui.natures.projectNatureID&lt;/nature&gt;
&lt;/natures&gt;</code></pre>
<h4 id="builder">Builder</h4>
<p>Your <code>.project</code> file should include the GF Builder as follows:</p>
<pre><code>&lt;buildSpec&gt;
&lt;buildCommand&gt;
&lt;name&gt;org.grammaticalframework.eclipse.ui.build.GFBuilderID&lt;/name&gt;
&lt;arguments&gt;
&lt;/arguments&gt;
&lt;/buildCommand&gt;
&lt;/buildSpec&gt;</code></pre>
<h4 id="specifying-build-files">Specifying build files</h4>
<p>As of GFEP ≥ 1.5.2, you are now able to explicitly a set of modules in your GF project which should be either included or excluded from the build process. In the inclusive case, this would normally contain your &quot;top-level&quot; modules. This can be done right-clicking on your project in the Project Explorer and choosing <strong>Properties → GF Build Settings</strong>. From here you simply tick which modules in your project the GF builder should compile:</p>
<div class="figure">
<img src="https://raw.github.com/GrammaticalFramework/gf-eclipse-plugin/master/doc/images/eclipse-project-build-settings.png" alt="Project-specific build settings" /><p class="caption">Project-specific build settings</p>
</div>
<p>When doing this, GFEP will never attempt to compile any other files in the project. Whenever you add a new top-level module or change your module hierarchy, be sure to check these build settings again.</p>
<!----------------------------------------------------------------------------->
<h2 id="getting-started">Getting started</h2>
<p>Some steps you can follow to get a feel of of the plugin's features.</p>
<h3 id="video-tutorial">Video tutorial</h3>
<p>A quick run through of the major features available in the GF Eclipse Plugin.</p>
<iframe src="http://player.vimeo.com/video/38768382?byline=0&amp;portrait=0" width="693" height="512" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>
<p><em>If the video doesn't appear above, you can view it at <a href="https://vimeo.com/38768382">https://vimeo.com/38768382</a></em></p>
<h3 id="the-eclipse-workspace-and-project-concepts">The Eclipse <em>workspace</em> and <em>project</em> concepts</h3>
<p>When you run Eclipse, it asks you to create or specify a <em>workspace</em> on your system, which is essentially the top directory that Eclipse will &quot;see&quot;. Any code you wish to work on inside Eclipse must reside in this workspace. A workspace contains one or more <em>projects</em>, which may or may not be related to each other. Generally each folder under the top-level workspace directory is considered an individual project, i.e.:</p>
<pre><code>workspace/
Project1/
file1-1.gf
file1-2.gf
Project2/
subdir2-1/
file2-1-1.gf
file2-1-2.gf
file2-1.gf
file2-2.gf</code></pre>
<p>If you open an existing folder as your workspace in Eclipse, then your folders in that workspace <strong>do not</strong> automatically become Eclipse projects. To do this, you must follow the &quot;Create new GF Project&quot; wizard below, and give your project the exact name of the existing folder (e.g. <code>Project1</code> or <code>Project2</code> in the example above.)</p>
<h4 id="gf-nature">GF Nature</h4>
<p>The <em>GF Nature</em> is what makes a regular Eclipse project a <em>GF</em> project. If you create a new GF Project from scratch then you don't need to worry too much about them. If you already have some project set up in your Eclipse workspace, then you will need to associate the builder with your project in order for all the GF goodness to work. This will internally add the <em>GF Builder</em> to your project also.</p>
<p>As of 1.4.2, this can be done very easily by right-clicking on your project in the explorer and clicking <strong>Add/Remove GF Nature</strong>. If your project has the GF icon overlayed on it, then the GF nature and builder are correctly associated with it.</p>
<p>See the <strong>project settings</strong> section above if you want to mess with your <code>.project</code> file.</p>
<h4 id="metadata-folders">Metadata folders</h4>
<p>GFEP will create the following metadata directories within your project:</p>
<ul>
<li>A <code>.gfbuild</code> directory in every folder containing GF source code, containing <code>.gf-tags</code> files created using the GF <code>--tags</code> compiler flag.</li>
</ul>
<p>These can be removed manually at any time, as they will always be regenerated as necessary. You will probably want to ignore these directories in your version control system.</p>
<h3 id="create-a-new-gf-project">Create a new GF Project</h3>
<p>If you have a folder in your workspace which you want to convert into a GF Project, then you can select it from the drop-down. This folder will then appear as an Eclipse project in your workspace.</p>
<p><img src="https://raw.github.com/GrammaticalFramework/gf-eclipse-plugin/master/doc/images/eclipse-projectwizard-1.png" alt="New project wizard" /> <img src="https://raw.github.com/GrammaticalFramework/gf-eclipse-plugin/master/doc/images/eclipse-projectwizard-2.png" alt="New project wizard" /></p>
<h3 id="new-module-wizard">New module wizard</h3>
<p>Use the <strong>GF Module</strong> wizard from <strong>File → New → Other → GF Module</strong>:</p>
<div class="figure">
<img src="https://raw.github.com/GrammaticalFramework/gf-eclipse-plugin/master/doc/images/eclipse-modulewizard-1.png" alt="New module wizard" /><p class="caption">New module wizard</p>
</div>
<p>You can find some small examples <a href="https://github.com/GrammaticalFramework/gf-eclipse-plugin/tree/master/workspace-demo/GF%20Project">here</a>. Download the files and manually add them to your Eclipse workspace to experiment with some of the plugin features.</p>
<h3 id="clone-module-wizard">Clone module wizard</h3>
<p>If you want to clone an existing module into a new language, you can now do so via the <strong>Clone GF Module</strong> wizard. This is also available as a context menu option in the <strong>Project Explorer</strong>, via <strong>&lt;Right click&gt; → Grammatical Framework → Compile for new language</strong>:</p>
<div class="figure">
<img src="https://raw.github.com/GrammaticalFramework/gf-eclipse-plugin/master/doc/images/eclipse-clonewizard.png" alt="Clone GF module to new language wizard" /><p class="caption">Clone GF module to new language wizard</p>
</div>
<p>This will create and open a new module with the relevant replacements made. Note how in this case string constants are replaced by the empty string <code>&quot;&quot;</code>. This wizard currently only works on <code>concrete</code> and <code>instance</code> modules.</p>
<div class="figure">
<img src="https://raw.github.com/GrammaticalFramework/gf-eclipse-plugin/master/doc/images/eclipse-clonewizard-newfile.png" alt="Newly cloned file" /><p class="caption">Newly cloned file</p>
</div>
<h3 id="workbench-editor-layout">Workbench editor layout</h3>
<p>Use Eclipse' own features to drag and drop your editor tabs to suit your needs.</p>
<div class="figure">
<img src="https://raw.github.com/GrammaticalFramework/gf-eclipse-plugin/master/doc/images/eclipse-editor-general.png" alt="The editor and outline view" /><p class="caption">The editor and outline view</p>
</div>
<h3 id="outline-view">Outline view</h3>
<p>The <strong>Outline</strong> view in the bottom-left offers a quite overview of your module structure. Clicking any of the terms will make your cursor jump to that point in the file.</p>
<h3 id="cross-referencing-errors-and-warnings">Cross-referencing errors and warnings</h3>
<p>Notice how changing a <code>cat</code> definition for example will produce warnings and/or errors in other the modules.</p>
<div class="figure">
<img src="https://raw.github.com/GrammaticalFramework/gf-eclipse-plugin/master/doc/images/eclipse-editor-cat.png" alt="Warnings and errors in the editor" /><p class="caption">Warnings and errors in the editor</p>
</div>
<h3 id="validation">Validation</h3>
<p>The in-editor validation sometimes needs to be triggered/updated by a keystroke. If you can still see errors which you believe should be correct, try adding a space character to ensure the validation is re-triggered.</p>
<p>Sometimes you may get an entire file marked with errors, even though in fact there is only a single error which is causing the internal builder to fail. In such cases referring to the <strong>Problems</strong> view should help you locate the cause. This issue is particularly relevant when changes made to one module may induce errors in its descendants (e.g. renaming a parameter in a resource module). This behaviour will hopefully be improved in future versions.</p>
<h4 id="builder-1">Builder</h4>
<p>For validation to work correctly, the project's <strong>Build Automatically</strong> option should be turned on. Each time you save a file (or some other change occurs in your project), the builder should get triggered which re-compiles any GF files which have changed. If the builder does not seem to get triggered, try to run a <em>clean</em> via <strong>Project → Clean...</strong></p>
<h3 id="code-formatting">Code formatting</h3>
<p>Use the built-in code formatter to tidy your code automatically. Right-click in the editor and choose <strong>Format</strong> or use the keyboard shortcut <strong>Ctrl+Shift+F</strong>.</p>
<p><img src="https://raw.github.com/GrammaticalFramework/gf-eclipse-plugin/master/doc/images/eclipse-before-format.png" alt="Before auto-formatting" /> <img src="https://raw.github.com/GrammaticalFramework/gf-eclipse-plugin/master/doc/images/eclipse-after-format.png" alt="After auto-formatting" /></p>
<h3 id="syntax-highlighting">Syntax highlighting</h3>
<p>You can change your syntax colouring styles as you wish from <strong>Preferences → Grammatical Framework → Syntax Colouring</strong></p>
<div class="figure">
<img src="https://raw.github.com/GrammaticalFramework/gf-eclipse-plugin/master/doc/images/eclipse-syntaxcoloring.png" alt="Syntax highlighting styles" /><p class="caption">Syntax highlighting styles</p>
</div>
<h3 id="launch-configurations">Launch configurations</h3>
<p>Set up a launch configuration from <strong>Run → Run Configurations... → Grammatical Framework</strong>. You will see the dialog below with some fields automatically filled in for you.</p>
<div class="figure">
<img src="https://raw.github.com/GrammaticalFramework/gf-eclipse-plugin/master/doc/images/eclipse-launchconfig.png" alt="Launch configuration dialog" /><p class="caption">Launch configuration dialog</p>
</div>
<p>Run the launch config and you will see the output from the GF compiler in the console view within Eclipse.</p>
<div class="figure">
<img src="https://raw.github.com/GrammaticalFramework/gf-eclipse-plugin/master/doc/images/eclipse-compileroutput.png" alt="Output from the GF compiler" /><p class="caption">Output from the GF compiler</p>
</div>
<h4 id="run-as...-launch-shortcut">Run As... launch shortcut</h4>
<p>Using the <strong>Run → Run As → Compile with GF</strong> shortcut will take the current selection or active editor and do one of two things:</p>
<ol style="list-style-type: decimal">
<li>If a launch configuration already exists which the current file in its <em>Source filenames</em> field, then that config will be launch directly.</li>
<li>Otherwise, a new a launch configuration window is displayed where you will need to review and confirm the default settings before continuing.</li>
</ol>
<h3 id="consoles">Consoles</h3>
<p>The plugin provides its own console view named <em>GFEP Log</em>, which shows log messages based on the <strong>Log Level</strong> preference (<strong>Preferences → Grammatical Framework</strong>).</p>
<p>Additionally, every time a grammar is <strong>Run</strong> a <em>new</em> console is opened to display the output. This console may also serve as the interactive GF Shell, depending on the <strong>Interactive Mode</strong> checkbox in your <strong>Run Configuration</strong>.</p>
<p>Eclipse does not make it obvious when multiple console windows open; click on the <strong>Display Selected Console</strong> button to switch between open consoles:</p>
<div class="figure">
<img src="https://raw.github.com/GrammaticalFramework/gf-eclipse-plugin/master/doc/images/eclipse-console-icon.png" alt="Display Selected Console icon" /><p class="caption">Display Selected Console icon</p>
</div>
<p>If the process associated with a console window has terminated, it will be indicated in the upper-left corner as below. Such console windows can then be closed using the grey cross button:</p>
<div class="figure">
<img src="https://raw.github.com/GrammaticalFramework/gf-eclipse-plugin/master/doc/images/eclipse-console-terminated.png" alt="Close terminated console icon" /><p class="caption">Close terminated console icon</p>
</div>
<p><em>The Eclipse console implementation does not support command history (up arrow) or auto-completion (tab).</em></p>
<h3 id="external-libraries-view"><em>External Libraries</em> view</h3>
<p>This view is automatically populated with a list of all the external modules referenced by the current file. Double-clicking on any item provides a quick way of opening GF files which are imported into your grammar from outside your Eclipse project, for example the GF Resource Grammar Library.</p>
<p>This view also provides a text box for searching within the current module's scope, as shown in the image below. Clicking the small arrow on the right-hand side of the view provides options for case sensitive and/or regular-expression based search.</p>
<div class="figure">
<img src="https://raw.github.com/GrammaticalFramework/gf-eclipse-plugin/master/doc/images/eclipse-external-libraries.png" alt="External libraries view" /><p class="caption">External libraries view</p>
</div>
<h3 id="test-manager-view"><em>Test Manager</em> view</h3>
<p>This feature works together with the launch configurations to make the process of running regression tests on your grammars quick and easy. As described in the <a href="http://www.grammaticalframework.org/gf-book/">GF Book</a> (Section 10.5), the general development-test cycle (independent of GFEP) is as follows:</p>
<ol style="list-style-type: decimal">
<li>Create a file <code>test.trees</code> which contains a bunch of abstract syntax trees, which you want to test</li>
<li>Compile your grammar and linearise the trees one by one, using some command like <code>rf -lines -tree -file=test.trees | l -table | wf -file=test.trees.out</code></li>
<li>Manually correct the output in <code>test.trees.out</code> and save it as your gold standard file <code>test.trees.gold</code>.</li>
<li>Each time you update your grammar, repeat step 2, then compare your new output against the gold standard using <code>diff</code> or some other comparison tool.</li>
</ol>
<p>The <strong>Test Manager</strong> view follows this same pattern but provides a convenient graphical interface for running your test cases and also for looking at the output, just using a few clicks:</p>
<div class="figure">
<img src="https://raw.github.com/GrammaticalFramework/gf-eclipse-plugin/master/doc/images/eclipse-test-manager.png" alt="Test Manager view" /><p class="caption">Test Manager view</p>
</div>
<p>Note that GFEP assumes the following convention:</p>
<table>
<thead>
<tr class="header">
<th align="left">Extension</th>
<th align="left">Description</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td align="left"><code>*.trees</code> or <code>*.sentences</code></td>
<td align="left">Test input files: trees file (for testing linearisation) and sentences file (for testing parsing)</td>
</tr>
<tr class="even">
<td align="left"><code>*.trees.out</code> or <code>*.sentences.out</code></td>
<td align="left">Corresponding output files (generated each time a test is run)</td>
</tr>
<tr class="odd">
<td align="left"><code>*.trees.gold</code> or <code>*.sentences.gold</code></td>
<td align="left">Corresponding gold standard files (manually corrected from an output file)</td>
</tr>
</tbody>
</table>
<h3 id="logs">Logs</h3>
<p>The GFEP writes to the Eclipse platform log. This can be accessed in two ways:</p>
<ol style="list-style-type: decimal">
<li>By opening the <strong>Error Log</strong> view in Eclipse</li>
<li>Accessing the file directly at <code>&lt;workspace&gt;/.metadata/.log</code></li>
</ol>
<p>You can set the log verbosity from <strong>Preferences → Grammatical Framework</strong>.</p>
<!----------------------------------------------------------------------------->
<h2 id="common-issues-and-fixes">Common issues and fixes</h2>
<h3 id="no-identifiers-are-resolved-and-my-log-contains-messages-saying-file-syntax.gf-does-not-exist.">No identifiers are resolved and my log contains messages saying &quot;File Syntax.gf does not exist.&quot;</h3>
<p>In general, this means that something is wrong with your <em>library path</em> setting.</p>
<p>GFEP attempts to compile all of your files individually with GF, which is not the usual way in which you would compile your grammar. As a result, when looking for the RGL files, GF needs a little help via the <code>path</code> argument.</p>
<p>The normal way to do this is to specify the <em>Library path</em> setting from <strong>Preferences → Grammatical Framework</strong>, setting it to something like <code>.:alltenses:prelude</code> (this is the default setting). Note that these paths are relative to the true RGL directory, which GF should already be aware of. The value of this setting is passed to GF from GFEP using the <code>--path</code> flag.</p>
<p>The <em>Library path</em> setting is the same for all your GF projects. If you want finer-grain control over the <code>path</code> compiler option then you should use compiler pragmas in your source files, e.g.:</p>
<pre><code>--# -path=.:alltenses:prelude</code></pre>
<p>The advantage of this method is that the information is bound to the file, so you can freely compile your modules outside of GFEP without having to specify the path as a command line option to GF. The disadvantage is that you need to specify such a pragma in every single file (at least if you want to continue to use the GFEP).</p>
<h3 id="other-strange-behaviour">Other strange behaviour</h3>
<p>When things seem strange, the very first step is always to clean the project via <strong>Project → Clean...</strong>. I only support the latest version of the plugin, so make sure you are up to date too.</p>
<p>If problems persist, please contact me or better yet file an issue on the GitHub issue tracker (see below).</p>
<!----------------------------------------------------------------------------->
<h2 id="ontology-grammar-plugin">Ontology Grammar plugin</h2>
<p>For information about the Ontology Grammar plugin developed by Ontotext AD, please refer <a href="https://github.com/GrammaticalFramework/gf-eclipse-plugin/blob/master/README_ontology-grammar.md">here</a>.</p>
<!----------------------------------------------------------------------------->
<h2 id="for-developers">For developers</h2>
<h3 id="project-setup">Project setup</h3>
<p>In order to build/run the GFEP from source, you need to have the Xtext libraries available in your Eclipse workspace. You have two choices:</p>
<ol style="list-style-type: decimal">
<li>Download the Xtext libraries from <a href="http://www.eclipse.org/Xtext/download/">http://www.eclipse.org/Xtext/download/</a> and add them to your existing Eclipse instance</li>
<li>Download a release of Eclipse packaged together with Xtext from <a href="http://xtext.itemis.com/xtext/language=en/36553/downloads">http://xtext.itemis.com/xtext/language=en/36553/downloads</a></li>
</ol>
<p>In both cases make sure you get the correct version of Xtext (see below). Once you have Xtext set up, you can clone the repository locally with the following command:</p>
<pre><code>git clone git://github.com/GrammaticalFramework/gf-eclipse-plugin.git</code></pre>
<p>You can then add the projects under the <code>workspace</code> directory to your Eclipse workspace, by using the <strong>File → Import...</strong> wizard. The individual projects are:</p>
<table>
<thead>
<tr class="header">
<th align="left">Namespace</th>
<th align="left">Description</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td align="left"><code>org.grammaticalframework.eclipse.ui</code></td>
<td align="left">Covers all UI aspects of the plugin. Depends on <code>org.grammaticalframework.eclipse</code> (but the opposite is not true).</td>
</tr>
<tr class="even">
<td align="left"><code>org.grammaticalframework.eclipse.tests</code></td>
<td align="left">Contains unit tests for the plugin. Not required for running the plugin.</td>
</tr>
<tr class="odd">
<td align="left"><code>org.grammaticalframework.eclipse.ontology-grammar</code></td>
<td align="left">GF Ontology Grammar Plugin for Eclipse, developed separately by Ontotext AD.</td>
</tr>
<tr class="even">
<td align="left"><code>org.grammaticalframework.feature</code></td>
<td align="left">Feature project for the GF Eclipse Plugin. Exports <code>org.grammaticalframework.eclipse</code> and <code>org.grammaticalframework.eclipse.ui</code>.</td>
</tr>
<tr class="odd">
<td align="left"><code>org.grammaticalframework.feature.ontology-grammar</code></td>
<td align="left">Feature project for the GF Ontology Grammar Plugin. Exports <code>org.grammaticalframework.eclipse.ontology-grammar</code>.</td>
</tr>
<tr class="even">
<td align="left"><code>org.grammaticalframework.updatesite</code></td>
<td align="left">Update site project which exports both feature projects under the same category.</td>
</tr>
</tbody>
</table>
<h4 id="extra-dependencies-for-unit-testing-project">Extra dependencies for unit testing project</h4>
<p>The unit testing project (<code>org.grammaticalframework.eclipse.tests</code>) has an extra requirement for the library <code>org.eclipselabs.xtext.utils.unittesting</code>, which you will probably get complaints about when importing your projects into Eclipse. You only need to worry about this if you want to run the unit tests; otherwise you can ignore these errors. You can get more information about this library <a href="http://code.google.com/a/eclipselabs.org/p/xtext-utils/wiki/Unit_Testing">here</a>, or just install it in Eclipse directly using the following update site URL: <a href="http://xtext-utils.eclipselabs.org.codespot.com/git.distribution/releases/unittesting-0.9.x/">http://xtext-utils.eclipselabs.org.codespot.com/git.distribution/releases/unittesting-0.9.x/</a></p>
<h4 id="xtext-version">Xtext version</h4>
<p>GFEP currently uses <strong>Xtext 2.1.0</strong>.</p>
<h3 id="running-from-source">Running from source</h3>
<p>Once you have set up your projects (see above), you can run/debug the GFEP by following the steps <a href="http://www.eclipse.org/Xtext/documentation/2_1_0/020-domainmodel-step-by-step.php#DomainmodelWalkThrough_7">here</a>. Note that this means you will be running <em>two</em> instances of Eclipse simultaneously; the first debugging the second.</p>
<h3 id="building-plugin-package">Building plugin package</h3>
<p>To package the GFEP sources as <code>.jar</code> files and install/update the GFEP in a separate Eclipse installation, do the following:</p>
<ol style="list-style-type: decimal">
<li>Open <code>site.xml</code> in the <code>org.grammaticalframework.updatesite</code> project with Eclipse's Site Manifest Editor (default).</li>
<li><strong>Synchronize</strong> the feature versions with the update site project.</li>
<li>Click <strong>Build All</strong> and the necessary <code>.jar</code> files should be created/updated in the project's folder. These can then be copied, along with <code>site.xml</code> to any local or web directory, which becomes the &quot;update site&quot;.</li>
</ol>
<h4 id="artifacts.jar-and-contents.jar"><code>artifacts.jar</code> and <code>contents.jar</code></h4>
<p>These are two meta-data files created by the update site project. However there are known issues with categories sporadically not working in update sites, and it seems that if you delete these 2 files then the problems are solved. More about this can be found <a href="http://ekkescorner.wordpress.com/2010/04/18/who-eats-the-categories-from-update-sites/">here</a>.</p>
<h4 id="other-notes">Other notes</h4>
<p>Some have mentioned than when opening the GFEP sources, under Linux, they needed to install the following:</p>
<pre><code>sudo apt-get install appmenu-gtk
sudo apt-get install gtk2-engines-pixbuf</code></pre>
<!----------------------------------------------------------------------------->
<h2 id="evaluation-feedback">Evaluation &amp; feedback</h2>
<p>Please try to use the plugin for developing your own GF projects and report any issues you come up against. Feedback (both negative and positive) on the following would be appreciated:</p>
<ol style="list-style-type: decimal">
<li>Issues encountered with installation</li>
<li>Incorrect support of GF syntactic constructs, module hierarchy system</li>
<li>Performance issues (speed, resources footprint)</li>
<li>General intuitiveness of the UI</li>
<li>Feature wish-list</li>
<li>Compatibilities / conflicts with other Eclipse plugins</li>
</ol>
<p>For all bug reports and feature requests, please use the <a href="https://github.com/GrammaticalFramework/gf-eclipse-plugin/issues">GitHub Issue Tracker</a>.</p>
<!----------------------------------------------------------------------------->
<h2 id="appendix">Appendix</h2>
<h3 id="module-types">Module types</h3>
<p>Description of the GF module types and their icons within the GF Eclipse Plugin.</p>
<table>
<thead>
<tr class="header">
<th align="left">Icon</th>
<th align="left">Description</th>
<th align="left">Notes</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td align="left"><img src="https://raw.github.com/GrammaticalFramework/gf-eclipse-plugin/master/doc/images/module-abstract.png" /></td>
<td align="left">Abstract module</td>
<td align="left"><code>abstract Foods = {...}</code></td>
</tr>
<tr class="even">
<td align="left"><img src="https://raw.github.com/GrammaticalFramework/gf-eclipse-plugin/master/doc/images/module-concrete.png" /></td>
<td align="left">Concrete module</td>
<td align="left"><code>concrete FoodsEng of Foods = {...}</code></td>
</tr>
<tr class="odd">
<td align="left"><img src="https://raw.github.com/GrammaticalFramework/gf-eclipse-plugin/master/doc/images/module-resource.png" /></td>
<td align="left">Resource module</td>
<td align="left"><code>resource ResFoods = {...}</code></td>
</tr>
<tr class="even">
<td align="left"><img src="https://raw.github.com/GrammaticalFramework/gf-eclipse-plugin/master/doc/images/module-interface.png" /></td>
<td align="left">Interface</td>
<td align="left"><code>interface LexFoods = {...}</code></td>
</tr>
<tr class="odd">
<td align="left"><img src="https://raw.github.com/GrammaticalFramework/gf-eclipse-plugin/master/doc/images/module-instance.png" /></td>
<td align="left">Instance</td>
<td align="left"><code>instance LexFoodsEng of LexFoods = {...}</code></td>
</tr>
<tr class="even">
<td align="left"><img src="https://raw.github.com/GrammaticalFramework/gf-eclipse-plugin/master/doc/images/module-functor.png" /></td>
<td align="left">Functor</td>
<td align="left"><code>incomplete concrete FoodsI of Foods = {...}</code></td>
</tr>
<tr class="odd">
<td align="left"><img src="https://raw.github.com/GrammaticalFramework/gf-eclipse-plugin/master/doc/images/module-functor-instantiation.png" /></td>
<td align="left">Functor instantiation</td>
<td align="left"><code>concrete FoodsEng of Foods = FoodsI with (...) {...}</code></td>
</tr>
</tbody>
</table>
<h3 id="build-command">Build command</h3>
<p>This is the GF command run by the builder:</p>
<pre><code>gf --v=0 --tags --output-dir=.gfbuild [--path=PATH] FILE</code></pre>
</body>
</html>

View File

@@ -1,3 +1,5 @@
# `/examples`
All contributions (`contrib` and `examples` folders) have now been
moved to a separate git repository at:
@@ -10,5 +12,5 @@ have some toy grammars to play with.
Any updates to these grammars should be made at the gf-contrib repository
above; changes will be copied from there to here manually.
John J. Camilleri
John J. Camilleri,
2013-09-16

View File

@@ -3,7 +3,7 @@
concrete WordsDut of Words = SentencesDut **
open SyntaxDut, (P = ParadigmsDut), (I = IrregDut), (L = LexiconDut), (R=ResDut), ExtraDut, Prelude in {
open SyntaxDut, (P = ParadigmsDut), (I = IrregDut), (L = LexiconDut), (R=ResDut), (E=ExtendDut), Prelude in {
lin
@@ -173,7 +173,7 @@ ik ga te voet/ ik ga lopend
-- miscellaneous
QWhatName p = mkQS (mkQCl how_IAdv (mkCl p.name I.heten_V)) ; --hoe heet je
QWhatAge p = mkQS (mkQCl (ICompAP (mkAP L.old_A)) p.name) ;
QWhatAge p = mkQS (mkQCl (E.ICompAP (mkAP L.old_A)) p.name) ;
HowMuchCost item = mkQS (mkQCl how8much_IAdv (mkCl item (P.mkV "kosten"))) ; --hoeveel kost...
ItCost item price = prop (mkCl item (P.mkV2 (P.mkV "kosten")) price) ; --..item.. kost ..price..

View File

@@ -1,5 +0,0 @@
<!DOCTYPE html>
<html>
<head><meta http-equiv="refresh" content="0; url=http://remu.grammaticalframework.org/framenet/"/></head>
<body>Redirecting...</body>
</html>

View File

@@ -1,177 +0,0 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<META NAME="generator" CONTENT="http://txt2tags.org">
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf8">
<LINK REL="stylesheet" TYPE="text/css" HREF="../css/style.css">
<meta name = "viewport" content = "width = device-width"><TITLE>Grammatical Framework: Programming with Multilingual Grammars</TITLE>
</HEAD><BODY BGCOLOR="white" TEXT="black">
<CENTER>
<H1>Grammatical Framework: Programming with Multilingual Grammars</H1>
<FONT SIZE="4"><I>Aarne Ranta</I></FONT><BR>
</CENTER>
<P>
<center><img style="width: 200px" src="gf-book-cover.png"></center>
</P>
<P>
This is the web page of the book
</P>
<UL>
<LI>Aarne Ranta,
<I>Grammatical Framework: Programming with Multilingual Grammars</I>,
CSLI Publications,
Stanford,
2011,
340 pp,
ISBN-10: 1-57586-626-9 (Paper), 1-57586-627-7 (Cloth).
</UL>
<H2>Publisher's information</H2>
<P>
Publisher's web page (look for "Series" -&gt; "CSLI Studies in Computational Linguistics")
</P>
<P>
<A HREF="http://www-csli.stanford.edu/pubs/">http://www-csli.stanford.edu/pubs/</A>
</P>
<H2>Order</H2>
<P>
Direct order ($32.50 paperback, $70 hardcover):
</P>
<P>
<A HREF="http://press.uchicago.edu/ucp/books/book/distributed/G/bo12469871.html">http://press.uchicago.edu/ucp/books/book/distributed/G/bo12469871.html</A>
</P>
<P>
Amazon order USA ($32.50 paperback, $70 hardcover):
</P>
<P>
<A HREF="http://www.amazon.com/Grammatical-Framework-Programming-Multilingual-Information/dp/1575866269/ref=sr_1_2?ie=UTF8&amp;qid=1308585697&amp;sr=8-2">http://www.amazon.com/Grammatical-Framework-Programming-Multilingual-Information/dp/1575866269/ref=sr_1_2?ie=UTF8&amp;qid=1308585697&amp;sr=8-2</A>
</P>
<P>
Amazon order UK (£21 paperback, £45 hardcover):
</P>
<P>
<A HREF="http://www.amazon.co.uk/Grammatical-Framework-Programming-Multilingual-Computational/dp/1575866269/ref=sr_1_6?ie=UTF8&amp;qid=1315580083&amp;sr=8-6">http://www.amazon.co.uk/Grammatical-Framework-Programming-Multilingual-Computational/dp/1575866269/ref=sr_1_6?ie=UTF8&amp;qid=1315580083&amp;sr=8-6</A>
</P>
<H2>Book description</H2>
<P>
Grammars of natural languages are complex systems, and their
computer implementation requires both programming skills and
linguistic knowledge, especially when dealing with other languages
than English. This book makes such tasks accessible for a wide
range of programmers. It introduces GF (Grammatical Framework),
which is a programming language designed for writing grammars, which
may moreover address several languages in parallel.
The book shows how to write grammars in GF and use them in applications
such as tourist phrasebooks, spoken dialogue systems, and natural
language interfaces. The examples and exercises address several
languages, and the readers are guided to look at their own languages
from the computational perspective.
</P>
<P>
With an emphasis on good engineering, the book promotes modularity
and division of labour - in particular, the use of libraries. It
introduces the GF Resource Grammar Library, which currently addresses
16 languages. This number is constantly growing due to contributions
from the international GF community. The library makes it painless to
build applications and to port them to new languages. The book
introduces a wide range of such applications, which run on platforms
ranging from web servers to mobile phones. But the book also gives
guidance for those readers who want to understand the underlying
linguistics and implement resource grammars for new languages.
</P>
<P>
The book starts with a hands-on tutorial, continues with a selection
of advanced topics, and ends with a complete reference manual
of GF. Requiring very little background knowledge, it is accessible
for second-year students that have experience with computers and an
interest for languages. At the same time, its novel and advanced
material makes it interesting for senior researchers in computer science,
linguistics, and related fields.
</P>
<H2>How to cite</H2>
<PRE>
@Book{ranta-2011,
author = {Aarne Ranta},
title = {{Grammatical Framework:
Programming with Multilingual Grammars}},
publisher = {{CSLI Publications}},
year = {2011},
address = "Stanford",
note = "ISBN-10: 1-57586-626-9 (Paper), 1-57586-627-7 (Cloth)"
}
</PRE>
<H2>Table of Contents</H2>
<P>
<A HREF="toc-gf-book.txt">Detailed Table of Contents</A>
</P>
<H2>Supporting material</H2>
<P>
<A HREF="./gf-book-slides.pdf">Slides</A> for teaching the book chapter by chapter.
</P>
<P>
<A HREF="./examples">Code examples</A>. You can also download the
complete example set as a compressed tar file,
<A HREF="gf-book-examples.tgz">gf-book-examples.tgz</A>.
</P>
<P>
<A HREF="http://www.grammaticalframework.org/demos/gfse/">GF Web IDE</A>:
build grammars in the cloud, without installing GF.
</P>
<P>
Demos
</P>
<UL>
<LI><A HREF="http://www.grammaticalframework.org:41296/minibar/minibar.html">on-line translator</A> (Section 7.12)
<LI><A HREF="http://www.grammaticalframework.org/demos/resource-api/editor.html">syntax editor</A> (Section 7.13)
<LI><A HREF="http://www.youtube.com/watch?v=1bfaYHWS6zU">multimodal dialogue system</A> (Section 7.15)
</UL>
<P>
Other tutorials:
</P>
<UL>
<LI><A HREF="../doc/tutorial/gf-tutorial.html">GF Tutorial</A>: programmer-oriented,
covering parts of chapters 2-8
<LI><A HREF="../doc/gf-lrec-2010.pdf">GF Resource Tutorial</A>: linguist-oriented,
covering parts of chapters 2-5, 9-10
</UL>
<P>
<A HREF="http://www.grammaticalframework.org/doc/gf-bibliography.html">Works mentioned in references</A>;
more download links will be added.
</P>
<P>
<A HREF="http://www.grammaticalframework.org/lib/doc/synopsis.html">Resource Grammar Library API</A>
</P>
<P>
<A HREF="http://www.grammaticalframework.org/download">Sources and binaries</A>
for GF 3.2, which exactly matches the book.
</P>
<P>
GF Home Page: <A HREF="http://www.grammaticalframework.org/">http://www.grammaticalframework.org/</A>
</P>
<P>
Author's email: aarne'at'chalmers'dot'se
</P>
<P>
Author's home page: <A HREF="http://www.cse.chalmers.se/~aarne/">http://www.cse.chalmers.se/~aarne/</A>
</P>
<!-- html code generated by txt2tags 2.6 (http://txt2tags.org) -->
<!-- cmdline: txt2tags -thtml index.txt -->
</BODY></HTML>

View File

@@ -14,33 +14,30 @@ maintainer: Thomas Hallgren
tested-with: GHC==7.6.3, GHC==7.8.3, GHC==7.10.3, GHC==8.0.2
data-dir: src
data-files: tools/gf.el
tools/gf.lang
tools/dark-filetypes.GF.conf
tools/light-filetypes.GF.conf
www/*.html
www/*.css
www/P/*.png
www/gfse/*.html
www/gfse/*.css
www/gfse/*.js
www/gfse/P/*.png
www/gfse/P/*.jpg
www/js/*.js
www/minibar/*.html
www/minibar/*.css
www/minibar/*.js
www/minibar/*.png
www/syntax-editor/*.html
www/syntax-editor/*.css
www/syntax-editor/*.js
www/TransQuiz/*.html
www/TransQuiz/*.css
www/TransQuiz/*.js
www/TransQuiz/*.png
www/translator/*.html
www/translator/*.css
www/translator/*.js
data-files:
www/*.html
www/*.css
www/P/*.png
www/gfse/*.html
www/gfse/*.css
www/gfse/*.js
www/gfse/P/*.png
www/gfse/P/*.jpg
www/js/*.js
www/minibar/*.html
www/minibar/*.css
www/minibar/*.js
www/minibar/*.png
www/syntax-editor/*.html
www/syntax-editor/*.css
www/syntax-editor/*.js
www/TransQuiz/*.html
www/TransQuiz/*.css
www/TransQuiz/*.js
www/TransQuiz/*.png
www/translator/*.html
www/translator/*.css
www/translator/*.js
--source-repository head
-- type: darcs
@@ -104,9 +101,9 @@ Library
--if impl(ghc>=7.8)
-- ghc-options: +RTS -A20M -RTS
ghc-prof-options: -fprof-auto
extensions:
extensions:
exposed-modules:
exposed-modules:
PGF
PGF.Internal
PGF.Haskell

View File

@@ -4,9 +4,7 @@
<TITLE>GF - Grammatical Framework</TITLE>
<meta charset="UTF-8">
<link rel="stylesheet" href="css/newstyle.css" title="GF">
<link rel="alterante stylesheet" href="css/oldstyle.css" title="Old">
<link rel="alternate" href="https://github.com/GrammaticalFramework/GF/" title="GF GitHub Mirror">
<link rel="alternate" href="http://grammatical-framework.blogspot.com/" title="GF Blog">
<link rel="alternate" href="https://github.com/GrammaticalFramework/GF/" title="GF GitHub repository">
<meta name = "viewport" content = "width = device-width">
<script type="text/javascript">
function sitesearch() {
@@ -26,7 +24,6 @@ function sitesearch() {
<img class="gflogo" src="doc/Logos/gf1.svg" alt="">
<H1>Grammatical Framework</H1>
<small class=tagline>A programming language for multilingual grammar applications</small>
<!--<p>Version 3.7.1<br>Oct 2015-->
</div>
<div class=menu>
@@ -35,12 +32,10 @@ function sitesearch() {
<h4>Use GF</h4>
<ul>
<li><a href="http://cloud.grammaticalframework.org/">GF Cloud<img class=right src="src/www/P/gf-cloud.png" alt="GF Cloud Service" title="GF Cloud Service"></a>
<li><a href="https://play.google.com/store/apps/details?id=org.grammaticalframework.ui.android">Android app</a>
<li><A HREF="demos/index.html">Other Demos</A>
</ul>
<ul>
<li><A HREF="http://www.grammaticalframework.org/download/index.html"><b>Download GF</b></A>
<li><a href="eclipse/index.html">GF Eclipse Plugin</a>
<li><a href="doc/gf-editor-modes.html">GF Editor Modes</a>
</ul>
@@ -48,7 +43,6 @@ function sitesearch() {
<li><A HREF="http://groups.google.com/group/gf-dev">User Group</A>
<li><a href="https://github.com/GrammaticalFramework/GF/issues">Bug Reports</a>
(<a href="http://code.google.com/p/grammatical-framework/issues/list">old</a>)
<li><a href="http://grammatical-framework.blogspot.com/">Blog</a>
</ul>
</div>
@@ -98,7 +92,6 @@ function sitesearch() {
<h4>Related to GF</h4>
<ul>
<li><A HREF="doc/gf-bibliography.html">Publications</A>
<li><A HREF="http://school.grammaticalframework.org">GF Summer Schools</A>
<li><A HREF="http://remu.grammaticalframework.org/">The REMU Project</A>
<li><A HREF="http://www.molto-project.eu">The MOLTO Project</A>
<li><a href="http://en.wikipedia.org/wiki/Grammatical_Framework">GF on Wikipedia</a>

View File

@@ -1,359 +0,0 @@
<!DOCTYPE html>
<HTML>
<HEAD>
<TITLE>GF - Grammatical Framework</TITLE>
<meta charset="UTF-8">
<link rel="stylesheet" href="css/style.css" title="GF">
<link rel="alterante stylesheet" href="css/oldstyle.css" title="Old">
<meta name = "viewport" content = "width = device-width">
<script type="text/javascript">
function sitesearch() {
var q=document.forms[0].q.value;
var site=" site:www.grammaticalframework.org";
var search=encodeURIComponent(q+site)
document.location.href="http://www.google.com/search?q="+search
return false;
}
</script>
<meta name="keywords" content="machine translation">
</HEAD>
<BODY>
<script type="text/javascript">
document.write('<div style="text-align: right"> <form onsubmit="return sitesearch()" method=get action="http://www.google.com/search"> <input type=search name="q" placeholder="site search"> <input type=submit value="Search"> </form></div>')
</script>
<div class=center>
<img id=gflogo class=grow src="doc/Logos/gf0.png" alt="">
<script>
if(document.implementation.hasFeature("http://www.w3.org/TR/SVG11/feature#BasicStructure", "1.1"))
document.getElementById("gflogo").src="doc/Logos/gf1.svg"
</script>
<H1>Grammatical Framework</H1>
<P>
Version 3.5
<br>
August 2013
<P>
<div class=mainlinks>
[ <A HREF="demos/index.html">Demos</A>
| <A HREF="http://www.grammaticalframework.org/download/index.html">Download</A>
| <A HREF="lib/doc/synopsis.html">Libraries</A>
| <A HREF="doc/gf-refman.html">Reference</A>
| <A HREF="doc/tutorial/gf-tutorial.html">Tutorial</A>
| <A HREF="doc/gf-quickstart.html">QuickStart</A>
| <A HREF="http://groups.google.com/group/gf-dev">UserGroup</A>
| <A HREF="gf-book">Book</A>
| <A HREF="https://github.com/GrammaticalFramework/GF/">GitHub</A>
| <A HREF="http://www.postcrashgames.com/gf_world/">Interactive Map</A>
| <a href="http://cloud.grammaticalframework.org/"><img src="src/www/P/gf-cloud.png" alt="GF Cloud Service" title="GF Cloud Service"></a>
]
</div>
<div class=extralinks>
<p>
[ <a href="http://code.google.com/p/grammatical-framework/issues/list">Issues</a>
| <A HREF="http://code.google.com/p/grammatical-framework/wiki/SideBar?tm=6">Wiki</A>
| <A HREF="doc/gf-people.html">People</A>
| <A HREF="doc/gf-bibliography.html">Publications</A>
| <A HREF="doc/gf-reference.html">QuickRefCard</A>
| <A HREF="doc/gf-shell-reference.html">GF Shell Reference</A>
| <a href="doc/gf-editor-modes.html">GF Editor Modes</a>
| <a href="eclipse/index.html">GF Eclipse Plugin</a>
| <A HREF="doc/gf-lrec-2010.pdf">LibTutorial</A>
| <a href="http://hackage.haskell.org/package/gf-3.5/docs/PGF.html">PGF library API</a>
| <A HREF="http://www.molto-project.eu">MOLTO</A>
| <A HREF="http://school.grammaticalframework.org">SummerSchool</A>
| <A HREF="/android/">Android</A>
| <a href="/~hallgren/gf-experiment/browse/">Browse GF Source Code</a>
| <a href="http://ci.zjyto.net/job/gf-build/"><img src="http://ci.zjyto.net/buildStatus/icon?job=gf-build" alt="GF build status"></a><small style="color: red"><em>New!</em></small>
]
</div>
</div>
<H2>News</H2>
<div class=news2>
<table class=news>
<tr><td>2014-03-11:
<td>A company for commercial applications of GF has been founded:
<a href="http://www.digitalgrammars.com/">Digital Grammars</a>.
<tr><td>2013-11-25:
<td>The default character encoding in GF grammar files will be changed
from Latin-1 to UTF-8. See
<a href="download/encoding-change.html">GF character encoding changes</a>
for details.
<tr><td>2013-10-18:<td>New resource grammar language: Estonian.
See <a href="lib/doc/synopsis.html">library synopsis</a>.
<tr><td>2013-09-18:<td>New <a href="https://github.com/GrammaticalFramework/gf-contrib">GF contributions repository</a>, hosted on GitHub.
<tr><td>2013-08-06:<td><strong>GF 3.5 released!</strong>
<a href="download/release-3.5.html">Release notes</a>.
<tr><td>2013-07-26:<td>Started a page with <A HREF="lib/doc/rgl-publications.html">RGL Documentation and Publications</A>.
<tr><td>2013-06-24:<td>We are now running the IRC channel <strong><code>#gf</code></strong> on the Freenode network.
<tr><td>2013-06-19:<td>New resource grammar language: Maltese.
See <a href="lib/doc/synopsis.html">library synopsis</a>.
<tr><td>2013-04-25:<td>New resource grammar language: Greek.
See <a href="lib/doc/synopsis.html">library synopsis</a>.
<tr><td>2013-01-31:<td><strong>GF 3.4 released!</strong>
<a href="download/release-3.4.html">Release notes</a>.
<tr><td>2012-12-10:<td>
<a href="http://www.postcrashgames.com/gf_world/">Resource Grammar Library
coverage map</a>, created by Tommi Nieminen.
<!--
<tr><td>2012-11-18:<td>
<A HREF="http://school.grammaticalframework.org/2013">GF Summer School</A>
in Frauenchiemsee, 18-30 August 2013.
<tr><td>2012-11-18:<td>New resource grammar language: Chinese.
See <a href="lib/doc/synopsis.html">library synopsis</a>.
Complete but not yet perfect.
<tr><td>2012-06-29:<td>GF sources now mirrored in GitHub, with change
statistics and other browsing features.
See <a href="https://github.com/GrammaticalFramework/GF/"><tt>github.com/GrammaticalFramework/GF</tt></a>
<tr><td>2012-05-07:<td>New resource grammar language: Japanese.
See <a href="lib/doc/synopsis.html">library synopsis</a>.
<tr><td>2012-03-23:<td>There will be a
<a href="gf-tutorial-icfp-2012/">GF tutorial at ICFP 2012</a>
in Copenhagen.
<tr><td>2012-03-03:<td><strong>GF 3.3.3 released!</strong>
<a href="download/release-3.3.3.html">Release notes</a>.
<tr><td>2012-02-24:<td>New resource grammar languages: Hindi, Sindhi.
See <a href="lib/doc/synopsis.html">library synopsis</a>.
<tr><td>2011-12-29:<td>New resource grammar languages: Latvian, Thai.
See <a href="lib/doc/synopsis.html">library synopsis</a>.
<tr><td>2011-10-27:<td><strong>GF 3.3 released!</strong>
<a href="download/release-3.3.html">Release notes</a>.
<tr><td>2011-09-20:<td>There is now a page collecting
<a href="doc/gf-editor-modes.html">editor modes for GF</a>.
Contributions are welcome!
<tr><td>2011-09-12:<td><strong>GF 3.2.9</strong> source snapshot with faster grammar compilation available. See <a href="download/index.html">Downloads</a>.
<tr><td>2011-04-22:<td><a href="android/tutorial/">JPGF Android Tutorial</a> added.
<tr><td>2011-04-15:<td>The <a href="gf-book">GF Book</a> is available.
<tr><td>2011-01-13:<td><a href="http://www.molto-project.eu/node/1177">Phrasedroid
available on the Android Market</a>.
<tr><td>2011-01-04:<td>GF is part of the
<a href="http://www.clt.gu.se/clt-toolkit">CLT Toolkit</a>.
<tr><td>2010-12-23:<td><strong>GF 3.2 released!</strong>
<a href="download/release-3.2.html">Release notes</a>.
-->
</table>
</div>
<H2>What is GF</H2>
<P>
GF, Grammatical Framework, is a programming language for
<B>multilingual grammar applications</B>. It is
</P>
<UL>
<LI>a <B>special-purpose language for grammars</B>, like
<a href="http://dinosaur.compilertools.net/yacc/">YACC</a>,
<a href="http://www.gnu.org/software/bison/">Bison</a>,
<a href="http://www.haskell.org/happy/">Happy</a>,
<a href="http://bnfc.digitalgrammars.com/">BNFC</a>,
but not restricted to programming languages
<LI>a <B>functional programming language</B>, like
<a href="http://www.haskell.org/">Haskell</a>,
<a href="http://en.wikipedia.org/wiki/Lisp_(programming_language)">Lisp</a>,
<a href="http://ocaml.org/">OCaml</a>,
<a href="http://www.smlnj.org/">SML</a>,
<a href="http://schemers.org/">Scheme</a>,
but specialized to grammar writing
<LI>a <B>development platform for natural language grammars</B>, like
<a href="http://moin.delph-in.net/LkbTop">LKB</a>,
<a href="http://www2.parc.com/isl/groups/nltt/xle/">XLE</a>,
<a href="http://www.issco.unige.ch/en/research/projects/regulus/news.shtml">Regulus</a>,
but based on functional programming and type theory
<LI>a <B>categorial grammar formalism</B>, like
<a href="http://www.loria.fr/equipes/calligramme/acg/">ACG</a>,
<a href="http://openccg.sourceforge.net/">CCG</a>,
but specialized for multilingual grammars,
<LI>a <B>logical framework</B>, like
<a href="http://wiki.portal.chalmers.se/agda/pmwiki.php">Agda</a>,
<a href="http://coq.inria.fr/">Coq</a>,
<a href="http://www.cl.cam.ac.uk/research/hvg/Isabelle/">Isabelle</a>,
but equipped with concrete syntax in addition to logic
<li>a <b>platform for machine translation</b>, like
<a href="http://www.statmt.org/moses/">Moses</a>,
<a href="http://www.apertium.org/">Apertium</a>,
but based on deep structural analysis (and usually applied for
limited fragments of language).
</UL>
<P>
Don't worry if you don't know most of the references above - but if you do know at
least one, it may help you to get a first idea of what GF is.
</P>
<H2>Applications</H2>
<P>
GF can be used for building
</P>
<UL>
<LI><A HREF="http://cloud.grammaticalframework.org/translator/">translation systems</A>
<LI><A HREF="http://cloud.grammaticalframework.org/minibar/minibar.html">multilingual web gadgets</A>
<LI><A HREF="http://www.cs.chalmers.se/~hallgren/Alfa/Tutorial/GFplugin.html">natural-language interfaces</A>
<LI><A HREF="http://www.youtube.com/watch?v=1bfaYHWS6zU">dialogue systems</A>
<LI><A HREF="lib/doc/synopsis.html">natural language resources</A>
</UL>
<H2>Availability</H2>
<P>
GF is <B>open-source</B>, licensed under <A HREF="LICENSE">GPL</A> (the program) and
<A HREF="./LICENSE">LGPL</A> and <A HREF="./LICENSE">BSD</A> (the libraries). It
is available for
</P>
<UL>
<LI>Linux
<LI>Mac OS X
<LI>Windows
<li>Android mobile platform (via Java; runtime)
<LI>via compilation to JavaScript, almost any platform that has a web browser (runtime)
</UL>
<H2>Projects</H2>
<P>
GF was first created in 1998 at
<A HREF="http://www.xrce.xerox.com/">Xerox Research Centre Europe</A>,
Grenoble, in the project
Multilingual Document Authoring. At Xerox, it was used for prototypes including
a restaurant phrase book,
a database query system,
a formalization of an alarm system instructions with translations to 5 languages, and
an authoring system for medical drug descriptions.
</P>
<P>
Later projects using GF and involving third parties include, in chronological order,
</P>
<UL>
<LI><A HREF="http://www.cs.chalmers.se/~hallgren/Alfa/Tutorial/GFplugin.html">GF-Alfa</A>:
natural language interface to formal proofs
<LI><A HREF="http://efficient.citi.tudor.lu/index_noframe.html">Efficient</A>:
authoring tool for business models.
<LI><A HREF="http://www.key-project.org/">GF-KeY</A>:
authoring and translation of software specifications
<LI><A HREF="http://www.talk-project.org">TALK</A>:
multilingual and multimodal spoken dialogue systems
<LI><A HREF="http://webalt.math.helsinki.fi/">WebALT</A>:
multilingual generation of mathematical exercises (commercial project)
<LI><A HREF="http://spraakbanken.gu.se/sal/">SALDO</A>:
Swedish morphological dictionary based on rules developed for GF and
<A HREF="http://www.cse.chalmers.se/alumni/markus/FM/">Functional Morphology</A>
<LI><a href="http://www.molto-project.eu">MOLTO</a>:
multilingual online translation
<LI><a href="http://remu.grammaticalframework.org">REMU</a>:
reliable multilingual digital communication.
</UL>
<p>
Here is a <a
href="http://videos.xrce.xerox.com/index.php/videos/index/618">talk
about GF at XRCE</a>,
14 years later.
<P>
Academically, GF has been used in at least ten PhD theses and resulted
in more than a hundred
scientific publications (see <A HREF="doc/gf-bibliography.html">GF publication list</A>).
</P>
<H2>Programming in GF</H2>
<P>
GF is easy to learn by following the <A HREF="doc/tutorial/gf-tutorial.html">tutorial</A>.
You can write your first translator in 15 minutes.
</P>
<P>
GF has an interactive command interpreter, as well as a batch compiler.
Grammars can be compiled to parser and translator code in many different
formats. These components can then be embedded in applications written
in other programming languages. The formats currently supported are:
</P>
<UL>
<LI>Haskell
<li>Java, in particular the Android platform
<LI>JavaScript
<LI>Speech recognition: HTK/ATK, Nuance, JSGF
</UL>
<P>
The GF programming language is high-level and advanced, featuring
</P>
<UL>
<LI>static type checking
<LI>higher-order functions
<LI>dependent types
<LI>pattern matching with data constructors and regular expressions
<LI>module system with multiple inheritance and parametrized modules
</UL>
<h3>Getting help</h3>
<p>
If you need some help with GF, the first places to start are the <a href="doc/tutorial/gf-tutorial.html">Tutorial</a> and <a href="doc/gf-refman.html">Reference</a> pages.
The printed <a href="gf-book">book</a> contains all the material in the tutorial and some extra bits, and is the recommended reference for GF.
</p>
<p>
We run the IRC channel <strong><code>#gf</code></strong> on the Freenode network, where you are welcome to look for help with small questions or just start a general discussion.
IRC logs (in raw format) are available <a href="irc/">here</a>.
If you have a larger question which the community may benefit from, we recommend you ask it on the <a href="http://groups.google.com/group/gf-dev">mailing list</a>.
</p>
<H2>Libraries</H2>
<P>
Libraries are at the heart of modern software engineering. In natural language
applications, libraries are a way to cope with thousands of details involved in
syntax, lexicon, and inflection. The
<A HREF="lib/doc/synopsis.html">GF resource grammar library</A> has
support for an increasing number of languages, currently including
</P>
<ol class=languages>
<LI>Afrikaans
<LI>Amharic (partial)
<LI>Arabic (partial)
<LI>Bulgarian
<LI>Catalan
<LI>Chinese
<LI>Danish
<LI>Dutch
<LI>English
<LI>Estonian
<LI>Finnish
<LI>French
<LI>German
<li>Greek
<li>Hebrew (fragments)
<LI>Hindi
<LI><A HREF="http://www.interlingua.com/">Interlingua</A>
<LI>Japanese
<LI>Italian
<LI>Latin (fragments)
<LI>Latvian
<li>Maltese
<LI>Nepali
<LI>Norwegian bokmål
<LI>Persian
<LI>Polish
<li>Punjabi
<LI>Romanian
<LI>Russian
<LI>Sindhi
<LI>Spanish
<li>Swahili (fragments)
<LI>Swedish
<LI>Thai
<LI>Turkish (fragments)
<LI>Urdu
</ol>
<P>
Adding a language to the resource library takes 3 to 9
months - contributions
are welcome! You can start with the <A HREF="doc/gf-lrec-2010.pdf">resource grammarian's tutorial</A>.
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
try {
var pageTracker = _gat._getTracker("UA-7811807-3");
pageTracker._trackPageview();
} catch(err) {}</script>
</BODY>
</HTML>

View File

@@ -39,6 +39,7 @@ allTransliterations = Map.fromList [
("amharic",transAmharic),
("ancientgreek", transAncientGreek),
("arabic", transArabic),
("arabic_unvocalized", transArabicUnvoc),
("devanagari", transDevanagari),
("greek", transGreek),
("hebrew", transHebrew),
@@ -178,6 +179,13 @@ transArabic = mkTransliteration "Arabic" allTrans allCodes where
allCodes = [0x0621..0x062f] ++ [0x0630..0x063a] ++
[0x0641..0x064f] ++ [0x0650..0x0657] ++ [0x0671,0x061f]
transArabicUnvoc :: Transliteration
transArabicUnvoc = transArabic{
invisible_chars = ["a","u","i","v2","o","V+","V-","a:"],
printname = "unvocalized Arabic"
}
transPersian :: Transliteration
transPersian = (mkTransliteration "Persian/Farsi" allTrans allCodes)
{invisible_chars = ["a","u","i"]} where

337
src/runtime/typescript/gflib.d.ts vendored Normal file
View File

@@ -0,0 +1,337 @@
/**
* gflib.dt.s
*
* by John J. Camilleri
*
* TypeScript type definitions for the "original" JS GF runtime (GF:src/runtime/javascript/gflib.js)
*/
// Note: the String prototype is extended with:
// String.prototype.tag = "";
// String.prototype.setTag = function (tag) { this.tag = tag; };
/**
* A GF grammar is one abstract and multiple concretes
*/
declare class GFGrammar {
abstract: GFAbstract
concretes: {[key: string]: GFConcrete}
constructor(abstract: GFAbstract, concretes: {[key: string]: GFConcrete})
translate(
input: string,
fromLang: string,
toLang: string
): {[key: string]: {[key: string]: string}}
}
/**
* Abstract Syntax Tree
*/
declare class Fun {
name: string
args: Fun[]
constructor(name: string, ...args: Fun[])
print(): string
show(): string
getArg(i: number): Fun
setArg(i: number, c: Fun): void
isMeta(): boolean
isComplete(): boolean
isLiteral(): boolean
isString(): boolean
isInt(): boolean
isFloat(): boolean
isEqual(obj: any): boolean
}
/**
* Abstract syntax
*/
declare class GFAbstract {
startcat: string
types: {[key: string]: Type} // key is function name
constructor(startcat: string, types: {[key: string]: Type})
addType(fun: string, args: string[], cat: string): void
getArgs(fun: string): string[]
getCat(fun: string): string
annotate(tree: Fun, type: string): Fun
handleLiterals(tree: Fun, type: Type): Fun
copyTree(x: Fun): Fun
parseTree(str: string, type: string): Fun
parseTree_(tokens: string[], prec: number): Fun
}
/**
* Type
*/
declare class Type {
args: string[]
cat: string
constructor(args: string[], cat: string)
}
type ApplyOrCoerce = Apply | Coerce
/**
* Concrete syntax
*/
declare class GFConcrete {
flags: {[key: string]: string}
productions: {[key: number]: ApplyOrCoerce[]}
functions: CncFun[]
sequences: Array<Array<Sym>>
startCats: {[key: string]: {s: number, e: number}}
totalFIds: number
pproductions: {[key: number]: ApplyOrCoerce[]}
lproductions: {[key: string]: {fid: FId, fun: CncFun}}
constructor(
flags: {[key: string]: string},
productions: {[key: number]: ApplyOrCoerce[]},
functions: CncFun[],
sequences: Array<Array<Sym>>,
startCats: {[key: string]: {s: number, e: number}},
totalFIds: number
)
linearizeSyms(tree: Fun, tag: string): Array<{fid: FId, table: any}>
syms2toks(syms: Sym[]): string[]
linearizeAll(tree: Fun): string[]
linearize(tree: Fun): string
tagAndLinearize(tree: Fun): string[]
unlex(ts: string): string
tagIt(obj: any, tag: string): any
// showRules(): string // Uncaught TypeError: Cannot read property 'length' of undefined at gflib.js:451
tokenize(string: string): string[]
parseString(string: string, cat: string): Fun[]
complete(
input: string,
cat: string
): {consumed: string[], suggestions: string[]}
}
/**
* Function ID
*/
type FId = number
/**
* Apply
*/
declare class Apply {
id: string
fun: FId
args: PArg[]
constructor(fun: FId, args: PArg[])
show(cat: string): string
isEqual(obj: any): boolean
}
/**
* PArg
*/
declare class PArg {
fid: FId
hypos: any[]
constructor(fid: FId, ...hypos: any[])
}
/**
* Coerce
*/
declare class Coerce {
id: string
arg: FId
constructor(arg: FId)
show(cat: string): string
}
/**
* Const
*/
declare class Const {
id: string
lit: Fun
toks: any[]
constructor(lit: Fun, toks: any[])
show(cat: string): string
isEqual(obj: any): boolean
}
/**
* CncFun
*/
declare class CncFun {
name: string
lins: FId[]
constructor(name: string, lins: FId[])
}
type Sym = SymCat | SymKS | SymKP | SymLit
/**
* SymCat
*/
declare class SymCat {
id: string
i: number
label: number
constructor(i: number, label: number)
getId(): string
getArgNum(): number
show(): string
}
/**
* SymKS
*/
declare class SymKS {
id: string
tokens: string[]
constructor(...tokens: string[])
getId(): string
show(): string
}
/**
* SymKP
*/
declare class SymKP {
id: string
tokens: string[]
alts: Alt[]
constructor(tokens: string[], alts: Alt[])
getId(): string
show(): string
}
/**
* Alt
*/
declare class Alt {
tokens: string[]
prefixes: string[]
constructor(tokens: string[], prefixes: string[])
}
/**
* SymLit
*/
declare class SymLit {
id: string
i: number
label: number
constructor(i: number, label: number)
getId(): string
show(): string
}
/**
* Trie
*/
declare class Trie {
value: any
items: Trie[]
insertChain(keys, obj): void
insertChain1(keys, obj): void
lookup(key, obj): any
isEmpty(): boolean
}
/**
* ParseState
*/
declare class ParseState {
concrete: GFConcrete
startCat: string
items: Trie
chart: Chart
constructor(concrete: GFConcrete, startCat: string)
next(token: string): boolean
complete(correntToken: string): Trie
extractTrees(): any[]
process(
agenda,
literalCallback: (fid: FId) => any,
tokenCallback: (tokens: string[], item: any) => any
): void
}
/**
* Chart
*/
declare class Chart {
active: any
actives: {[key: number]: any}
passive: any
forest: {[key: number]: ApplyOrCoerce[]}
nextId: number
offset: number
constructor(concrete: GFConcrete)
lookupAC(fid: FId,label)
lookupACo(offset, fid: FId, label)
labelsAC(fid: FId)
insertAC(fid: FId, label, items): void
lookupPC(fid: FId, label, offset)
insertPC(fid1: FId, label, offset, fid2: FId): void
shift(): void
expandForest(fid: FId): any[]
}
/**
* ActiveItem
*/
declare class ActiveItem {
offset: number
dot: number
fun: CncFun
seq: Array<Sym>
args: PArg[]
fid: FId
lbl: number
constructor(
offset: number,
dot: number,
fun: CncFun,
seq: Array<Sym>,
args: PArg[],
fid: FId,
lbl: number
)
isEqual(obj: any): boolean
shiftOverArg(i: number, fid: FId): ActiveItem
shiftOverTokn(): ActiveItem
}

View File

@@ -9,23 +9,4 @@ Executable gfdoc
Executable htmls
main-is: Htmls.hs
build-depends: base
library
hs-source-dirs: gftest
exposed-modules: Grammar
other-modules: Mu, Graph, FMap, EqRel
build-depends: base
, containers
, pgf2
executable gftest
hs-source-dirs: gftest
main-is: Main.hs
build-depends: base
, pgf2
, cmdargs
, containers
, filepath
, gf-tools
build-depends: base

File diff suppressed because it is too large Load Diff

View File

@@ -1,32 +0,0 @@
module EqRel where
import qualified Data.Map as M
import Data.List ( sort )
data EqRel a = Top | Classes [[a]] deriving (Eq,Ord,Show)
(/\) :: (Ord a) => EqRel a -> EqRel a -> EqRel a
Top /\ r = r
r /\ Top = r
Classes xss /\ Classes yss = Classes $ sort $ map sort $ concat -- maybe throw away singleton lists?
[ M.elems tabXs
| xs <- xss
, let tabXs = M.fromListWith (++)
[ (tabYs M.! x, [x])
| x <- xs ]
]
where
tabYs = M.fromList [ (y,representative)
| ys <- yss
, let representative = head ys
, y <- ys ]
basic :: (Ord a) => [a] -> EqRel Int
basic xs = Classes $ sort $ map sort $ M.elems $ M.fromListWith (++)
[ (x,[i]) | (x,i) <- zip xs [0..] ]
rep :: EqRel Int -> Int -> Int
rep Top j = 0
rep (Classes xss) j = head [ head xs | xs <- xss, j `elem` xs ]

View File

@@ -1,62 +0,0 @@
module FMap where
--------------------------------------------------------------------------------
-- implementation
data FMap a b = Ask a (FMap a b) (FMap a b) | Nil | Answer b
deriving ( Eq, Ord, Show )
toList :: FMap a b -> [([a],b)]
toList t = go [([],t)]
where
go [] = []
go ((xs,Ask x yes no):xts) = go ((x:xs,yes):(xs,no):xts)
go ((_ ,Nil) :xts) = go xts
go ((xs,Answer z) :xts) = (reverse xs,z) : go xts
isNil :: FMap a b -> Bool
isNil = null . toList
nil :: FMap a b
nil = Nil
unit :: [a] -> b -> FMap a b
unit [] y = Answer y
unit (x:xs) y = Ask x (unit xs y) Nil
covers :: Ord a => FMap a b -> [a] -> Bool
Nil `covers` _ = False
_ `covers` [] = True
Answer _ `covers` _ = False
Ask x yes no `covers` zs@(y:ys) =
case x `compare` y of
LT -> (yes `covers` zs) || (no `covers` zs)
EQ -> yes `covers` ys
GT -> False
ask :: a -> FMap a b -> FMap a b -> FMap a b
ask x Nil Nil = Nil
ask x s t = Ask x s t
del :: Ord a => [a] -> FMap a b -> FMap a b
del _ Nil = Nil
del _ (Answer _) = Nil
del [] (Ask x yes no) = ask x yes (del [] no)
del (x:xs) t@(Ask y yes no) =
case x `compare` y of
LT -> del xs t
EQ -> ask y (del xs yes) (del xs no)
GT -> ask y yes (del (x:xs) no)
add :: Ord a => [a] -> b -> FMap a b -> FMap a b
add [] y Nil = Answer y
add (x:xs) y Nil = Ask x (add xs y Nil) Nil
add xs@(_:_) y (Answer _) = add xs y Nil
add (x:xs) y t@(Ask z yes no) =
case x `compare` z of
LT -> Ask x (add xs y Nil) (del xs t)
EQ -> Ask x (add xs y yes) (del xs no)
GT -> Ask z yes (add (x:xs) y no)
--------------------------------------------------------------------------------

File diff suppressed because it is too large Load Diff

View File

@@ -1,193 +0,0 @@
module Graph where
import qualified Data.Map as M
import Data.Map( Map, (!) )
import qualified Data.Set as S
import Data.Set( Set )
import Data.List( nub, sort, (\\) )
--import Test.QuickCheck hiding ( generate )
-- == almost everything in this module is inspired by King & Launchbury ==
--------------------------------------------------------------------------------
-- depth-first trees
data Tree a
= Node a [Tree a]
| Cut a
deriving ( Eq, Show )
type Forest a
= [Tree a]
top :: Tree a -> a
top (Node x _) = x
top (Cut x) = x
-- pruning a possibly infinite forest
prune :: Ord a => Forest a -> Forest a
prune ts = go S.empty ts
where
go seen [] = []
go seen (Cut x :ts) = Cut x : go seen ts
go seen (Node x vs:ts)
| x `S.member` seen = Cut x : go seen ts
| otherwise = Node x (take n ws) : drop n ws
where
n = length vs
ws = go (S.insert x seen) (vs ++ ts)
-- pre- and post-order traversals
preorder :: Tree a -> [a]
preorder t = preorderF [t]
preorderF :: Forest a -> [a]
preorderF ts = go ts []
where
go [] xs = xs
go (Cut x : ts) xs = go ts xs
go (Node x vs : ts) xs = x : go vs (go ts xs)
postorder :: Tree a -> [a]
postorder t = postorderF [t]
postorderF :: Forest a -> [a]
postorderF ts = go ts []
where
go [] xs = xs
go (Cut x : ts) xs = go ts xs
go (Node x vs : ts) xs = go vs (x : go ts xs)
-- computing back-arrows
backs :: Ord a => Tree a -> Set a
backs t = S.fromList (go S.empty t)
where
go ups (Node x ts) = concatMap (go (S.insert x ups)) ts
go ups (Cut x) = [x | x `S.member` ups ]
--------------------------------------------------------------------------------
-- graphs
type Graph a
= Map a [a]
vertices :: Graph a -> [a]
vertices g = [ x | (x,_) <- M.toList g ]
transposeG :: Ord a => Graph a -> Graph a
transposeG g =
M.fromListWith (++) $
[ (y,[x]) | (x,ys) <- M.toList g, y <- ys ] ++
[ (x,[]) | x <- vertices g ]
--------------------------------------------------------------------------------
-- graphs and trees
generate :: Ord a => Graph a -> a -> Tree a
generate g x = Node x (map (generate g) (g!x))
dfs :: Ord a => Graph a -> [a] -> Forest a
dfs g xs = prune (map (generate g) xs)
reach :: Ord a => Graph a -> [a] -> Graph a
reach g xs = M.fromList [ (x,g!x) | x <- preorderF (dfs g xs) ]
dff :: Ord a => Graph a -> Forest a
dff g = dfs g (vertices g)
preOrd :: Ord a => Graph a -> [a]
preOrd g = preorderF (dff g)
postOrd :: Ord a => Graph a -> [a]
postOrd g = postorderF (dff g)
scc1 :: Ord a => Graph a -> Forest a
scc1 g = reverse (dfs (transposeG g) (reverse (postOrd g)))
scc2 :: Ord a => Graph a -> Forest a
scc2 g = dfs g (reverse (postOrd (transposeG g)))
scc :: Ord a => Graph a -> Forest a
scc g = scc2 g
sccs :: Ord a => Graph a -> [[a]]
sccs = map preorder . scc
--------------------------------------------------------------------------------
-- testing correctness
{-
newtype G = G (Graph Int) deriving ( Show )
set :: (Ord a, Num a, Arbitrary a) => Gen [a]
set = (nub . sort . map abs) `fmap` arbitrary
instance Arbitrary G where
arbitrary =
do xs <- set `suchThat` (not . null)
yss <- sequence [ listOf (elements xs) | x <- xs ]
return (G (M.fromList (xs `zip` yss)))
shrink (G g) =
[ G (delNode x g)
| (x,_) <- M.toList g
] ++
[ G (delEdge x y g)
| (x,ys) <- M.toList g
, y <- ys
]
where
delNode v g =
M.fromList
[ (x,filter (v/=) ys)
| (x,ys) <- M.toList g
, x /= v
]
delEdge v w g =
M.insert v ((g!v) \\ [w]) g
-- all vertices in a component can reach each other
prop_Scc_StronglyConnected (G g) =
whenFail (print cs) $
and [ y `S.member` r | c <- cs, x <- c, let r = reach x, y <- c ]
where
cs = sccs g
reach x = go S.empty [x]
where
go seen [] = seen
go seen (x:xs)
| x `S.member` seen = go seen xs
| otherwise = go (S.insert x seen) ((g!x) ++ xs)
-- vertices cannot forward-reach to other components
prop_Scc_NotConnected (G g) =
whenFail (print cs) $
-- every vertex is somewhere
and [ or [ x `elem` c | c <- cs ]
| x <- vertices g
] &&
-- cannot foward-reach
and [ y `S.notMember` rx
| (c,d) <- pairs cs
, x <- c
, let rx = reach x
, y <- d
]
where
cs = sccs g
pairs (x:xs) = [ (x,y) | y <- xs ] ++ pairs xs
pairs [] = []
reach x = go S.empty [x]
where
go seen [] = seen
go seen (x:xs)
| x `S.member` seen = go seen xs
| otherwise = go (S.insert x seen) ((g!x) ++ xs)
-}
--------------------------------------------------------------------------------

View File

@@ -1,447 +0,0 @@
{-# LANGUAGE DeriveDataTypeable #-}
module Main where
import Grammar
import EqRel
import Control.Monad ( when )
import Data.List ( intercalate, groupBy, sortBy, deleteFirstsBy, isInfixOf )
import Data.Maybe ( fromMaybe, mapMaybe )
import qualified Data.Set as S
import qualified Data.Map as M
import System.Console.CmdArgs hiding ( name, args )
import qualified System.Console.CmdArgs as A
import System.FilePath.Posix ( takeFileName )
import System.IO ( stdout, hSetBuffering, BufferMode(..) )
data GfTest
= GfTest
{ grammar :: Maybe FilePath
-- Languages
, lang :: Lang
-- Functions and cats
, function :: Name
, category :: Cat
, tree :: String
, start_cat :: Maybe Cat
, show_cats :: Bool
, show_funs :: Bool
, funs_of_arity :: Maybe Int
, show_coercions:: Bool
, show_contexts :: Maybe Int
, concr_string :: String
-- Information about fields
, equal_fields :: Bool
, empty_fields :: Bool
, unused_fields :: Bool
, erased_trees :: Bool
-- Compare to old grammar
, old_grammar :: Maybe FilePath
, only_changed_cats :: Bool
-- Misc
, treebank :: Maybe FilePath
, count_trees :: Maybe Int
, debug :: Bool
, write_to_file :: Bool
} deriving (Data,Typeable,Show,Eq)
gftest = GfTest
{ grammar = def &= typFile &= help "Path to the grammar (PGF) you want to test"
, lang = def &= A.typ "\"Eng Swe\""
&= help "Concrete syntax + optional translations"
, tree = def &= A.typ "\"UseN tree_N\""
&= A.name "t" &= help "Test the given tree"
, function = def &= A.typ "UseN"
&= A.name "f" &= help "Test the given function(s)"
, category = def &= A.typ "NP"
&= A.name "c" &= help "Test all functions with given goal category"
, start_cat = def &= A.typ "Utt"
&= A.name "s" &= help "Use the given category as start category"
, concr_string = def &= A.typ "the" &= help "Show all functions that include given string"
, show_cats = def &= help "Show all available categories"
, show_funs = def &= help "Show all available functions"
, funs_of_arity = def &= A.typ "2" &= help "Show all functions of arity 2"
, show_coercions= def &= help "Show coercions in the grammar"
, show_contexts = def &= A.typ "8410" &= help "Show contexts for a given concrete type (given as FId)"
, debug = def &= help "Show debug output"
, equal_fields = def &= A.name "q" &= help "Show fields whose strings are always identical"
, empty_fields = def &= A.name "e" &= help "Show fields whose strings are always empty"
, unused_fields = def &= help "Show fields that never make it into the top category"
, erased_trees = def &= A.name "r" &= help "Show trees that are erased"
, treebank = def &= typFile
&= A.name "b" &= help "Path to a treebank"
, count_trees = def &= A.typ "3" &= help "Number of trees of size <3>"
, old_grammar = def &= typFile
&= A.name "o" &= help "Path to an earlier version of the grammar"
, only_changed_cats = def &= help "When comparing against an earlier version of a grammar, only test functions in categories that have changed between versions"
, write_to_file = def &= help "Write the results in a file (<GRAMMAR>_<FUN>.org)"
}
main :: IO ()
main = do
hSetBuffering stdout NoBuffering
args <- cmdArgs gftest
case grammar args of
Nothing -> putStrLn "Usage: `gftest -g <PGF grammar> [OPTIONS]'\nTo see available commands, run `gftest --help' or visit https://github.com/GrammaticalFramework/GF/blob/master/src/tools/gftest/README.md"
Just fp -> do
let (absName,grName) = (takeFileName $ stripPGF fp, stripPGF fp ++ ".pgf") --doesn't matter if the name is given with or without ".pgf"
(langName:langTrans) = case lang args of
[] -> [ absName ++ "Eng" ] -- if no English grammar found, it will be given a default value later
langs -> [ absName ++ t | t <- words langs ]
-- Read grammar and translations
gr <- readGrammar langName grName
grTrans <- sequence [ readGrammar lt grName | lt <- langTrans ]
-- if language given by the user was not valid, use default language from Grammar
let langName = concrLang gr
let startcat = startCat gr `fromMaybe` start_cat args
testTree' t n = testTree False gr grTrans t n ctxs
where
s = top t
c = snd (ctyp s)
ctxs = concat [ contextsFor gr sc c
| sc <- ccats gr startcat ]
output = -- Print to stdout or write to a file
if write_to_file args
then \x ->
do let fname = concat [ langName, "_", function args, category args, ".org" ]
writeFile fname x
putStrLn $ "Wrote results in " ++ fname
else putStrLn
intersectConcrCats cats_fields intersection =
M.fromListWith intersection
([ (c,fields)
| (CC (Just c) _,fields) <- cats_fields
] ++
[ (cat,fields)
| (c@(CC Nothing _),fields) <- cats_fields
, (CC (Just cat) _,coe) <- coercions gr
, c == coe
])
printStats tab =
sequence_ [ do putStrLn $ "==> " ++ c ++ ": "
putStrLn $ unlines (map (fs!!) xs)
| (c,vs) <- M.toList tab
, let fs = fieldNames gr c
, xs@(_:_) <- [ S.toList vs ] ]
-----------------------------------------------------------------------------
-- Testing functions
-- Test a tree
let trees = case tree args of
[] -> []
ts -> lines ts
output $
unlines [ testTree' (readTree gr tree) 1 | tree <- trees ]
-- Test a function
let substrs xs = filter (/="*") $ groupBy (\a b -> a/='*' && b/='*') xs
let cats = case category args of
[] -> []
cs -> if '*' `elem` cs
then let subs = substrs cs
in nub [ cat | (cat,_,_,_) <- concrCats gr
, all (`isInfixOf` cat) subs ]
else words cs
output $
unlines [ testTree' t n
| cat <- cats
, (t,n) <- treesUsingFun gr (functionsByCat gr cat) `zip` [1..]]
-- Test all functions in a category
let funs = case function args of
[] -> []
fs -> if '*' `elem` fs
then let subs = substrs fs
in nub [ f | s <- symbols gr, let f = show s
, all (`isInfixOf` f) subs
, arity s >= 1 ]
else words fs
output $
unlines [ testFun (debug args) gr grTrans startcat f
| f <- funs ]
-----------------------------------------------------------------------------
-- Information about the grammar
-- Show contexts for a particular concrete category
case show_contexts args of
Nothing -> return ()
Just fid -> mapM_ print
[ ctx dummyHole
| start <- ccats gr startcat
, ctx <- contextsFor gr start (mkCC gr fid) ]
-- Show available categories
when (show_cats args) $ do
putStrLn "* Categories in the grammar:"
let concrcats = sortBy (\(_,a,_,_) (_,b,_,_) -> a `compare` b) (concrCats gr)
sequence_ [ do putStrLn cat
when (debug args) $
putStrLn $ unwords $
[ " Compiles to concrete" ] ++
[ "categories " ++ show bg++""++show end
| bg/=end ] ++
[ "category " ++ show bg
| bg==end ]
| (cat,bg,end,_) <- concrcats
, end >= 0]
-- Show available functions
when (show_funs args) $ do
putStrLn "* Functions in the grammar:"
putStrLn $ unlines $ nub [ show s | s <- symbols gr ]
-- Show coercions in the grammar
when (show_coercions args) $ do
putStrLn "* Coercions in the grammar:"
putStrLn $ unlines [ show cat++"--->"++show coe | (cat,coe) <- coercions gr ]
case funs_of_arity args of
Nothing -> return ()
Just n -> do
putStrLn $ "* Functions in the grammar of arity " ++ show n ++ ":"
putStrLn $ unlines $ nub [ show s | s <- symbols gr, arity s == n ]
-- Show all functions that contain the given string
-- (e.g. English "it" appears in DefArt, ImpersCl, it_Pron, …)
case concr_string args of
[] -> return ()
str -> do putStrLn $ "### The following functions contain the string '" ++ str ++ "':"
putStr "==> "
putStrLn $ intercalate ", " $ nub [ name s | s <- hasConcrString gr str]
-- Show empty fields
when (empty_fields args) $ do
putStrLn "### Empty fields:"
printStats $ intersectConcrCats (emptyFields gr) S.intersection
putStrLn ""
-- Show erased trees
when (erased_trees args) $ do
putStrLn "* Erased trees:"
sequence_
[ do putStrLn ("** " ++ intercalate "," erasedTrees ++ " : " ++ uncoerceAbsCat gr c)
sequence_
[ do putStrLn ("- Tree: " ++ showTree t)
putStrLn ("- Lin: " ++ s)
putStrLn $ unlines
[ "- Trans: "++linearize tgr t
| tgr <- grTrans ]
| t <- ts
, let s = linearize gr t
, let erasedSymbs = [ sym | sym <- flatten t, c==snd (ctyp sym) ]
]
| top <- take 1 $ ccats gr startcat
, (c,ts) <- forgets gr top
, let erasedTrees =
concat [ [ showTree subtree
| sym <- flatten t
, let csym = snd (ctyp sym)
, c == csym || coerces gr c csym
, let Just subtree = subTree sym t ]
| t <- ts ]
]
putStrLn ""
-- Show unused fields
when (unused_fields args) $ do
let unused =
[ (c,S.fromList notUsed)
| tp <- ccats gr startcat
, (c,is) <- reachableFieldsFromTop gr tp
, let ar = head $
[ length (seqs f)
| f <- symbols gr, snd (ctyp f) == c ] ++
[ length (seqs f)
| (b,a) <- coercions gr, a == c
, f <- symbols gr, snd (ctyp f) == b ]
notUsed = [ i | i <- [0..ar-1], i `notElem` is ]
, not (null notUsed)
]
putStrLn "### Unused fields:"
printStats $ intersectConcrCats unused S.intersection
putStrLn ""
-- Show equal fields
let tab = intersectConcrCats (equalFields gr) (/\)
when (equal_fields args) $ do
putStrLn "### Equal fields:"
sequence_
[ putStrLn ("==> " ++ c ++ ":\n" ++ cl)
| (c,eqr) <- M.toList tab
, let fs = fieldNames gr c
, cl <- case eqr of
Top -> ["TOP"]
Classes xss -> [ unlines (map (fs!!) xs)
| xs@(_:_:_) <- xss ]
]
putStrLn ""
case count_trees args of
Nothing -> return ()
Just n -> do let start = head $ ccats gr startcat
let i = featCard gr start n
let iTot = sum [ featCard gr start m | m <- [1..n] ]
putStr $ "There are "++show iTot++" trees up to size "++show n
putStrLn $ ", and "++show i++" of exactly size "++show n++".\nFor example: "
putStrLn $ "* " ++ show (featIth gr start n 0)
putStrLn $ "* " ++ show (featIth gr start n (i-1))
-------------------------------------------------------------------------------
-- Read trees from treebank.
treebank' <-
case treebank args of
Nothing -> return []
Just fp -> do
tb <- readFile fp
return [ readTree gr s
| s <- lines tb ]
mapM_ print treebank'
-------------------------------------------------------------------------------
-- Comparison with old grammar
case old_grammar args of
Nothing -> return ()
Just fp -> do
oldgr <- readGrammar langName (stripPGF fp ++ ".pgf")
let ogr = oldgr { concrLang = concrLang oldgr ++ "-OLD" }
difcats = diffCats ogr gr -- (acat, [#o, #n], olabels, nlabels)
--------------------------------------------------------------------------
-- generate statistics of the changes in the concrete categories
let ccatChangeFile = langName ++ "-ccat-diff.org"
writeFile ccatChangeFile ""
sequence_
[ appendFile ccatChangeFile $ unlines
[ "* " ++ acat
, show o ++ " concrete categories in the old grammar,"
, show n ++ " concrete categories in the new grammar."
, "** Labels only in old (" ++ show (length ol) ++ "):"
, intercalate ", " ol
, "** Labels only in new (" ++ show (length nl) ++ "):"
, intercalate ", " nl ]
| (acat, [o,n], ol, nl) <- difcats ]
when (debug args) $
sequence_
[ appendFile ccatChangeFile $
unlines $
("* All concrete cats in the "++age++" grammar:"):
[ show cts | cts <- concrCats g ]
| (g,age) <- [(ogr,"old"),(gr,"new")] ]
putStrLn $ "Created file " ++ ccatChangeFile
--------------------------------------------------------------------------
-- Print out tests for all functions in the changed cats.
-- If -f, -c or --treebank specified, use them.
let f cat = (cat, treesUsingFun gr $ functionsByCat gr cat)
byCat = [ f cat | cat <- cats ] -- from command line arg -c
changed = [ f cat | (cat,_,_,_) <- difcats
, only_changed_cats args ]
byFun = [ (cat, treesUsingFun gr fs)
| funName <- funs -- comes from command line arg -f
, let fs@(s:_) = lookupSymbol gr funName
, let cat = snd $ Grammar.typ s ]
fromTb = [ (cat,[tree]) | tree <- treebank'
, let (CC (Just cat) _) = ccatOf tree ]
treesToTest =
case concat [byFun, byCat, changed, fromTb] of
[] -> [ f cat -- nothing else specified -> test all functions
| (cat,_,_,_) <- concrCats gr ]
xs -> S.toList $ S.fromList xs
writeLinFile file grammar otherGrammar = do
writeFile file ""
putStrLn "Testing functions in… "
diff <- concat `fmap`
sequence [ do let cs = [ compareTree grammar otherGrammar grTrans t
| t <- trees ]
putStr $ cat ++ " \r"
-- prevent lazy evaluation; make printout accurate
appendFile ("/tmp/"++file) (unwords $ map show cs)
return cs
| (cat,trees) <- treesToTest ]
let relevantDiff = go [] [] diff where
go res seen [] = res
go res seen (Comparison f ls:cs) =
if null uniqLs then go res seen cs
else go (Comparison f uniqLs:res) (uniqLs++seen) cs
where uniqLs = deleteFirstsBy ctxEq ls seen
ctxEq (a,_,_,_) (b,_,_,_) = a==b
shorterTree c1 c2 = length (funTree c1) `compare` length (funTree c2)
writeFile file $ unlines
[ show comp
| comp <- sortBy shorterTree relevantDiff ]
writeLinFile (langName ++ "-lin-diff.org") gr ogr
putStrLn $ "Created file " ++ (langName ++ "-lin-diff.org")
---------------------------------------------------------------------------
-- Print statistics about the functions: e.g., in the old grammar,
-- all these 5 functions used to be in the same category:
-- [DefArt,PossPron,no_Quant,this_Quant,that_Quant]
-- but in the new grammar, they are split into two:
-- [DefArt,PossPron,no_Quant] and [this_Quant,that_Quant].
let groupFuns grammar = -- :: Grammar -> [[Symbol]]
concat [ groupBy sameCCat $ sortBy compareCCat funs
| (cat,_,_,_) <- difcats
, let funs = functionsByCat grammar cat ]
sortByName = sortBy (\s t -> name s `compare` name t)
writeFunFile groupedFuns file grammar = do
writeFile file ""
sequence_ [ do appendFile file "---\n"
appendFile file $ unlines
[ showConcrFun gr fun
| fun <- sortByName funs ]
| funs <- groupedFuns ]
writeFunFile (groupFuns ogr) (langName ++ "-old-funs.org") ogr
writeFunFile (groupFuns gr) (langName ++ "-new-funs.org") gr
putStrLn $ "Created files " ++ langName ++ "-(old|new)-funs.org"
where
nub = S.toList . S.fromList
sameCCat :: Symbol -> Symbol -> Bool
sameCCat s1 s2 = snd (ctyp s1) == snd (ctyp s2)
compareCCat :: Symbol -> Symbol -> Ordering
compareCCat s1 s2 = snd (ctyp s1) `compare` snd (ctyp s2)
stripPGF :: String -> String
stripPGF s = case reverse s of
'f':'g':'p':'.':name -> reverse name
name -> s

View File

@@ -1,113 +0,0 @@
module Mu where
import Data.Map( Map, (!) )
import qualified Data.Map as M
import Data.Set( Set )
import qualified Data.Set as S
import Graph
--------------------------------------------------------------------------------
-- naive implementation of fixpoint computation
mu0 :: (Ord x, Eq a) => a -> [(x, [x], [a] -> a)] -> [x] -> [a]
mu0 bot defs zs = [ done!z | z <- zs ]
where
xs = [ x | (x, _, _) <- defs ]
done = iter [ bot | _ <- xs ]
iter as
| as == as' = tab
| otherwise = iter as'
where
tab = M.fromList (xs `zip` as)
as' = [ f [ tab!y | y <- ys ]
| (_,(_, ys, f)) <- as `zip` defs
]
--------------------------------------------------------------------------------
-- scc-based implementation of fixpoint computation
{-
a --^ initial/bottom value (smallest element) in the fixpoint computation
-> [( x, [x] --^ A single category, its arguments
, [a] -> a) --^ function that takes as its argument a list of values that we want to compute for the [x]
]
-> [x] --^ All categories that you want to see the answer for
-> [a] --^ Values for the given categories
-}
mu :: (Ord x, Eq a) => a -> [(x, [x], [a] -> a)] -> [x] -> [a]
mu bot defs zs = [ vtab?z | z <- zs ]
where
ftab = M.fromList [ (x,f) | (x,_,f) <- defs ]
graph = reach (M.fromList [ (x,xs) | (x,xs,_) <- defs ]) zs
vtab = foldl compute M.empty (scc graph)
compute vtab t = fix (-1) vtab (map (vtab ?) xs)
where
xs = S.toList (backs t)
fix 0 vtab _ = vtab
fix n vtab as
| as' == as = vtab'
| otherwise = fix (n-1) vtab' as'
where
(_,vtab') = eval t vtab
as' = map (vtab' ?) xs
eval (Cut x) vtab = (vtab?x, vtab)
eval (Node x ts) vtab = (a, M.insert x a vtab')
where
(as, vtab') = evalList ts vtab
a = (ftab!x) as
evalList [] vtab = ([], vtab)
evalList (t:ts) vtab = (a:as, vtab'')
where
(a, vtab') = eval t vtab
(as,vtab'') = evalList ts vtab'
vtab ? x = case M.lookup x vtab of
Nothing -> bot
Just a -> a
--------------------------------------------------------------------------------
-- diff/scc-based implementation of fixpoint computation
muDiff :: (Ord x, Eq a)
=> a -> (a->Bool) -> (a->a->a) -> (a->a->a)
-> [(x, [x], [a] -> a)]
-> [x] -> [a]
muDiff bot isBot diff apply defs zs = [ vtab?z | z <- zs ]
where
ftab = M.fromList [ (x,f) | (x,_,f) <- defs ]
graph = reach (M.fromList [ (x,xs) | (x,xs,_) <- defs ]) zs
vtab = foldl compute M.empty (scc graph)
compute vtab t = fix vtab M.empty
where
xs = S.toList (backs t)
fix dtab vtab
| all isBot ds = vtab'
| otherwise = fix (M.fromList (xs `zip` ds)) vtab'
where
dtab' = eval t dtab
vtab' = foldr (\(x,d) -> M.alter (Just . apply' d) x) vtab (M.toList dtab')
ds = map (dtab' ?) xs
apply' d Nothing = apply d bot
apply' d (Just a) = apply d a
eval (Cut x) tab = tab
eval (Node x ts) tab = M.insert x d tab'
where
tab' = foldl (flip eval) tab ts
d = (ftab!x) [ tab'?x | x <- map top ts ] `diff` (vtab?x)
vtab ? x = case M.lookup x vtab of
Nothing -> bot
Just a -> a
--------------------------------------------------------------------------------

View File

@@ -1,563 +1 @@
# gftest: Automatic systematic test case generation for GF grammars
`gftest` is a program for automatically generating systematic test
cases for GF grammars. The basic use case is to give `gftest` a
PGF grammar, a concrete language and a function; then `gftest` generates a
representative and minimal set of example sentences for a human to look at.
There are examples of actual generated test cases later in this
document, as well as the full list of options to give to `gftest`.
## Table of Contents
- [Installation](#installation)
- [Prerequisites](#prerequisites)
- [Install gftest](#install-gftest)
- [Common use cases](#common-use-cases)
- [Grammar: `-g`](#grammar--g)
- [Language: `-l`](#language--l)
- [Function(s) to test: `-f`](#functions-to-test--f)
- [Start category for context: `-s`](#start-category-for-context--s)
- [Category to test: `-c`](#category-to-test--c)
- [Tree to test: `-t`](#tree-to-test--t)
- [Compare against an old version of the grammar: `-o`](#compare-against-an-old-version-of-the-grammar--o)
- [Information about a particular string: `--concr-string`](#information-about-a-particular-string---concr-string)
- [Write into a file: `-w`](#write-into-a-file--w)
- [Less common use cases](#less-common-use-cases)
- [Empty or always identical fields: `-e`, `-q`](#empty-or-always-identical-fields--e--q)
- [Unused fields: `-u`](#unused-fields--u)
- [Erased trees: `-r`](#erased-trees--r)
- [Debug information: `-d`](#debug-intormation--d)
- [Detailed information about the grammar](#detailed-information-about-the-grammar)
- [--show-cats](#--show-cats)
- [--show-funs](#--show-funs)
- [--show-coercions](#--show-coercions)
- [--show-contexts](#--show-contexts)
- [--count-trees](#--count-trees)
- [--funs-of-arity](#--funs-of-arity)
## Installation
### Prerequisites
You need the library `PGF2`. Here are instructions how to install:
1) Install C runtime: go to the directory [GF/src/runtime/c](https://github.com/GrammaticalFramework/GF/tree/master/src/runtime/c), see
instructions in INSTALL
1) Install PGF2 in one of the two ways:
* **EITHER** Go to the directory
[GF/src/runtime/haskell-bind](https://github.com/GrammaticalFramework/GF/tree/master/src/runtime/haskell-bind),
do `cabal install`
* **OR** Go to the root directory of
[GF](https://github.com/GrammaticalFramework/GF/) and compile GF
with C-runtime system support: `cabal
install -fc-runtime`, see more information [here](http://www.grammaticalframework.org/doc/gf-developers.html#toc16).
### Install gftest
Go to
[GF/src/tools](https://github.com/GrammaticalFramework/GF/tree/master/src/tools),
do `cabal install`. It creates an executable `gftest`.
## Common use cases
Run `gftest --help` of `gftest -?` to get the list of options.
```
Common flags:
-g --grammar=FILE Path to the grammar (PGF) you want to test
-l --lang="Eng Swe" Concrete syntax + optional translations
-f --function=UseN Test the given function(s)
-c --category=NP Test all functions with given goal category
-t --tree="UseN tree_N" Test the given tree
-s --start-cat=Utt Use the given category as start category
--show-cats Show all available categories
--show-funs Show all available functions
--funs-of-arity=2 Show all functions of arity 2
--show-coercions Show coercions in the grammar
--show-contexts=8410 Show contexts for a given concrete type (given as FId)
--concr-string=the Show all functions that include given string
-q --equal-fields Show fields whose strings are always identical
-e --empty-fields Show fields whose strings are always empty
-u --unused-fields Show fields that never make it into the top category
-r --erased-trees Show trees that are erased
-o --old-grammar=ITEM Path to an earlier version of the grammar
--only-changed-cats When comparing against an earlier version of a
grammar, only test functions in categories that have
changed between versions
-b --treebank=ITEM Path to a treebank
--count-trees=3 Number of trees of depth <depth>
-d --debug Show debug output
-w --write-to-file Write the results in a file (<GRAMMAR>_<FUN>.org)
-? --help Display help message
-V --version Print version information
```
### Grammar: `-g`
Give the PGF grammar as an argument with `-g`. If the file is not in
the same directory, you need to give the full file path.
You can give the grammar with or without `.pgf`.
Without a concrete syntax you can't do much, but you can see the
available categories and functions with `--show-cats` and `--show-funs`
Examples:
* `gftest -g Foods --show-funs`
* `gftest -g /home/inari/grammars/LangEng.pgf --show-cats`
### Language: `-l`
Give a concrete language. It assumes the format `AbsNameConcName`, and you should only give the `ConcName` part.
You can give multiple languages, in which case it will create the test cases based on the first, and show translations in the rest.
Examples:
* `gftest -g Phrasebook -l Swe --show-cats`
* `gftest -g Foods -l "Spa Eng" -f Pizza`
### Function(s) to test: `-f`
Given a grammar (`-g`) and a concrete language ( `-l`), test a function or several functions.
Examples:
* `gftest -g Lang -l "Dut Eng" -f UseN`
* `gftest -g Phrasebook -l Spa -f "ByTransp ByFoot"`
You can use the wildcard `*`, if you want to match multiple functions. Examples:
* `gftest -g Lang -l Eng -f "*hat*"`
matches `hat_N, hate_V2, that_Quant, that_Subj, whatPl_IP` and `whatSg_IP`.
* `gftest -g Lang -l Eng -f "*hat*u*"`
matches `that_Quant` and `that_Subj`.
* `gftest -g Lang -l Eng -f "*"`
matches all functions in the grammar. (As of March 2018, takes 13
minutes for the English resource grammar, and results in ~40k
lines. You may not want to do this for big grammars.)
### Start category for context: `-s`
Give a start category for contexts. Used in conjunction with `-f`,
`-c`, `-t` or `--count-trees`. If not specified, contexts are created
for the start category of the grammar.
Example:
* `gftest -g Lang -l "Dut Eng" -f UseN -s Adv`
This creates a hole of `CN` in `Adv`, instead of the default start category.
### Category to test: `-c`
Given a grammar (`-g`) and a concrete language ( `-l`), test all functions that return a given category.
Examples:
* `gftest -g Phrasebook -l Fre -c Modality`
* `gftest -g Phrasebook -l Fre -c ByTransport -s Action`
### Tree to test: `-t`
Given a grammar (`-g`) and a concrete language ( `-l`), test a complete tree.
Example:
* `gftest -g Phrasebook -l Dut -t "ByTransp Bus"`
You can combine it with any of the other flags, e.g. put it in a
different start category:
* `gftest -g Phrasebook -l Dut -t "ByTransp Bus" -s Action`
This may be useful for the following case. Say you tested `PrepNP`,
and the default NP it gave you only uses the word *car*, but you
would really want to see it for some other noun—maybe `car_N` itself
is buggy, and you want to be sure that `PrepNP` works properly. So
then you can call the following:
* `gftest -g TestLang -l Eng -t "PrepNP with_Prep (MassNP (UseN beer_N))"`
### Compare against an old version of the grammar: `-o`
Give a grammar, a concrete syntax, and an old version of the same
grammar as a separate PGF file. The program generates test sentences
for all functions (if no other arguments), linearises with both
grammars, and outputs those that differ between the versions. It
writes the differences into files.
Example:
```
> gftest -g TestLang -l Eng -o TestLangOld
Created file TestLangEng-ccat-diff.org
Testing functions in…
<categories flashing by>
Created file TestLangEng-lin-diff.org
Created files TestLangEng-(old|new)-funs.org
```
* TestLangEng-ccat-diff.org: All concrete categories that have
changed. Shows e.g. if you added or removed a parameter or a
field.
* **TestLangEng-lin-diff.org** (usually the most relevant file): All
trees that have different linearisations in the following format.
```
* send_V3
** UseCl (TTAnt TPres ASimul) PPos (PredVP (UsePron we_Pron) (ReflVP (Slash3V3 ∅ (UsePron it_Pron))))
TestLangDut> we sturen onszelf ernaar
TestLangDut-OLD> we sturen zichzelf ernaar
** UseCl (TTAnt TPast ASimul) PPos (PredVP (UsePron we_Pron) (ReflVP (Slash3V3 ∅ (UsePron it_Pron))))
TestLangDut> we stuurden onszelf ernaar
TestLangDut-OLD> we stuurden zichzelf ernaar
```
* TestLangEng-old-funs.org and TestLangEng-new-funs.org: groups the
functions by their concrete categories. Shows difference if you have
e.g. added or removed parameters, and that has created new versions of
some functions: say you didn't have gender in nouns, but now you
have, then all functions taking nouns have suddenly a gendered
version. (This is kind of hard to read, don't worry too much if the
output doesn't make any sense.)
#### Additional arguments to `-o`
The default mode is to test all functions, but you can also give any
combination of `-s`, `-f`, `-c`, `--treebank`/`-b` and `--only-changed-cats`.
With `-s`, you can change the start category in which contexts are
generated.
With `-f` and `-c`, it tests only the specified functions and
categories.
With `-b FILEPATH` (`-b`=`--treebank`), it tests only the trees in the file.
With `--only-changed-cats`, it only test functions in those categories
that have changed between the two versions.
Examples:
* `gftest -g TestLang -l Eng -o TestLangOld` tests all functions
* `gftest -g TestLang -l Eng -o TestLangOld -s S` tests all functions in start category S
* `gftest -g TestLang -l Eng -o TestLangOld --only-changed-cats` tests only changed categories. If no categories have changed (and no other arguments specified), tests everything.
* `gftest -g TestLang -l Eng -o TestLangOld -f "AdjCN AdvCN" -c Adv -b trees.txt` tests functions, `AdjCN` and `AdvCN`; same for all functions that produce an `Adv`, and all trees in trees.txt.
### Information about a particular string: `--concr-string`
Show all functions that introduce the string given as an argument.
Example:
* `gftest -g Lang -l Eng --concr-string it`
which gives the answer `==> CleftAdv, CleftNP, DefArt, ImpersCl, it_Pron`
(Note that you have the same feature in GF shell, command `morpho_analyse`/`ma`.)
### Write into a file: `-w`
Writes the results into a file of format `<GRAMMAR>_<FUN or CAT>.org`,
e.g. TestLangEng-UseN.org. Recommended to open it in emacs org-mode,
so you get an overview, and you can maybe ignore some trees if you
think they are redundant.
1) When you open the file, you see a list of generated test cases, like this: ![Instructions how to use org mode](https://raw.githubusercontent.com/inariksit/GF-testing/master/doc/instruction-1.png)
Place cursor to the left and click tab to open it.
2) You get a list of contexts for the test case. Keep the cursor where it was if you want to open everything at the same time. Alternatively, scroll down to one of the contexts and press tab there, if you only want to open one.
![Instructions how to use org mode](https://raw.githubusercontent.com/inariksit/GF-testing/master/doc/instruction-2.png)
3) Now you can read the linearisations.
![Instructions how to use org mode](https://raw.githubusercontent.com/inariksit/GF-testing/master/doc/instruction-3.png)
If you want to close the test case, just press tab again, keeping the
cursor where it's been all the time (line 31 in the pictures).
## Less common use cases
The topics here require some more obscure GF-fu. No need to worry if
the terms are not familiar to you.
### Empty or always identical fields: `-e`, `-q`
Information about the fields: always empty, or always equal to each
other. Example of empty fields:
```
> gftest -g Lang -l Dut -e
* Empty fields:
==> Ant: s
==> Pol: s
==> Temp: s
==> Tense: s
==> V: particle, prefix
```
The categories `Ant`, `Pol`, `Temp` and `Tense` are as expected empty;
there's no string to be added to the sentences, just a parameter that
*chooses* the right forms of the clause.
`V` having empty fields `particle` and `prefix` is in this case just
an artefact of a small lexicon: we happen to have no intransitive
verbs with a particle or prefix in the core 300-word vocabulary. But a
grammarian would know that it's still relevant to keep those fields,
because in some bigger application such a verb may show up.
On the other hand, if some other field is always empty, it might be a
hint for the grammarian to remove it altogether.
Example of equal fields:
```
> gftest -g Lang -l Dut -q
* Equal fields:
==> RCl:
s Pres Simul Pos Utr Pl
s Pres Simul Pos Neutr Pl
==> RCl:
s Pres Simul Neg Utr Pl
s Pres Simul Neg Neutr Pl
==> RCl:
s Pres Anter Pos Utr Pl
s Pres Anter Pos Neutr Pl
==> RCl:
s Pres Anter Neg Utr Pl
s Pres Anter Neg Neutr Pl
==> RCl:
s Past Simul Pos Utr Pl
s Past Simul Pos Neutr Pl
```
Here we can see that in relative clauses, gender does not seem to play
any role in plural. This could be a hint for the grammarian to make a
leaner parameter type, e.g. `param RClAgr = SgAgr <everything incl. gender> | PlAgr <no gender here>`.
### Unused fields: `-u`
These fields are not empty, but they are never used in the top
category. The top category can be specified by `-s`, otherwise it is
the default start category of the grammar.
Note that if you give a start category from very low, such as `Adv`,
you get a whole lot of categories and fields that naturally have no
way of ever making it into an adverb. So this is mostly meaningful to
use for the start category.
### Erased trees: `-r`
Show trees that are erased in some function, i.e. a function `F : A -> B -> C` has arguments A and B, but doesn't use one of them in the resulting tree of type C. This is usually a bug.
Example:
```
> gftest -g Lang -l "Dut Eng" -r
* Erased trees:
** RelCl (ExistNP something_NP) : RCl
- Tree: AdvS (PrepNP with_Prep (RelNP (UsePron it_Pron) (UseRCl (TTAnt TPres ASimul) PPos (RelCl (ExistNP something_NP))))) (UseCl (TTAnt TPres ASimul) PPos (ExistNP something_NP))
- Lin: ermee is er iets
- Trans: with it, such that there is something, there is something
** write_V2 : V2
- Tree: AdvS (PrepNP with_Prep (PPartNP (UsePron it_Pron) write_V2)) (UseCl (TTAnt TPres ASimul) PPos (ExistNP something_NP))
- Lin: ermee is er iets
- Trans: with it written there is something
```
In the first result, an argument of type `RCl` is missing in the tree constructed by `RelNP`, and in the second result, the argument `write_V2` is missing in the tree constructed by `PPartNP`. In both cases, the English linearisation contains all the arguments, but in the Dutch one they are missing. (This bug is already fixed, just showing it here to demonstrate the feature.)
## Detailed information about the grammar
### Debug information: `-d`
When combined with `-f`, `-c` or `-t`, two things happen:
1) The trees are linearised using `tabularLinearize`, which shows the
inflection table of all forms.
2) You can see traces of pruning that happens in testing functions:
contexts that are common to several concrete categories are put under
a separate test case.
When combined with `--show-cats`, also the concrete categories are
shown.
### --show-cats
Shows the categories in the grammar. With `--debug`/`-d`, shows also
concrete categories.
Example:
```
> gftest -g Foods -l Spa --show-cats -d
* Categories in the grammar:
Comment
Compiles to concrete category 0
Item
Compiles to concrete categories 1—4
Kind
Compiles to concrete categories 5—6
Quality
Compiles to concrete categories 7—8
Question
Compiles to concrete category 9
```
### --show-funs
Shows the functions in the grammar. (Nothing fancy happens with other flags.)
### --show-coercions
First I'll explain what *coercions* are, then why it may be
interesting to show them. Let's take a Spanish Foods grammar, and
consider the category `Quality`, e.g. `Good` and `Vegan`.
`Good` "bueno/buena/buenos/buenas" goes before the noun it modifies,
whereas `Vegan` "vegano/vegana/…" goes after, so these will become different
*concrete categories* in the PGF: `Quality_before` and
`Quality_after`. (In reality, they are something like `Quality_7` and
`Quality_8` though.)
Now, this difference is meaningful only when the adjective is modifying
the noun: "la buena pizza" vs. "la pizza vegana". But when the
adjective is in a predicative position, they both behave the same:
"la pizza es buena" and "la pizza es vegana". For this, the grammar
creates a *coercion*: both `Quality_before` and `Quality_after` may be
treated as `Quality_whatever`. To save some redundant work, this coercion `Quality_whatever`
appears in the type of predicative function, whereas the
modification function has to be split into two different functions,
one taking `Quality_before` and other `Quality_after`.
Now you know what coercions are, this is how it looks like in the program:
```
> gftest -g Foods -l Spa --show-coercions
* Coercions in the grammar:
Quality_7--->_11
Quality_8--->_11
```
(Just mentally replace 7 with `before`, 8 with `after` and 11 with `whatever`.)
### --show-contexts
Show contexts for a given concrete category, given as an FId
(i.e. Int). The concrete category may be a coercion or a normal
category. By combining with [`-s`](#start-category-for-context--s),
you can change the start category of the context.
(You can get a list of all concrete categories by pairing `--show-cats`
with `--debug`: see [`--show-cats`](#--show-cats).)
Examples:
* First, find out some concrete categories:
```
> gftest -g Foods -l Spa --show-cats -d
Quality
Compiles to concrete categories 7—8
```
* Then, list the contexts for some of them, say `Quality_7`:
```
> gftest -g Foods -l Spa --show-contexts 7
Pred (That (Mod ∅ Wine)) Vegan
Pred (That Wine) ∅
Pred (These (Mod ∅ Wine)) Vegan
Pred (These Wine) ∅
Pred (That (Mod ∅ Pizza)) Vegan
Pred (That Pizza) ∅
Pred (These (Mod ∅ Pizza)) Vegan
Pred (These Pizza) ∅
```
* Check out from [`--show-coercions`](#--show-coercions) how to find
coercions, and you can try `--show-contexts` with them:
```
> gftest -g Foods -l Spa --show-contexts 11
Pred (That Wine) ∅
Pred (These Wine) ∅
Pred (That Pizza) ∅
Pred (These Pizza) ∅
```
### --count-trees
Number of trees up to given size. Gives a number how many trees, and a
couple of examples from the highest size. Examples:
```
> gftest -g TestLang -l Eng --count-trees 10
There are 675312 trees up to size 10, and 624512 of exactly size 10.
For example:
* AdvS today_Adv (UseCl (TTAnt TPres ASimul) PPos (ExistNP (UsePron i_Pron)))
* UseCl (TTAnt TCond AAnter) PNeg (PredVP (SelfNP (UsePron they_Pron)) UseCopula)
```
This counts the number of trees in the start category. You can also
specify a category:
```
> gftest -g TestLang -l Eng --count-trees 4 -s Adv
There are 2409 trees up to size 4, and 2163 of exactly size 4.
For example:
* AdAdv very_AdA (PositAdvAdj young_A)
* PrepNP above_Prep (UsePron they_Pron)
```
### --funs-of-arity
Show all functions of given arity (not up to).
Example:
```
> gftest -g Phrasebook --funs-of-arity 3
* Functions in the grammar of arity 3:
ADoVerbPhrasePlace
AModVerbPhrase
HowFarFromBy
QWhereModVerbPhrase
```
Development moved to https://github.com/GrammaticalFramework/gftest