Skip to content

Commit

Permalink
✨ Support for Regression Task (#1)
Browse files Browse the repository at this point in the history
- Add support for regression task that parses either classification tasks or regression tasks
- Add test cases
- Rename test cases to follow a leading-0 pattern
  • Loading branch information
hayesall authored Aug 5, 2021
2 parents da8e97e + c6395b3 commit fa6e65f
Show file tree
Hide file tree
Showing 23 changed files with 662 additions and 104 deletions.
11 changes: 9 additions & 2 deletions cmd/ILPLang.g4
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,20 @@ fragment ALPHANUMERIC
| '_'
;

FLOAT: (DIGIT)* PERIOD (DIGIT)+ ;
INTEGER: (DIGIT)+ ;

start
: (term)* EOF
: (classification_task | regression_task) EOF
;

classification_task: (term)* ;
regression_task: (regression_term)* ;

// This recognizes both relations and entities.
// The grammar would be more generally useful if this recognized entities and
// relations on those entities.
OBJECT: (ALPHANUMERIC)+;

term: OBJECT LPAREN OBJECT (COMMA OBJECT)* RPAREN PERIOD NEWLINE;
term: OBJECT LPAREN OBJECT (COMMA (OBJECT | INTEGER))* RPAREN PERIOD NEWLINE;
regression_term: 'regressionExample' LPAREN OBJECT LPAREN OBJECT RPAREN COMMA (FLOAT | INTEGER) RPAREN PERIOD NEWLINE;
11 changes: 10 additions & 1 deletion cmd/parser/ILPLang.interp
Original file line number Diff line number Diff line change
@@ -1,25 +1,34 @@
token literal names:
null
'regressionExample'
'('
')'
','
'.'
null
null
null
null

token symbolic names:
null
null
LPAREN
RPAREN
COMMA
PERIOD
NEWLINE
FLOAT
INTEGER
OBJECT

rule names:
start
classification_task
regression_task
term
regression_term


atn:
[3, 24715, 42794, 33075, 47597, 16764, 15335, 30598, 22884, 3, 8, 29, 4, 2, 9, 2, 4, 3, 9, 3, 3, 2, 7, 2, 8, 10, 2, 12, 2, 14, 2, 11, 11, 2, 3, 2, 3, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 7, 3, 20, 10, 3, 12, 3, 14, 3, 23, 11, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3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 2, 2, 2, 10, 44, 3, 2, 2, 2, 12, 15, 5, 4, 3, 2, 13, 15, 5, 6, 4, 2, 14, 12, 3, 2, 2, 2, 14, 13, 3, 2, 2, 2, 15, 16, 3, 2, 2, 2, 16, 17, 7, 2, 2, 3, 17, 3, 3, 2, 2, 2, 18, 20, 5, 8, 5, 2, 19, 18, 3, 2, 2, 2, 20, 23, 3, 2, 2, 2, 21, 19, 3, 2, 2, 2, 21, 22, 3, 2, 2, 2, 22, 5, 3, 2, 2, 2, 23, 21, 3, 2, 2, 2, 24, 26, 5, 10, 6, 2, 25, 24, 3, 2, 2, 2, 26, 29, 3, 2, 2, 2, 27, 25, 3, 2, 2, 2, 27, 28, 3, 2, 2, 2, 28, 7, 3, 2, 2, 2, 29, 27, 3, 2, 2, 2, 30, 31, 7, 11, 2, 2, 31, 32, 7, 4, 2, 2, 32, 37, 7, 11, 2, 2, 33, 34, 7, 6, 2, 2, 34, 36, 9, 2, 2, 2, 35, 33, 3, 2, 2, 2, 36, 39, 3, 2, 2, 2, 37, 35, 3, 2, 2, 2, 37, 38, 3, 2, 2, 2, 38, 40, 3, 2, 2, 2, 39, 37, 3, 2, 2, 2, 40, 41, 7, 5, 2, 2, 41, 42, 7, 7, 2, 2, 42, 43, 7, 8, 2, 2, 43, 9, 3, 2, 2, 2, 44, 45, 7, 3, 2, 2, 45, 46, 7, 4, 2, 2, 46, 47, 7, 11, 2, 2, 47, 48, 7, 4, 2, 2, 48, 49, 7, 11, 2, 2, 49, 50, 7, 5, 2, 2, 50, 51, 7, 6, 2, 2, 51, 52, 9, 3, 2, 2, 52, 53, 7, 5, 2, 2, 53, 54, 7, 7, 2, 2, 54, 55, 7, 8, 2, 2, 55, 11, 3, 2, 2, 2, 6, 14, 21, 27, 37]
24 changes: 14 additions & 10 deletions cmd/parser/ILPLang.tokens
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
LPAREN=1
RPAREN=2
COMMA=3
PERIOD=4
NEWLINE=5
OBJECT=6
'('=1
')'=2
','=3
'.'=4
T__0=1
LPAREN=2
RPAREN=3
COMMA=4
PERIOD=5
NEWLINE=6
FLOAT=7
INTEGER=8
OBJECT=9
'regressionExample'=1
'('=2
')'=3
','=4
'.'=5
11 changes: 10 additions & 1 deletion cmd/parser/ILPLangLexer.interp
Original file line number Diff line number Diff line change
@@ -1,22 +1,29 @@
token literal names:
null
'regressionExample'
'('
')'
','
'.'
null
null
null
null

token symbolic names:
null
null
LPAREN
RPAREN
COMMA
PERIOD
NEWLINE
FLOAT
INTEGER
OBJECT

rule names:
T__0
LPAREN
RPAREN
COMMA
Expand All @@ -25,6 +32,8 @@ NEWLINE
DIGIT
SMALL_LETTER
ALPHANUMERIC
FLOAT
INTEGER
OBJECT

channel names:
Expand All @@ -35,4 +44,4 @@ mode names:
DEFAULT_MODE

atn:
[3, 24715, 42794, 33075, 47597, 16764, 15335, 30598, 22884, 2, 8, 45, 8, 1, 4, 2, 9, 2, 4, 3, 9, 3, 4, 4, 9, 4, 4, 5, 9, 5, 4, 6, 9, 6, 4, 7, 9, 7, 4, 8, 9, 8, 4, 9, 9, 9, 4, 10, 9, 10, 3, 2, 3, 2, 3, 3, 3, 3, 3, 4, 3, 4, 3, 5, 3, 5, 3, 6, 3, 6, 3, 7, 3, 7, 3, 8, 3, 8, 3, 9, 3, 9, 3, 9, 5, 9, 39, 10, 9, 3, 10, 6, 10, 42, 10, 10, 13, 10, 14, 10, 43, 2, 2, 11, 3, 3, 5, 4, 7, 5, 9, 6, 11, 7, 13, 2, 15, 2, 17, 2, 19, 8, 3, 2, 5, 3, 2, 12, 12, 3, 2, 50, 59, 3, 2, 99, 124, 2, 44, 2, 3, 3, 2, 2, 2, 2, 5, 3, 2, 2, 2, 2, 7, 3, 2, 2, 2, 2, 9, 3, 2, 2, 2, 2, 11, 3, 2, 2, 2, 2, 19, 3, 2, 2, 2, 3, 21, 3, 2, 2, 2, 5, 23, 3, 2, 2, 2, 7, 25, 3, 2, 2, 2, 9, 27, 3, 2, 2, 2, 11, 29, 3, 2, 2, 2, 13, 31, 3, 2, 2, 2, 15, 33, 3, 2, 2, 2, 17, 38, 3, 2, 2, 2, 19, 41, 3, 2, 2, 2, 21, 22, 7, 42, 2, 2, 22, 4, 3, 2, 2, 2, 23, 24, 7, 43, 2, 2, 24, 6, 3, 2, 2, 2, 25, 26, 7, 46, 2, 2, 26, 8, 3, 2, 2, 2, 27, 28, 7, 48, 2, 2, 28, 10, 3, 2, 2, 2, 29, 30, 9, 2, 2, 2, 30, 12, 3, 2, 2, 2, 31, 32, 9, 3, 2, 2, 32, 14, 3, 2, 2, 2, 33, 34, 9, 4, 2, 2, 34, 16, 3, 2, 2, 2, 35, 39, 5, 15, 8, 2, 36, 39, 5, 13, 7, 2, 37, 39, 7, 97, 2, 2, 38, 35, 3, 2, 2, 2, 38, 36, 3, 2, 2, 2, 38, 37, 3, 2, 2, 2, 39, 18, 3, 2, 2, 2, 40, 42, 5, 17, 9, 2, 41, 40, 3, 2, 2, 2, 42, 43, 3, 2, 2, 2, 43, 41, 3, 2, 2, 2, 43, 44, 3, 2, 2, 2, 44, 20, 3, 2, 2, 2, 5, 2, 38, 43, 2]
[3, 24715, 42794, 33075, 47597, 16764, 15335, 30598, 22884, 2, 11, 86, 8, 1, 4, 2, 9, 2, 4, 3, 9, 3, 4, 4, 9, 4, 4, 5, 9, 5, 4, 6, 9, 6, 4, 7, 9, 7, 4, 8, 9, 8, 4, 9, 9, 9, 4, 10, 9, 10, 4, 11, 9, 11, 4, 12, 9, 12, 4, 13, 9, 13, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 3, 3, 3, 3, 4, 3, 4, 3, 5, 3, 5, 3, 6, 3, 6, 3, 7, 3, 7, 3, 8, 3, 8, 3, 9, 3, 9, 3, 10, 3, 10, 3, 10, 5, 10, 63, 10, 10, 3, 11, 7, 11, 66, 10, 11, 12, 11, 14, 11, 69, 11, 11, 3, 11, 3, 11, 6, 11, 73, 10, 11, 13, 11, 14, 11, 74, 3, 12, 6, 12, 78, 10, 12, 13, 12, 14, 12, 79, 3, 13, 6, 13, 83, 10, 13, 13, 13, 14, 13, 84, 2, 2, 14, 3, 3, 5, 4, 7, 5, 9, 6, 11, 7, 13, 8, 15, 2, 17, 2, 19, 2, 21, 9, 23, 10, 25, 11, 3, 2, 5, 3, 2, 12, 12, 3, 2, 50, 59, 3, 2, 99, 124, 2, 88, 2, 3, 3, 2, 2, 2, 2, 5, 3, 2, 2, 2, 2, 7, 3, 2, 2, 2, 2, 9, 3, 2, 2, 2, 2, 11, 3, 2, 2, 2, 2, 13, 3, 2, 2, 2, 2, 21, 3, 2, 2, 2, 2, 23, 3, 2, 2, 2, 2, 25, 3, 2, 2, 2, 3, 27, 3, 2, 2, 2, 5, 45, 3, 2, 2, 2, 7, 47, 3, 2, 2, 2, 9, 49, 3, 2, 2, 2, 11, 51, 3, 2, 2, 2, 13, 53, 3, 2, 2, 2, 15, 55, 3, 2, 2, 2, 17, 57, 3, 2, 2, 2, 19, 62, 3, 2, 2, 2, 21, 67, 3, 2, 2, 2, 23, 77, 3, 2, 2, 2, 25, 82, 3, 2, 2, 2, 27, 28, 7, 116, 2, 2, 28, 29, 7, 103, 2, 2, 29, 30, 7, 105, 2, 2, 30, 31, 7, 116, 2, 2, 31, 32, 7, 103, 2, 2, 32, 33, 7, 117, 2, 2, 33, 34, 7, 117, 2, 2, 34, 35, 7, 107, 2, 2, 35, 36, 7, 113, 2, 2, 36, 37, 7, 112, 2, 2, 37, 38, 7, 71, 2, 2, 38, 39, 7, 122, 2, 2, 39, 40, 7, 99, 2, 2, 40, 41, 7, 111, 2, 2, 41, 42, 7, 114, 2, 2, 42, 43, 7, 110, 2, 2, 43, 44, 7, 103, 2, 2, 44, 4, 3, 2, 2, 2, 45, 46, 7, 42, 2, 2, 46, 6, 3, 2, 2, 2, 47, 48, 7, 43, 2, 2, 48, 8, 3, 2, 2, 2, 49, 50, 7, 46, 2, 2, 50, 10, 3, 2, 2, 2, 51, 52, 7, 48, 2, 2, 52, 12, 3, 2, 2, 2, 53, 54, 9, 2, 2, 2, 54, 14, 3, 2, 2, 2, 55, 56, 9, 3, 2, 2, 56, 16, 3, 2, 2, 2, 57, 58, 9, 4, 2, 2, 58, 18, 3, 2, 2, 2, 59, 63, 5, 17, 9, 2, 60, 63, 5, 15, 8, 2, 61, 63, 7, 97, 2, 2, 62, 59, 3, 2, 2, 2, 62, 60, 3, 2, 2, 2, 62, 61, 3, 2, 2, 2, 63, 20, 3, 2, 2, 2, 64, 66, 5, 15, 8, 2, 65, 64, 3, 2, 2, 2, 66, 69, 3, 2, 2, 2, 67, 65, 3, 2, 2, 2, 67, 68, 3, 2, 2, 2, 68, 70, 3, 2, 2, 2, 69, 67, 3, 2, 2, 2, 70, 72, 5, 11, 6, 2, 71, 73, 5, 15, 8, 2, 72, 71, 3, 2, 2, 2, 73, 74, 3, 2, 2, 2, 74, 72, 3, 2, 2, 2, 74, 75, 3, 2, 2, 2, 75, 22, 3, 2, 2, 2, 76, 78, 5, 15, 8, 2, 77, 76, 3, 2, 2, 2, 78, 79, 3, 2, 2, 2, 79, 77, 3, 2, 2, 2, 79, 80, 3, 2, 2, 2, 80, 24, 3, 2, 2, 2, 81, 83, 5, 19, 10, 2, 82, 81, 3, 2, 2, 2, 83, 84, 3, 2, 2, 2, 84, 82, 3, 2, 2, 2, 84, 85, 3, 2, 2, 2, 85, 26, 3, 2, 2, 2, 8, 2, 62, 67, 74, 79, 84, 2]
24 changes: 14 additions & 10 deletions cmd/parser/ILPLangLexer.tokens
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
LPAREN=1
RPAREN=2
COMMA=3
PERIOD=4
NEWLINE=5
OBJECT=6
'('=1
')'=2
','=3
'.'=4
T__0=1
LPAREN=2
RPAREN=3
COMMA=4
PERIOD=5
NEWLINE=6
FLOAT=7
INTEGER=8
OBJECT=9
'regressionExample'=1
'('=2
')'=3
','=4
'.'=5
18 changes: 18 additions & 0 deletions cmd/parser/ilplang_base_listener.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

77 changes: 49 additions & 28 deletions cmd/parser/ilplang_lexer.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 18 additions & 0 deletions cmd/parser/ilplang_listener.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit fa6e65f

Please sign in to comment.