Group Abstract Group Abstract

Message Boards Message Boards

Functional parsers (exemplified with an integration requests language)

GROUPS:
I implemented and uploaded a package for construction of functional parsers:
see : https://github.com/antononcube/MathematicaForPrediction/blob/master/FunctionalParsers.m

Here is a link to a slide show that gives an introduction to how the package is used:
https://github.com/antononcube/MathematicaForPrediction/blob/master/Documentation/Functional%20parsers%20for%20an%20integration%20requests%20language%20grammar.pdf
 
Here is the EBNF grammar of the integration requests language:
 <request-preamble> = 'compute' | 'what' , 'is' ;
 <compute> = <request-preamble> , [ 'the' ] ;
 <integral-type> = [ 'numerical' | 'symbolic' ] , 'integral' ;
 <integrate> = [ 'symbolically' | 'numerically' ] , 'integrate' | 'integrate' , ( 'numerically' | 'symbolically' ) ;
 <function> = '_String' ;
 <variable> = '_IdentifierString' ;
 <range-named> = 'R' | 'R+' | 'R-' ;
 <range-interval> = [ 'from' ] , '_WordString' , [ 'to' | 'and' ] , '_WordString';
 <range> = ( [ 'in' | 'over' ] , [ 'the' ] , [ 'interval' ] ) , ( <range-interval> | <range-named> ) ;
<var-range-spec> = ( 'for' | 'of' ) , <variable> , <range> ;
<integral-request> = <compute> , <integral-type> , 'of' ;
<command1> = ( <integral-request> | <integrate> ) , <function> , ( <var-range-spec> | <range> ) ;
<command2> = ( <integral-request> | <integrate> ) , <function> ;
<command> = <command1> | <command2> ;
The grammar can be represented with the following graph:

The mind map was hand made with MindNode Pro. Generally, the branches represent alternatives, but if two branches are connected the direction of the arrow connecting them shows a sequence combination.

The package provides functions for automatic generation of parsers from EBNF grammars.
The parsers are generated like this:
code = ToTokens[integrationGrammar];
GenerateParsersFromEBNF[code];

Here is a table with the interpretation of integration request commands:
POSTED BY: Anton Antonov
Answer
7 months ago
I just submitted this related blog post:
http://mathematicaforprediction.wordpress.com/2014/02/13/natural-language-processing-with-functional-parsers/ .
(Which probably has more details...)
POSTED BY: Anton Antonov
Answer
7 months ago