forked from antononcube/MathematicaForPrediction
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTimeSeriesConversationalEngineGrammar.ebnf
63 lines (57 loc) · 4.42 KB
/
TimeSeriesConversationalEngineGrammar.ebnf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
(*
Time series conversational engine grammar in EBNF
Copyright (C) 2014 Anton Antonov
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Written by Anton Antonov,
antononcube @ gmail . com,
Windermere, Florida, USA.
*)
(* Version 1.0 *)
(* This grammar is intended to be parsed by the functions in the Mathematica package FunctionalParses.m at GitHub,
see https://github.com/antononcube/MathematicaForPrediction/blob/master/FunctionalParsers.m .
In order to parse this grammar specification either:
- copy all of the grammar rule lines and paste them within a pair of string quotes, or
- use Get in Mathematica.
*)
"
<preamble> = 'find' | 'compute' | 'calculate' | 'show' ;
<weather-spec-straight> = ( ( 'temperature' | 'pressure' | 'wind' , 'speed' ) <& ( 'of' | 'for' ) ) , <city-spec> <@ TSWeatherSpec[#]& ;
<weather-spec-reverse> = [ 'the' ] &> <city-spec> , ( 'temperature' | 'pressure' | 'wind' , 'speed' ) <@ TSWeatherSpec[Reverse[#]]& ;
<weather-spec> = <weather-spec-straight> | <weather-spec-reverse> ;
<city-spec> = '_LetterString' | '_LetterString' , [ ',' ] , '_LetterString' , [ [ ',' ] , '_LetterString' ] <@ TSCitySpec[Flatten[{#}]]& ;
<company-spec> = '_String' <@ TSCompanySpec ;
<finance-spec-straight> = ( [ 'the' ] &> ( [ 'stock' ] &> 'price' | 'trade' &> 'volume' ) <& [ 'of' | 'for' ] ) , <company-spec> <@ TSFinancialData ;
<finance-spec-reverse> = [ 'the' ] &> <company-spec> , ( [ 'stock' ] &> 'price' | 'trade' &> 'volume' ) <@ TSFinancialData[Reverse[#]]& ;
<finance-spec> = <finance-spec-straight> | <finance-spec-reverse> ;
<past-data-spec> = [ 'the' ] &> 'last' , [ 'loaded' ] , ( 'data' | 'file' ) <@ TSPastData[Flatten[{#}]]& ;
<data-spec> = <weather-spec> | <finance-spec> | <past-data-spec> ;
<regression-quantile-bsplines> = [ ( '1' | 'one' | 'a' ) ] , 'regression' , 'quantile' | 'quantile' , 'regression' <@ TSBSplineQRegression[1]& ;
<regression-quantiles-bsplines> = [ 'Range[1,40]' ] <& ( 'regression' , 'quantiles' ) <@ TSBSplineQRegression[#]& ;
<regression-quantiles> = <regression-quantile-bsplines> | <regression-quantiles-bsplines> ;
<outliers> = [ 'the' ] &> [ ( 'top' | 'bottom' | 'largest' | 'smallest' | 'all' ) ] , 'outliers' <@ TSOutliers[Flatten[#]]& ;
<least-squares> = ( 'least' , 'squares' , [ 'fit' ] , [ 'with' | 'of' ] ) &> '_String' <@ TSLeastSquaresFit[#]& ;
<operation-spec> = <regression-quantiles> | <least-squares> | <outliers> ;
<operate-command> = [ <preamble> ] &> <operation-spec> <@ TSOperateCommand[#]& ;
<operate-on-data-command> = <operate-command> , ( 'for' | 'on' | 'in' | 'over' | 'of' ) &> <data-spec> <@ TSOperateOnDataCommand[#]& ;
<load-file-command> = ( 'load' , [ 'data' ] , 'file' ) &> ( '_String' ) <@ TSLoadFile[#]& ;
<load-data-command> = ( 'load' , [ 'the' ] , [ 'data' ] ) &> <data-spec> <@ TSLoadData[#]& ;
<start-over> = 'start' , 'over' | 'clear' <@ TSStartOver[Flatten[{#}]]& ;
<clear-graphics> = 'clear' , ( 'plots' | 'plots' | 'graphics' ) <@ TSClearGraphics ;
<what-operations> = 'what' , ( ( 'operations' , 'are' | [ 'are' ] , [ 'the' ] , 'operations' ) , [ 'implemented' | 'in' ] ) | [ 'what' ] , ( 'operation' | 'operations' ) , ( 'I' , 'can' | 'to' ) , ( 'use' | 'do' ) <@ TSWhatOperations[Flatten[{#}]]& ;
<help-all> = 'help' | [ 'all' ] , 'commands' <@ TSHelp[Flatten[{#}]]& ;
<help> = <help-all> | <what-operations> ;
<plot-joined> = [ 'plot' | 'plots' ] , 'joined' | 'Joined' , '->' , 'True' | 'Joined->True' <@ TSPlotJoined ;
<plot-not-joined> = [ 'plot' | 'plots' ] , ( 'not' | 'non' ) , 'joined' | 'Joined' , '->' , 'False' | 'Joined->False' <@ TSPlotNotJoined ;
<plot-data> = 'plot' , 'data' <@ TSPlotData ;
<plot-command> = <plot-data> | <plot-joined> | <plot-not-joined> ;
<ts-command> = <load-data-command> | <load-file-command> | <operate-command> | <operate-on-data-command> | <clear-graphics> | <start-over> | <help> | <plot-command> ;
"