>> >>> quit() Download and build Jython"> >> >>> quit() Download and build Jython">

Presentation is loading. Please wait.

Presentation is loading. Please wait.

Dr. Philip Cannata 1 with ReL. Dr. Philip Cannata 2 10 Java (Object Oriented) ASP RDF (Horn Clause Deduction, Semantic Web) Relation Jython in Java This.

Similar presentations


Presentation on theme: "Dr. Philip Cannata 1 with ReL. Dr. Philip Cannata 2 10 Java (Object Oriented) ASP RDF (Horn Clause Deduction, Semantic Web) Relation Jython in Java This."— Presentation transcript:

1 Dr. Philip Cannata 1 with ReL

2 Dr. Philip Cannata 2 10 Java (Object Oriented) ASP RDF (Horn Clause Deduction, Semantic Web) Relation Jython in Java This Course High Level Languages

3 Dr. Philip Cannata 3 svn co https://jython.svn.sourceforge.net/svnroot/jython/trunk/jython jythonhttps://jython.svn.sourceforge.net/svnroot/jython/trunk/jython ant. BUILD SUCCESSFUL Total time: 46 seconds dist/bin/jython Jython 2.6a0+ (trunk:7292M, Sep 25 2012, 21:48:21) [Java HotSpot(TM) 64-Bit Server VM (Apple Inc.)] on java1.6.0_33 Type "help", "copyright", "credits" or "license" for more information. >>> 1+2 3 >>> quit() Download and build Jython

4 Dr. Philip Cannata 4 A grammar file for the python language –./grammar/python.g Java classes that get instantiated as nodes on the Abstract Syntax Tree –./src/org/python/antlr/ast A way of printing the Abstract Syntax Tree –./dist/bin/jython ast/astview.py file.py Visitor classes for the interpreter –./org/python/antlr/ast/VisitorBase.java./org/python/antlr/ast/VisitorIF.java./org/python/antlr/Visitor.java A way to hook into the visitor’s process of setting up the runtime stack –./org/python/compiler/Code.java./org/python/compiler/CodeCompiler.java A way to work with the results from the jython interpreter – an example that we’ll use a lot is./org/python/core/PyTuple.java What would you expect to find in Jython

5 Dr. Philip Cannata 5 # Download ReL.zip from the class website to../../Download/ReL.zip cp -R../ReL/*. ant. BUILD SUCCESSFUL Total time: 46 seconds dist/bin/jython Jython 2.6a0+ (trunk:7292M, Sep 25 2012, 21:48:21) [Java HotSpot(TM) 64-Bit Server VM (Apple Inc.)] on java1.6.0_33 Type "help", "copyright", "credits" or "license" for more information. >>> 1+2 3 >>> quit() Overlay ReL code on top of Jython

6 Dr. Philip Cannata 6 ('body', ('BinOp (6,59)', ('left', ('Name (6,59)', ('id', 'x'), ('ctx', ('Load',)))), ('op', ('Add',)), ('right', ('Num (6,61)', ('n', 1))))))), ('args', ('Num (6,65)', ('n', 4))), ('keywords',), ('starargs', None), ('kwargs', None)), ('Name (6,69)', ('id', 'i'), ('ctx', ('Load',))), ('Name (6,72)', ('id', 'x'), ('ctx', ('Load',)))), ('ctx', ('Load',)))))), ('orelse',)), ('Print (7,0)', ('dest', None), ('values', ('Tuple (7,7)', ('elts',), ('ctx', ('Load',)))), ('nl', True)), ('Print (8,0)', ('dest', None), ('values', ('Tuple (8,7)', ('elts',), ('ctx', ('Load',)))), ('nl', True)), ('Print (9,0)', ('dest', None), ('values', ('Tuple (9,7)', ('elts', ('Name (9,52)', ('id', 'x'), ('ctx', ('Load',)))), ('ctx', ('Load',)))), ('nl', True)))) $ cat tests/demo.py ; dist/bin/jython ast/astview.py tests/demo.py MAKECONNECT URL jdbc:oracle:thin:@rising-sun.microlab.cs.utexas.edu:1521:orcl UNAME cs345_50 PWORD cs345_50p; DROP TABLE NEWTEST1; # CREATE TABLE NEWTEST1 (VAL1 NUMBER, VAL2 NUMBER, VAL3 NUMBER); x=3 for i in [2, 4, 7]: INSERT INTO NEWTEST1 (VAL1, VAL2, VAL3) VALUES ((lambda x:x+1) (4), i, x); print (SELECT * FROM NEWTEST1;) print (SELECT VAL2 FROM NEWTEST1;) print (SELECT VAL1, VAL2 FROM NEWTEST1 WHERE VAL3 = x;) ('Module', ('body', ('Expr (1,0)', ('value', ('Connection (1,0)', ('elts',), ('ctx', ('Load',))))), ('Expr (2,0)', ('value', ('Tuple (2,0)', ('elts',), ('ctx', ('Load',))))), ('Assign (4,0)', ('targets', ('Name (4,0)', ('id', 'x'), ('ctx', ('Store',)))), ('value', ('Num (4,2)', ('n', 3)))), ('For (5,0)', ('target', ('Name (5,4)', ('id', 'i'), ('ctx', ('Store',)))), ('iter', ('List (5,9)', ('elts', ('Num (5,10)', ('n', 2)), ('Num (5,13)', ('n', 4)), ('Num (5,16)', ('n', 7))), ('ctx', ('Load',)))), ('body', ('Expr (6,1)', ('value', ('Tuple (6,1)', ('elts', ('Call (6,49)', ('func', ('Lambda (6,50)', ('args', ('arguments', ('args', ('Name (6,57)', ('id', 'x'), ('ctx', ('Param',)))), ('vararg', None),jdbc:oracle:thin:@rising-sun.microlab.cs.utexas.edu:1521:orcl AST

7 Dr. Philip Cannata 7 MAKECONNECT – Python.g

8 Dr. Philip Cannata 8 MAKECONNECT– Python.g

9 Dr. Philip Cannata 9 MAKECONNECT– Python.g

10 Dr. Philip Cannata 10 MAKECONNECT– Python.g

11 Dr. Philip Cannata 11 MAKECONNECT– Python.g

12 Dr. Philip Cannata 12 MAKECONNECT– Python.g

13 Dr. Philip Cannata 13 Connection.java

14 Dr. Philip Cannata 14 Connection.java

15 Dr. Philip Cannata 15 VisitorBase.java

16 Dr. Philip Cannata 16 VisitorIF.java

17 Dr. Philip Cannata 17 Code.java

18 Dr. Philip Cannata 18 CodeCompiler.java

19 Dr. Philip Cannata 19 CodeCompiler.java

20 Dr. Philip Cannata 20 CodeCompiler.java

21 Dr. Philip Cannata 21 SELECT– Python.g

22 Dr. Philip Cannata 22 SELECT– Python.g

23 Dr. Philip Cannata 23 Tuple.java and PyTuple.java fjyswan files $ find. -type f -print./build.xml./extlibs/jsqlparser./extlibs/jsqlparser.jar./extlibs/META-INF./extlibs/ojdbc6.jar./fjyswanreadme.txt./grammar/Python.g./src/org/python/antlr/ast/Connection.java./src/org/python/antlr/ast/Tuple.java./src/org/python/antlr/ast/VisitorBase.java./src/org/python/antlr/ast/VisitorIF.java./src/org/python/compiler/Code.java./src/org/python/compiler/CodeCompiler.java./src/org/python/core/PyTuple.java./tests/astdemo.py./tests/demo.py

24 Dr. Philip Cannata 24 Tuple.java

25 Dr. Philip Cannata 25 Tuple.java

26 Dr. Philip Cannata 26 CodeCompiler.java

27 Dr. Philip Cannata 27 PyTuple.java

28 Dr. Philip Cannata 28 PyTuple.java

29 Dr. Philip Cannata 29 PyTuple.java

30 Dr. Philip Cannata 30 PyTuple.java

31 Dr. Philip Cannata 31 PyTuple.java Continues until line 319

32 Dr. Philip Cannata 32 $ dist/bin/jython tests/demo.py DROP TABLE NEWTEST1 INSERT INTO NEWTEST1 (VAL1, VAL2, VAL3) VALUES (5, 2, 3) INSERT INTO NEWTEST1_RDF_DATA VALUES (1, SDO_RDF_TRIPLE_S('NEWTEST1_CS345_RICK', 'www.example.org/NEWTEST1/1', 'www.example.org/NEWTEST1/VAL1', 'www.example.org/NEWTEST1/5')) INSERT INTO NEWTEST1_RDF_DATA VALUES (2, SDO_RDF_TRIPLE_S('NEWTEST1_CS345_RICK', 'www.example.org/NEWTEST1/1', 'www.example.org/NEWTEST1/VAL2', 'www.example.org/NEWTEST1/2')) INSERT INTO NEWTEST1_RDF_DATA VALUES (3, SDO_RDF_TRIPLE_S('NEWTEST1_CS345_RICK', 'www.example.org/NEWTEST1/1', 'www.example.org/NEWTEST1/VAL3', 'www.example.org/NEWTEST1/3')) INSERT INTO NEWTEST1 (VAL1, VAL2, VAL3) VALUES (5, 4, 3) INSERT INTO NEWTEST1_RDF_DATA VALUES (4, SDO_RDF_TRIPLE_S('NEWTEST1_CS345_RICK', 'www.example.org/NEWTEST1/2', 'www.example.org/NEWTEST1/VAL1', 'www.example.org/NEWTEST1/5')) INSERT INTO NEWTEST1_RDF_DATA VALUES (5, SDO_RDF_TRIPLE_S('NEWTEST1_CS345_RICK', 'www.example.org/NEWTEST1/2', 'www.example.org/NEWTEST1/VAL2', 'www.example.org/NEWTEST1/4')) INSERT INTO NEWTEST1_RDF_DATA VALUES (6, SDO_RDF_TRIPLE_S('NEWTEST1_CS345_RICK', 'www.example.org/NEWTEST1/2', 'www.example.org/NEWTEST1/VAL3', 'www.example.org/NEWTEST1/3')) INSERT INTO NEWTEST1 (VAL1, VAL2, VAL3) VALUES (5, 7, 3) INSERT INTO NEWTEST1_RDF_DATA VALUES (7, SDO_RDF_TRIPLE_S('NEWTEST1_CS345_RICK', 'www.example.org/NEWTEST1/3', 'www.example.org/NEWTEST1/VAL1', 'www.example.org/NEWTEST1/5')) INSERT INTO NEWTEST1_RDF_DATA VALUES (8, SDO_RDF_TRIPLE_S('NEWTEST1_CS345_RICK', 'www.example.org/NEWTEST1/3', 'www.example.org/NEWTEST1/VAL2', 'www.example.org/NEWTEST1/7')) INSERT INTO NEWTEST1_RDF_DATA VALUES (9, SDO_RDF_TRIPLE_S('NEWTEST1_CS345_RICK', 'www.example.org/NEWTEST1/3', 'www.example.org/NEWTEST1/VAL3', 'www.example.org/NEWTEST1/3'))www.example.org/NEWTEST1/1www.example.org/NEWTEST1/VALwww.example.org/NEWTEST1/5www.example.org/NEWTEST1/1www.example.org/NEWTEST1/VALwww.example.org/NEWTEST1/2www.example.org/NEWTEST1/1www.example.org/NEWTEST1/VALwww.example.org/NEWTEST1/3www.example.org/NEWTEST1/2www.example.org/NEWTEST1/VALwww.example.org/NEWTEST1/5www.example.org/NEWTEST1/2www.example.org/NEWTEST1/VALwww.example.org/NEWTEST1/4www.example.org/NEWTEST1/2www.example.org/NEWTEST1/VALwww.example.org/NEWTEST1/3 www.example.org/NEWTEST1/VALwww.example.org/NEWTEST1/5www.example.org/NEWTEST1/3www.example.org/NEWTEST1/VALwww.example.org/NEWTEST1/7www.example.org/NEWTEST1/3www.example.org/NEWTEST1/VALwww.example.org/NEWTEST1/3 Interpretation output

33 Dr. Philip Cannata 33 SELECT * FROM NEWTEST1 SELECT sub, pred, obj FROM TABLE(SEM_MATCH('(?sub ?pred ?obj)', SEM_Models('NEWTEST1_CS345_RICK'), null, SEM_ALIASES(SEM_ALIAS('','www.example.org/NEWTEST1/')), null)) (('SUB', 'PRED', 'OBJ'), ('www.example.org/NEWTEST1/1', 'www.example.org/NEWTEST1/VAL1', 'www.example.org/NEWTEST1/5'), ('www.example.org/NE WTEST1/1', 'www.example.org/NEWTEST1/VAL2', 'www.example.org/NEWTEST1/2'), ('www.example.org/NEWTEST1/1', 'www.example.org/NEWTEST1/VAL3', ' www.example.org/NEWTEST1/3'), ('www.example.org/NEWTEST1/2', 'www.example.org/NEWTEST1/VAL1', 'www.example.org/NEWTEST1/5'), ('www.example.o rg/NEWTEST1/2', 'www.example.org/NEWTEST1/VAL2', 'www.example.org/NEWTEST1/4'), ('www.example.org/NEWTEST1/2', 'www.example.org/NEWTEST1/VAL 3', 'www.example.org/NEWTEST1/3'), ('www.example.org/NEWTEST1/3', 'www.example.org/NEWTEST1/VAL1', 'www.example.org/NEWTEST1/5'), ('www.exam ple.org/NEWTEST1/3', 'www.example.org/NEWTEST1/VAL2', 'www.example.org/NEWTEST1/7'), ('www.example.org/NEWTEST1/3', 'www.example.org/NEWTEST 1/VAL3', 'www.example.org/NEWTEST1/3'))www.exampwww.example.org/NEWTEST1/1www.example.org/NEWTEST1/VAL1www.example.org/NEWTEST1/5www.example.org/NEwww.example.org/NEWTEST1/VAL2www.example.org/NEWTEST1/2www.example.org/NEWTEST1/1www.example.org/NEWTEST1/VAL3 www.example.org/NEWTEST1/3www.example.org/NEWTEST1/2www.example.org/NEWTEST1/VAL1www.example.org/NEWTEST1/5www.example.owww.example.org/NEWTEST1/VAL2www.example.org/NEWTEST1/4www.example.org/NEWTEST1/2www.example.org/NEWTEST1/VALwww.example.org/NEWTEST1/3 www.example.org/NEWTEST1/VAL1www.example.org/NEWTEST1/5www.examwww.example.org/NEWTEST1/VAL2www.example.org/NEWTEST1/7www.example.org/NEWTEST1/3www.example.org/NEWTESTwww.example.org/NEWTEST1/3 SELECT VAL2 FROM NEWTEST1 SELECT b FROM TABLE(SEM_MATCH('(?sub :VAL2 ?b)', SEM_Models('NEWTEST1_CS345_RICK'), null, SEM_ALIASES(SEM_ALIAS('','www.example.org/NEWTEST1/')), null)) (('B',), ('www.example.org/NEWTEST1/2',), ('www.example.org/NEWTEST1/4',), ('www.example.org/NEWTEST1/7',))www.example.org/NEWTEST1www.example.org/NEWTEST1/2www.example.org/NEWTEST1/4www.example.org/NEWTEST1/7 SELECT VAL1, VAL2 FROM NEWTEST1 WHERE VAL3 = 3 SELECT b, c FROM TABLE(SEM_MATCH('(?sub :VAL1 ?b) (?sub :VAL2 ?c) (?sub :VAL3 :3)', SEM_Models('NEWTEST1_CS345_RICK'), null, SEM_ALIASES(SEM_ALIAS('','www.example.org/NEWTEST1/')), null)) (('B', 'C'), ('www.example.org/NEWTEST1/5', 'www.example.org/NEWTEST1/4'), ('www.example.org/NEWTEST1/5', 'www.example.org/NEWTEST1/7'), ('w ww.example.org/NEWTEST1/5', 'www.example.org/NEWTEST1/2'))www.example.org/NEWTEST1/www.example.org/NEWTEST1/5www.example.org/NEWTEST1/4www.example.org/NEWTEST1/5www.example.org/NEWTEST1/7www.example.org/NEWTEST1/2 SQLSPARQL


Download ppt "Dr. Philip Cannata 1 with ReL. Dr. Philip Cannata 2 10 Java (Object Oriented) ASP RDF (Horn Clause Deduction, Semantic Web) Relation Jython in Java This."

Similar presentations


Ads by Google