summaryrefslogtreecommitdiff
path: root/src/compiler/GF/Command
AgeCommit message (Collapse)Author
2016-06-09PGF service & minibar: only show dependency diagrams if the labels are knownhallgren
+ The PGF service now reads and caches dependency label configuration files. + The grammar info returned by command=grammar has a new boolean field 'hasDependencyLabels' to indicate if dependency labels were found for the grammar. Also, command=deptree will now fail if no labels are present. + The minibar only shows word dependency trees if labels are present. + Also changed the type of getDepLabels from [String] -> Labels to String -> Labels, since all uses were in the form "getDepLabels . lines".
2016-05-22Changes for compatibility with GHC 8.0.1hallgren
2016-04-07GF.Command.Commands2: adapt gf -cshell to the changes in the previous patchhallgren
2016-04-07GF shell: fix a parsing problem with the cc commandhallgren
This patch fixes a problem introduced last year when the GF shell was refactored to allow more commands to be treated uniformly and be part of pipes. The cc command was one of those commands, but unfortunately this introduced a parsing problem, e.g. > cc "last" constant not found: last > cc "last"++"year" command not parsed: cc "last"++"year" This happened because the generic command line parser in GF.Command.{Abstract,Parse} assumes that all commands have an argument of type PGF.Expr. Commands that expect other types of arguments have to use PGF.showExpr combined with other conversion to the argument type they expect. The cc command excpets a GF.Grammar.Term, and unfortunately not all terms survice the roundtrip through PGF.Expr, in part because of an additional hack to allow strings to be roundtripped through PGF.Expr without adding superfluous double quotes. To solve the problem, this patch + makes room for arguments of type Term in the Argument type in GF.Command.Abstract. + makes a special case for the cc command in GF.Command.Parse, by calling the partial parser 'runPartial pTerm' recently added in GF.Grammar.Lexer and GF.Grammar.Parser. Care was taken so that that "|" and ";" can be used both inside terms and as separators between commands in the shell, e.g. things like the following now work: > cc ("a"|"b") | ps -lexcode variants { "a" ; "b" } + introduces a type CommandArgument that replaces [Expr] as the type of values passed between commands in pipes. It has room for values of type [Expr], [String] and Term, thus eliminating the need to roundtrip through the Expr type all the time. The hack to avoid adding superfluous quotes when strings are roundtripped through Expr has been left in place for now, but can probably be removed.
2016-03-22fix the handling of separators in BNFC which are not nonemptykrasimir
2016-03-22CFGtoPGF is now extended to support context-free grammars with primitive ↵krasimir
parameters
2016-03-21initial support for BNFC syntax in context-free grammars for GF. Not all ↵krasimir
features are supported yet. Based on contribution from Gleb Lobanov
2016-02-23add lexer and unlexer for Ancient Greek accent normalizationleiss
2015-12-02GF shell, cc command: try to compute pre{...} tokens in token sequenceshallgren
This is implemented as a simple post-processing step after partial evaluation to try compute pre{...} tokens in token sequences. Nothing is done to deal with intervening free variants. This was done in response to a query from René T on the gf-dev mailing list.
2015-11-23vd -conll2latex now converts conll to latex. Without going through GF trees, ↵aarne
but as a service to the dependency parser community.
2015-11-17added -output=latex to visialize_dependencies. This generates more ↵aarne
familiar-looking output than the default graphviz, which can moreover be pasted into LaTeX documents. Some more work is needed to make long sentences look nice and fit on a page; a constant word length is now used to simplify computing the coordinates.
2015-11-05the visualization commands (aw,vd,vp,vt) can now show multiple trees. ↵aarne
Previously they only showed one tree even if there were for instance after ambiguous parsing. The reason was that dot (graphviz) ignored all graphs but the first one. Now the graphs are put into separate files. The 'convert' command from ImageMagick package is used to combine them to one pdf. If this is a problem, the old behaviour can be restored by the -number=1 option to the tree-generating command, which cuts away all trees but the one and doesn't require ImageMagick.
2015-11-05improved documentation of vp -showdepaarne
2015-11-04dependency labels in parse trees now with the -deps flag, -file=labels_file ↵aarne
for configuration. With -nocat option this shows reasonable dep trees, more familiar looking than the vd command. With -showfun flag, the tree gives a rather complete picture of the analysis of the sentence.
2015-11-04prepared visualize_parse for showing dependency labelsaarne
2015-09-28Preliminary new shell feature: cc -trace.hallgren
You can now do things like cc -trace mkV "debug" to see a trace of all opers with their arguments and results during the computation of mkV "debug".
2015-09-03GF shell: write_file now writes one tree per linehallgren
This compensates for other changes that removed line breaks. Maybe it should have a -lines options like ps and rf?
2015-08-28Comment out some dead code found with -fwarn-unused-bindshallgren
Also fixed some warnings and tightened some imports
2015-08-26GF shell: change parse & linearize to obtain useful results from p|l and l|p ↵hallgren
in more cases These changes are inspired by the gf -cshell implementation of these commands. The output of the linearize command has been changed to remove superfluous blank lines and commas, and deliver the result as a list of strings instead of a single multi-line string. This makes it possible to use -all and pipe the results to the parse command. This also means that with -treebank -all, the language tag will be repeated for each result from the same language. The parse command, when trying to parse with more than one language, would "forget" other results after a failed parse, and thus not send all successful parses through the pipe. For example, if English is not the first language in the grammar, p "hello" | l would output nothing, instead of translations of "hello" to all languages, forcing the user to write p -lang=Eng "hello" | l instead, to get the expected result. The cause of this behaviour was in the function fromParse, which was rather messy, so I assume it is not intentional, but the result of a programming mistake at some point. The fromParse function has now been refactored from a big recursive function into fromParse opts = foldr (joinPiped . fromParse1 opts) void where the helper functions fromParse1 deals with a single parse result and joinPiped combines multiple parse results.
2015-08-21GF shell bug fix: visualize_parse didn't accept the -lang flaghallgren
Even though the -lang flag was handled in the implementation, it was not documented, and GF.Command.Interpreter rejects undocumented flags: option not interpreted: lang This must be a fairly old bug, so it suggests that the vp command isn't used much...
2015-08-21GF -cshell: implement visualize_parsehallgren
Supported options and flags: -lang -format -view None of the rendering options available in the Haskell run-time are supported.
2015-08-21gf -cshell: implement visualize_treehallgren
But the following options are not supported: -mk -nocats -nofuns
2015-08-20gf -cshell: implement a subset of print_grammar and abstract_infohallgren
pg supports only the -funs, -cats and -langs output modes. ai IDENTIFIER shows info about a category or a function. ai can not type check and refine metavariables in expressions.
2015-08-18gf -cshell: linearize: implement options -all -list -treebankhallgren
Options -all and -list use PGF2.linearizeAll, which lists all variants, but not all forms... Also, there is no attempt to be compatible with the output from the Haskell run-rime shell, which produces superfluous blank lines (-all) or commas (-list), and mixes tagged and untagged lines (-treebank -all).
2015-08-18GF shell: restore the eh command to working order and document ithallgren
Also, when the command line parser fails, append the problematic command line to the error message "command not parsed".
2015-08-13GF Shell: refactoring for improved modularity and reusability:hallgren
+ Generalize the CommandInfo type by parameterizing it on the monad instead of just the environment. + Generalize the commands defined in GF.Command.{Commands,Commands2,CommonCommands,SourceCommands,HelpCommand} to work in any monad that supports the needed operations. + Liberate GF.Command.Interpreter from the IO monad. Also, move the current PGF from CommandEnv to GFEnv in GF.Interactive, making the command interpreter even more generic. + Use a state monad to maintain the state of the interpreter in GF.{Interactive,Interactive2}.
2015-08-12GF Shell: turn set_encoding into a common commandhallgren
Implemented in GF.Command.CommonCommands instead of GF.Interactive & GF.Interactive2.
2015-08-12GF shell: source commands (cc, sd, so, ss & dg) can now be used in pipeshallgren
These commands are now implemented as regular commands (i.e. using the CommandInfo data type) in the new module GF.Command.SourceCommands. The list of commands exported from GF.Command.Commmands now called pgfCommands instead of allCommands. The list allCommands of all commands is now assembled from sourceCommands, pgfCommands, commonCommands and helpCommand in GF.Interactive.
2015-08-12Move welcome message from GF.Interactive & GF.Interactive2 to ↵hallgren
GF.Command.Messages ...to avoid the duplication.
2015-08-11GF shell: make environment types abstract, comment out some dead codehallgren
2015-08-10gf -cshell: improved help for the 'import' commandhallgren
2015-08-10Factor out common code from GF.Command.Commands and GF.Command.Commands2hallgren
Created module GF.Command.CommonCommands with ~250 lines of code for commands that do not depend on the type of PGF in the environemnt, either because they don't use the PGF or because they are just documented here and implemented elsewhere. TODO: further refactoring so that documentation and implementation of *all* commands can be kept together.
2015-08-10gf -cshell: preliminary support for the C run-time system in the GF shellhallgren
Some C run-time functionality is now available in the GF shell, by starting GF with 'gf -cshell' or 'gf -crun'. Only limited functionality is available when running the shell in these modes: - You can only import .pgf files, not source files. - The -retain flag can not be used and the commands that require it to work are not available. - Only 18 of the 40 commands available in the usual shell have been implemented. The 'linearize' and 'parse' commands are the only ones that call the C run-time system, and they support only a limited set of options and flags. Use the 'help' commmands for details. - A new command 'generate_all', that calls PGF2.generateAll, has been added. Unfortuntaly, using it causes 'segmentation fault'. This is implemented by adding two new modules: GF.Command.Commands2 and GF.Interactive2. They are copied and modified versions of GF.Command.Commands and GF.Interactive, respectively. Code for unimplemented commands and other code that has not been adapted to the C run-time system has been left in place, but commented out, pending further work.
2015-08-10Refactor GF shell modules to improve modularity and reusabilityhallgren
+ Move type CommandInfo from GF.Command.Commands to a new module GF.Commands.CommandInfo and make it independent of the PGF type. + Make the module GF.Command.Interpreter independent of the PGF type and eliminate the import of GF.Command.Commands. + Move the implementation of the "help" command to its own module GF.Command.Help
2015-04-20drop the dependency to FSTkrasimir
2015-03-05remove some more old codekrasimir
2015-02-27GF shell: fixed problems with previous change of the -retain flaghallgren
Because the prompt included the name of the abstract syntax, the loading of the PGF was forced even if -retain was used. Even worse, if an error occured while loading the PGF, it was repeated and caught every time the prompt was printed, creating an infite loop. The solution is to not print the name of the abstract syntax when the grammar is imported with -retain, which is the way things were before anyway.
2014-11-10Documentation improvements and cleanup relating to the IOE monadhallgren
Renamed appIOE to tryIOE (it is analogous to 'try' in the standard libraries). Removed unused IOE operations & documented the remaining ones. Removed/simplified superfluous uses of IOE operations.
2014-10-22Various small changes for improved documentationhallgren
2014-10-19(un)lexmixed: added the other math environments than $ used in latexaarne
2014-10-17ps -lines preserves line-by-line structure when preprocessing files for ↵aarne
parsing line by line
2014-08-11a partial support for def rules in the C runtimekr.angelov
The def rules are now compiled to byte code by the compiler and then to native code by the JIT compiler in the runtime. Not all constructions are implemented yet. The partial implementation is now in the repository but it is not activated by default since this requires changes in the PGF format. I will enable it only after it is complete.
2014-07-28Convert from Text.PrettyPrint to GF.Text.Prettyhallgren
All compiler modules now use GF.Text.Pretty instead of Text.PrettyPrint
2014-07-27Introducing GF.Text.Pretty for more concise pretty printers and ↵hallgren
GF.Infra.Location for modularity GF.Text.Pretty provides the class Pretty and overloaded versions of the pretty printing combinators in Text.PrettyPrint, allowing pretty printable values to be used directly instead of first having to convert them to Doc with functions like text, int, char and ppIdent. Some modules have been converted to use GF.Text.Pretty, but not all. Precedences could be added to simplify the pretty printers for terms and patterns. GF.Infra.Location contains the types Location and L, factored out from GF.Grammar.Grammar, and the class HasSourcePath. This allowed the import of GF.Grammar.Grammar to be removed from GF.Infra.CheckM, making it more like a pure library module.
2014-06-12PGF library: expose only PGF and PGF.Internal instead of all moduleshallgren
PGF exports the public, stable API. PGF.Internal exports additional things needed in the GF compiler & shell, including the nonstardard version of Data.Binary.
2014-05-24now we compile context-free grammars directly to PGF without going via GF ↵kr.angelov
source code. This makes it quick and lightweight to compile big grammars such as the Berkley grammar
2014-03-21refactor the compilation of CFG and EBNF grammars. Now they are parsed by ↵kr.angelov
using GF.Grammar.Parser just like the ordinary GF grammars. Furthermore now GF.Speech.CFG is moved to GF.Grammar.CFG. The new module is used by both the speech conversion utils and by the compiler for CFG grammars. The parser for CFG now consumes a lot less memory and can be used with grammars with more than 4 000 000 productions.
2014-01-09Check file datestamp before creating PGF file when compiling grammarshallgren
When running a command like gf -make L_1.gf ... L_n.gf gf now avoids recreating the target PGF file if it already exists and is up-to-date. gf still reads all required .gfo files, so significant additional speed improvements are still possible. This could be done by reading .gfo files more lazily...
2013-12-06GF shell: fix help text for generate_treeshallgren
Trees are not generated with increasing depth.
2013-11-19GF shell: improved system_pipe (aka "?") commandhallgren
1. No temporary files are created. 2. The output of a system command is read lazily, making it feasible to process large or even infinite output, e.g. the following works as expected: ? "yes" | ? "head -5" | ps -lextext