diff --git a/doc/tutorial/gf-tutorial2.html b/doc/tutorial/gf-tutorial2.html index 9730526e2..bb6440ff4 100644 --- a/doc/tutorial/gf-tutorial2.html +++ b/doc/tutorial/gf-tutorial2.html @@ -7,7 +7,7 @@
+See +resource library documentation +
+See an +example built this way +
+Transfer means noncompositional tree-transforming operations.
+The command apply_transfer = at is typically used in a pipe:
+
+ > p "John walks and John runs" | apply_transfer aggregate | l + John walks and runs ++
+See the +sources of this example. +
++See the +transfer language documentation +for more information. +
+
+Lexers and unlexers can be chosen from
+a list of predefined ones, using the flags-lexer and `` -unlexer`` either
+in the grammar file or on the GF command line.
+
+Given by help -lexer, help -unlexer:
+
+ The default is words. + -lexer=words tokens are separated by spaces or newlines + -lexer=literals like words, but GF integer and string literals recognized + -lexer=vars like words, but "x","x_...","$...$" as vars, "?..." as meta + -lexer=chars each character is a token + -lexer=code use Haskell's lex + -lexer=codevars like code, but treat unknown words as variables, ?? as meta + -lexer=text with conventions on punctuation and capital letters + -lexer=codelit like code, but treat unknown words as string literals + -lexer=textlit like text, but treat unknown words as string literals + -lexer=codeC use a C-like lexer + -lexer=ignore like literals, but ignore unknown words + -lexer=subseqs like ignore, but then try all subsequences from longest + + The default is unwords. + -unlexer=unwords space-separated token list (like unwords) + -unlexer=text format as text: punctuation, capitals, paragraph <p> + -unlexer=code format as code (spacing, indentation) + -unlexer=textlit like text, but remove string literal quotes + -unlexer=codelit like code, but remove string literal quotes + -unlexer=concat remove all spaces + -unlexer=bind like identity, but bind at "&+" + ++ +
+Issues: +
+lincats
+optimize flag
+-mcfg vs. others
+
+Thespeak_aloud = sa command sends a string to the speech
+synthesizer
+Flite.
+It is typically used via a pipe:
+
+ generate_random | linearize | speak_aloud ++
+The result is only satisfactory for English. +
+
+The speech_input = si command receives a string from a
+speech recognizer that requires the installation of
+ATK.
+It is typically used to pipe input to a parser:
+
+ speech_input -tr | parse ++
+The method words only for grammars of English. +
++Both Flite and ATK are freely available through the links +above, but they are not distributed together with GF. +
+ ++The +Editor User Manual +describes the use of the editor, which works for any multilingual GF grammar. +
++Here is a snapshot of the editor: +
+
+
+
+The grammars of the snapshot are from the +Letter grammar package. +
-+Forthcoming. +
-+Other processes can communicate with the GF command interpreter, +and also with the GF syntax editor. +
++GF grammars can be used as parts of programs written in the +following languages. The links give more documentation. +
+ + +
+A summary is given in the following chart of GF grammar compiler phases:
+
+
+Formal and Informal Software Specifications, +PhD Thesis by +Kristofer Johannisson, is an extensive example of this. +The system is based on a multilingual grammar relating the formal language OCL with +English and German. +
++A simpler example will be explained here. +
diff --git a/doc/tutorial/gf-tutorial2.txt b/doc/tutorial/gf-tutorial2.txt index 72f3cce3a..48383e006 100644 --- a/doc/tutorial/gf-tutorial2.txt +++ b/doc/tutorial/gf-tutorial2.txt @@ -1530,13 +1530,20 @@ they can be used as arguments. For example: ===Resource grammars and their reuse=== +See +[resource library documentation ../../lib/resource/doc/gf-resource.html] + ===Interfaces, instances, and functors=== +See an +[example built this way ../../examples/mp3/mp3-resource.html] + ===Restricted inheritance and qualified opening=== + ==More concepts of abstract syntax== @@ -1546,14 +1553,22 @@ they can be used as arguments. For example: ===Semantic definitions=== -===Case study: grammars of formal languages=== - - - ==Transfer modules== +Transfer means noncompositional tree-transforming operations. +The command ``apply_transfer = at`` is typically used in a pipe: +``` + > p "John walks and John runs" | apply_transfer aggregate | l + John walks and runs +``` +See the +[sources ../../transfer/examples/aggregation] of this example. + +See the +[transfer language documentation ../transfer.html] +for more information. ==Practical issues== @@ -1561,18 +1576,120 @@ they can be used as arguments. For example: ===Lexers and unlexers=== +Lexers and unlexers can be chosen from +a list of predefined ones, using the flags``-lexer`` and `` -unlexer`` either +in the grammar file or on the GF command line. + +Given by ``help -lexer``, ``help -unlexer``: +``` + The default is words. + -lexer=words tokens are separated by spaces or newlines + -lexer=literals like words, but GF integer and string literals recognized + -lexer=vars like words, but "x","x_...","$...$" as vars, "?..." as meta + -lexer=chars each character is a token + -lexer=code use Haskell's lex + -lexer=codevars like code, but treat unknown words as variables, ?? as meta + -lexer=text with conventions on punctuation and capital letters + -lexer=codelit like code, but treat unknown words as string literals + -lexer=textlit like text, but treat unknown words as string literals + -lexer=codeC use a C-like lexer + -lexer=ignore like literals, but ignore unknown words + -lexer=subseqs like ignore, but then try all subsequences from longest + + The default is unwords. + -unlexer=unwords space-separated token list (like unwords) + -unlexer=text format as text: punctuation, capitals, paragraph+ -unlexer=code format as code (spacing, indentation) + -unlexer=textlit like text, but remove string literal quotes + -unlexer=codelit like code, but remove string literal quotes + -unlexer=concat remove all spaces + -unlexer=bind like identity, but bind at "&+" + +``` + ===Efficiency of grammars=== +Issues: + +- the choice of datastructures in ``lincat``s +- the value of the ``optimize`` flag +- parsing efficiency: ``-mcfg`` vs. others + ===Speech input and output=== +The``speak_aloud = sa`` command sends a string to the speech +synthesizer +[Flite http://www.speech.cs.cmu.edu/flite/doc/]. +It is typically used via a pipe: +``` generate_random | linearize | speak_aloud +The result is only satisfactory for English. + +The ``speech_input = si`` command receives a string from a +speech recognizer that requires the installation of +[ATK http://mi.eng.cam.ac.uk/~sjy/software.htm]. +It is typically used to pipe input to a parser: +``` speech_input -tr | parse +The method words only for grammars of English. + +Both Flite and ATK are freely available through the links +above, but they are not distributed together with GF. + + + + +===Multilingual syntax editor=== + +The +[Editor User Manual http://www.cs.chalmers.se/~aarne/GF2.0/doc/javaGUImanual/javaGUImanual.htm] +describes the use of the editor, which works for any multilingual GF grammar. + +Here is a snapshot of the editor: + +[../quick-editor.gif] + +The grammars of the snapshot are from the +[Letter grammar package http://www.cs.chalmers.se/~aarne/GF/examples/letter]. + + + +===Interactive Development Environment (IDE)=== + +Forthcoming. + ===Communicating with GF=== +Other processes can communicate with the GF command interpreter, +and also with the GF syntax editor. + ===Embedded grammars in Haskell, Java, and Prolog=== +GF grammars can be used as parts of programs written in the +following languages. The links give more documentation. + +- [Java http://www.cs.chalmers.se/~bringert/gf/gf-java.html] +- [Haskell http://www.cs.chalmers.se/~aarne/GF/src/GF/Embed/EmbedAPI.hs] +- [Prolog http://www.cs.chalmers.se/~peb/software.html] + ===Alternative input and output grammar formats=== +A summary is given in the following chart of GF grammar compiler phases: +[../gf-compiler.png] + + +==Case studies== + +===Interfacing formal and natural languages=== + +[Formal and Informal Software Specifications http://www.cs.chalmers.se/~krijo/thesis/thesisA4.pdf], +PhD Thesis by +[Kristofer Johannisson http://www.cs.chalmers.se/~krijo], is an extensive example of this. +The system is based on a multilingual grammar relating the formal language OCL with +English and German. + +A simpler example will be explained here. + diff --git a/src/GF/UseGrammar/Morphology.hs b/src/GF/UseGrammar/Morphology.hs index 8b9935c23..2d96ecd77 100644 --- a/src/GF/UseGrammar/Morphology.hs +++ b/src/GF/UseGrammar/Morphology.hs @@ -71,7 +71,7 @@ mkMorpho gr a = tcompile $ concatMap mkOne $ allItems where -- gather forms of lexical items allLins fun@(m,f) = errVal [] $ do - ts <- allLinsOfFun gr (CIQ a f) + ts <- lookupLin gr (CIQ a f) >>= comp >>= allAllLinValues ss <- mapM (mapPairsM (mapPairsM (liftM wordsInTerm . comp))) ts return [(p,s) | (p,fs) <- concat $ map snd $ concat ss, s <- fs] prOne (_,f) c (ps,s) = (s, [prt f +++ tagPrt c +++ unwords (map prt_ ps)])