Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
resarch:nlpa:preethaprelims [2015/08/02 16:07] preethac |
resarch:nlpa:preethaprelims [2016/06/23 00:32] (current) preethac |
||
---|---|---|---|
Line 1358: | Line 1358: | ||
; ... | ; ... | ||
; | ; | ||
+ | |||
+ | Instead of using temporary storage to share data between event methods(like in implementation of listeners/visitors), we can store those values in the parse tree itself. | ||
Temporarily works if following changes made in grammar file(but supposedly not correct) | Temporarily works if following changes made in grammar file(but supposedly not correct) | ||
Line 1889: | Line 1891: | ||
\\ Margin should be 1 inch on left and right -done | \\ Margin should be 1 inch on left and right -done | ||
\\ Change verbs in project steps - done | \\ Change verbs in project steps - done | ||
- | \\ after first line cite quorum website, say how many blind prog are there(to be found somewhere in his website), refer to his paper. | + | \\ after first line cite quorum website, say how many blind prog are there(to be found somewhere in his website), refer to his paper.-done |
- | \\ at the end, before the reference, present a summary of results , how it would help programmers,etc | + | \\ at the end, before the reference, present a summary of results , how it would help programmers,etc-done |
+ | \\ Sent for 2nd review to Dr. Pollock. | ||
+ | \\ Added Sakai site for PhD Prelims. | ||
**Application on Quorum:** | **Application on Quorum:** | ||
Line 1944: | Line 1948: | ||
import java.io.*; | import java.io.*; | ||
import java.util.Map; | import java.util.Map; | ||
- | + | public class TestQuorumFile { | |
- | public class TestQuorumFile { | + | public static class QuorumFileLoader extends QuorumBaseListener { |
- | public static class QuorumFileLoader extends QuorumBaseListener { | + | //Map<String,String> props = new OrderedHashMap<String, String>(); |
- | // Map<String,String> props = new OrderedHashMap<String, String>(); | + | |
public String value; | public String value; | ||
public void exitPrint_statement(QuorumParser.Print_statementContext ctx) { | public void exitPrint_statement(QuorumParser.Print_statementContext ctx) { | ||
- | // String id = ctx.getText(); | + | //String id = ctx.getText(); |
- | // String value = ctx.getText(); | + | //String value = ctx.getText(); |
- | // props.put(id, value); | + | //props.put(id, value); |
value = ctx.getText(); | value = ctx.getText(); | ||
} | } | ||
} | } | ||
- | |||
public static void main(String[] args) throws Exception { | public static void main(String[] args) throws Exception { | ||
String inputFile = null; | String inputFile = null; | ||
Line 1971: | Line 1973: | ||
ParseTree tree = parser.start(); // begin parsing at start rule | ParseTree tree = parser.start(); // begin parsing at start rule | ||
System.out.println("\nParse tree is:\n"+tree.toStringTree(parser)); | System.out.println("\nParse tree is:\n"+tree.toStringTree(parser)); | ||
- | |||
// create a standard ANTLR parse tree walker | // create a standard ANTLR parse tree walker | ||
ParseTreeWalker walker = new ParseTreeWalker(); | ParseTreeWalker walker = new ParseTreeWalker(); | ||
Line 1977: | Line 1978: | ||
QuorumFileLoader loader = new QuorumFileLoader(); | QuorumFileLoader loader = new QuorumFileLoader(); | ||
walker.walk(loader, tree); // walk parse tree | walker.walk(loader, tree); // walk parse tree | ||
- | //System.out.println(loader.props); // print results | + | //System.out.println(loader.props); // print results |
System.out.println("\nInput is: \n"+loader.value); // print results | System.out.println("\nInput is: \n"+loader.value); // print results | ||
} | } | ||
Line 1994: | Line 1995: | ||
output"Hello" | output"Hello" | ||
+ | **Implementing listener and walking a parse tree on Quorum loop-if statement:** | ||
+ | import org.antlr.v4.misc.OrderedHashMap; | ||
+ | import org.antlr.v4.runtime.*; | ||
+ | import org.antlr.v4.runtime.tree.*; | ||
+ | import java.io.*; | ||
+ | import java.util.Map; | ||
+ | public class TestQuorumFileNew { | ||
+ | public static class QuorumFileLoader extends QuorumBaseListener | ||
+ | { | ||
+ | // Map<String,String> props = new OrderedHashMap<String, String>(); | ||
+ | public String value1; | ||
+ | public String value2; | ||
+ | public String value3,value4,value5,value6; | ||
+ | public void exitPrint_statement(QuorumParser.Print_statementContext ctx) | ||
+ | { | ||
+ | // String id = ctx.getText(); | ||
+ | // String value = ctx.getText(); | ||
+ | // props.put(id, value); | ||
+ | value1 = ctx.getText(); | ||
+ | } | ||
+ | public void exitIf_statement(QuorumParser.If_statementContext ctx) | ||
+ | { | ||
+ | value2 = ctx.getText(); | ||
+ | value5 = ctx.block().getText(); | ||
+ | System.out.println("\nParent is:" +ctx.getParent());//not sure what the output means | ||
+ | System.out.println("\nChild of if statement is:" +ctx.getChild(0)); | ||
+ | //System.out.println("Object of if statement is:"+ctx.value()); //gives error | ||
+ | //System.out.println("Object of if statement is:"+ctx.object()); //gives error | ||
+ | } | ||
+ | public void exitLoop_statement(QuorumParser.Loop_statementContext ctx) | ||
+ | { | ||
+ | value3 = ctx.getText(); | ||
+ | value4 = ctx.expression().getText(); | ||
+ | value6 = ctx.block().getText(); | ||
+ | System.out.println("\nChild of loop statement is:" +ctx.getChild(4)); | ||
+ | } | ||
+ | public void visitTerminal(TerminalNode node) | ||
+ | { | ||
+ | Token symbol = node.getSymbol(); | ||
+ | // System.out.println(node); | ||
+ | if ( symbol.getType()==QuorumParser.IF ) | ||
+ | { | ||
+ | System.out.println("\nTerminal node is: "+symbol); | ||
+ | } | ||
+ | // { | ||
+ | // stack.push( Integer.valueOf(symbol.getText()) ); | ||
+ | // } | ||
+ | } | ||
+ | } | ||
+ | public static void main(String[] args) throws Exception { | ||
+ | String inputFile = null; | ||
+ | if ( args.length>0 ) inputFile = args[0]; | ||
+ | InputStream is = System.in; | ||
+ | if ( inputFile!=null ) { | ||
+ | is = new FileInputStream(inputFile); | ||
+ | } | ||
+ | ANTLRInputStream input = new ANTLRInputStream(is); | ||
+ | QuorumLexer lexer = new QuorumLexer(input); | ||
+ | CommonTokenStream tokens = new CommonTokenStream(lexer); | ||
+ | QuorumParser parser = new QuorumParser(tokens); | ||
+ | ParseTree tree = parser.start(); // begin parsing at start rule | ||
+ | System.out.println("\nParse tree is:\n"+tree.toStringTree(parser)); | ||
+ | // create a standard ANTLR parse tree walker | ||
+ | ParseTreeWalker walker = new ParseTreeWalker(); | ||
+ | // create listener then feed to walker | ||
+ | QuorumFileLoader loader = new QuorumFileLoader(); | ||
+ | walker.walk(loader, tree); // walk parse tree | ||
+ | System.out.println("\nInside Print Statement: \n"+loader.value1); // print results | ||
+ | System.out.println("\nInside If Statement: \n"+loader.value2); // print results | ||
+ | System.out.println("\nInside Loop Statement: \n"+loader.value3); // print results | ||
+ | System.out.println("\nBlock Inside Loop Statement: \n"+loader.value6); // print results | ||
+ | } | ||
+ | } | ||
+ | |||
+ | Preethas-MacBook-Pro:Antlr preethac$ javac TestQuorumFileNew.java Quorum*.java | ||
+ | Preethas-MacBook-Pro:Antlr preethac$ java TestQuorumFileNew qnew.properties | ||
+ | Parse tree is: | ||
+ | (start (class_declaration (no_class_stmnts (statement (loop_statement repeat while (expression (expression (action_call index)) < (expression 256)) (block (statement (assignment_statement (assignment_declaration text) name = (expression (action_call ToText ( (function_expression_list (expression (action_call index))) ))))) (statement (if_statement if (expression (expression (action_call name)) not= (expression undefined)) (block (statement (solo_method_call keyNames : (solo_method_required_method_part put ( (function_expression_list (expression (action_call index)) , (expression (action_call index))) ))))) end))) end)))) <EOF>) | ||
+ | Terminal node is: [@22,71:72='if',<58>,3:8] | ||
+ | Parent is:[212 425 221 123 120 96] | ||
+ | Child of if statement is:if | ||
+ | Child of loop statement is:end | ||
+ | Inside Print Statement: null | ||
+ | Inside If Statement: ifnamenot=undefinedkeyNames:put(index,index)end | ||
+ | Inside Loop Statement: repeatwhileindex<256textname=ToText(index)ifnamenot=undefinedkeyNames:put(index,index)endend | ||
+ | Block Inside Loop Statement: textname=ToText(index)ifnamenot=undefinedkeyNames:put(index,index)end | ||
+ | |||
+ | Update on Aug 18,2015: | ||
+ | \\ Code (to generate feature vectors and identify action from a Quorum sample code) is ready. | ||
+ | \\ Next step is to do further testing on the code for accuracy - Completed | ||
+ | \\ **Results - Testing of tool on identified Quorum loop-ifs:** | ||
+ | |||
+ | |||
+ | * Feature Vector: F1:1, F2:0, F3:0, F4:2, F5:4, F6:0, F7:0, F8:2 | ||
+ | * Action Identified: find | ||
+ | * Feature Vector: F1:5, F2:1, F3:0, F4:2, F5:0, F6:0, F7:0, F8:2 | ||
+ | * Action Identified: get | ||
+ | * Feature Vector: F1:1, F2:0, F3:0, F4:2, F5:0, F6:0, F7:0, F8:2 | ||
+ | * Action Identified: could not be identified(no entry in action identification table) | ||
+ | * Feature Vector: F1:5, F2:ResolveAllTypes(), F3:0, F4:2, F5:0, F6:0, F7:0, F8:2 | ||
+ | * Action Identified: not identified as method name not listed in action identification table | ||
+ | * Feature Vector: F1:4, F2:ResolveClass(), F3:0, F4:2, F5:0, F6:0, F7:0, F8:2 | ||
+ | * Action Identified: Not identified as method name not listed in action identification table | ||
+ | * Feature Vector: 1,0,0,2,0,0,0,2 Action Identified: not identified | ||
+ | * Feature Vector: F1:1, F2:0, F3:0, F4:2, F5:0, F6:0, F7:0, F8:2 | ||
+ | * Action Identified: Not identified(no entry in action identification table) | ||
+ | * Feature Vector: F1:5, F2:VisitLocalVariable(), F3:0, F4:2, F5:0, F6:0, F7:0, F8:2 | ||
+ | * Action Identified: Not identified(as method name not listed in action identification model) | ||
+ | * Feature Vector: F1:1, F2:0, F3:0, F4:2, F5:0, F6:0, F7:0, F8:2 | ||
+ | * Action Identified: Not identified(no entry in action identification table) | ||
+ | * Feature Vector: F1:1, F2:0, F3:0, F4:0, F5:0, F6:0, F7:0, F8:2 | ||
+ | * Action Identified: Not identified (no entry in action identification table) | ||
+ | * Multiple ifs, loop discarded. | ||
+ | * Feature Vector: F1:5, F2:1, F3:0, F4:2, F5:0, F6:0, F7:0, F8:2 | ||
+ | * Action Identified: get | ||
+ | * Feature Vector: F1:5, F2:AssignBytecodeLocations(), F3:0, F4:2, F5:0, F6:0, F7:0, F8:2 | ||
+ | * Action Identified: not identified | ||
+ | * Feature Vector: F1:5, F2:1, F3:0, F4:2, F5:0, F6:0, F7:0, F8:2 | ||
+ | * Action Identified: get | ||
+ | * Feature Vector: F1:5, F2:1, F3:0, F4:2, F5:0, F6:0, F7:0, F8:1 (as we consider only the if loop and it's last statement) | ||
+ | * Action Identified: get | ||
+ | * Feature Vector: F1:5, F2:VisitEnd(), F3:0, F4:2, F5:0, F6:0, F7:0, F8:2 | ||
+ | * Action Identified: cannot be determined as method name not listed in action identification table | ||
+ | * Feature Vector: F1:4, F2:WriteParentActionBytecode(), F3:0, F4:2, F5:0, F6:1, F7:0, F8:2 | ||
+ | * Action Identified: cannot be determined as method name not listed in action identification table | ||
+ | * Feature Vector: F1:5, F2:VisitEnd(), F3:0, F4:2, F5:0, F6:0, F7:0, F8:2 | ||
+ | * Action Identified: cannot be determined as method name not listed in action identification table | ||
+ | * Feature Vector: F1:5, F2: undefined, F3:0, F4:2, F5:0, F6:0, F7:0, F8:2 | ||
+ | * Action Identified: cannot be determined | ||
+ | * Feature Vector: F1:1, F2:0, F3:0, F4:2, F5:0, F6:0, F7:0, F8:2 | ||
+ | * Action Identified: not identified as corresponding entry not found in action identification table | ||
+ | * Feature Vector: F1:1, F2:0, F3:0, F4:0, F5:0, F6:0, F7:0, F8:1 | ||
+ | * Action Identified: not identified | ||
+ | * Feature Vector: F1:5, F2:1, F3:0, F4:0, F5:0, F6:0, F7:0, F8:2 | ||
+ | * Action Identified: Not identified | ||
+ | * Feature Vector: F1:0, F2:0, F3:0, F4:0, F5:3, F6:0, F7:0, F8:2 | ||
+ | * Action Identified: determine | ||
+ | * Feature Vector: F1:4, F2:5, F3:0, F4:1, F5:3, F6:0, F7:0, F8:2 | ||
+ | * Action Identified: could not be identified | ||
+ | * Feature Vector: F1:3, F2:0, F3:0, F4:0, F5:0, F6:0, F7:0, F8:2 | ||
+ | * Action Identified: could not be identified | ||
+ | * Feature Vector: F1:0, F2:0, F3:0, F4:0, F5:4, F6:1, F7:0, F8:2 | ||
+ | * Action Identified: find | ||
+ | * Feature Vector: F1:0, F2:0, F3:0, F4:0, F5:3, F6:1, F7:0, F8:2 | ||
+ | * Action Identified: determine | ||
+ | * Feature Vector: F1:6, F2:0, F3:0, F4:0, F5:0, F6:0, F7:0, F8:2 | ||
+ | * Action Identified: determine | ||
+ | * Feature Vector: F1:6, F2:0, F3:0, F4:0, F5:0, F6:0, F7:0, F8:2 | ||
+ | * Action Identified: determine | ||
+ | * Feature Vector: F1:0, F2:0, F3:0, F4:0, F5:3, F6:0, F7:0, F8:2 | ||
+ | * Action Identified: determine | ||
+ | * (a) Feature Vector: F1:4, F2:5, F3:0, F4:1, F5:3, F6:0, F7:0, F8:2 | ||
+ | * Action Identified: not identified (b) Feature Vector: F1:6, F2:0, F3:0, F4:0, F5:0, F6:0, F7:0, F8:2 Action Identified: determine | ||
+ | * Feature Vector: F1:0, F2:0, F3:0, F4:0, F5:3, F6:0, F7:0, F8:2 | ||
+ | * Action Identified: determine | ||
+ | * Feature Vector: F1:1, F2:0, F3:0, F4:2, F5:4, F6:0, F7:0, F8:2 | ||
+ | * Action Identified: find | ||
+ | * Feature Vector: F1:0, F2:0, F3:0, F4:0, F5:3, F6:0, F7:0, F8:2 | ||
+ | * Action Identified: determine | ||
+ | * Feature Vector: F1:0, F2:0, F3:0, F4:0, F5:3, F6:0, F7:0, F8:2 | ||
+ | * Action Identified: determine | ||
+ | * Feature Vector: F1:0, F2:0, F3:0, F4:0, F5:4, F6:0, F7:0, F8:2 | ||
+ | * Action Identified: find. | ||
+ | * Feature Vector: F1:0, F2:0, F3:0, F4:0, F5:4, F6:0, F7:0, F8:2 | ||
+ | * Action Identified: find | ||
+ | * Feature Vector: F1:5, F2:3, F3:0, F4:1, F5:0, F6:0, F7:0, F8:2 | ||
+ | * Action Identified: not identified | ||
+ | * | ||
+ | \\ **Outline of prelims report** | ||
+ | \\ 1. Introduction | ||
+ | \\ 2. Contributions | ||
+ | \\ 3. "Developing of Model of Loop Actions" | ||
+ | \\ Cite Xiaoran's paper, Summary of that paper, can use Fig:1 from that paper and the limitations of the model | ||
+ | \\ 4. Quorum Language | ||
+ | \\ Introduction, Loop Structures | ||
+ | \\ 5. Java to Quorum(Something like that) | ||
+ | \\ In general how to do | ||
+ | \\ Challenges in doing this for Quorum | ||
+ | \\ Research Process/Methodology - Examples, Algorithms, Pictures, ANTLR-how used, parse trees, what changes for each feature vector-syntactic or semantic | ||
+ | \\ 6. Results- Accuracy, evaluation by Xiaoran(author of that paper) | ||
+ | \\ 7. Discussion - Implications of results, how general is the process, how easy to apply to other languages. | ||
+ | \\ 8. Threats to Validity(My limitations of this project) | ||
+ | \\ Less no. of Quorum programs | ||
+ | \\ Less variety of loops | ||
+ | \\ Code form developers of Quorum is used, other programmers' code not available yet. | ||
+ | \\ To minimize the threats:- | ||
+ | \\ a. Collected as many Quorum loops as possible. | ||
+ | \\ b. Real code examples are used, and not sample ones. | ||
+ | \\ c.Could be a future work- to check how our tool works on unseen code from other programmers. | ||
+ | |||
+ | \\ As per department instructions - The written report should not exceed 20 pages in length, and should be structured as a scientific publication, including: Title, Abstract, Introduction, Related Work, appropriate sections that describe the work conducted, the methods used and the results obtained, followed by Analysis/Conclusions and Future Work. The report must also contain a bibliography which is not included in the 20 pages length limit. The first page of the report must include the student name, the title of the work, and the names of the advisor and the committee member. | ||
+ | |||
+ | \\ Tested the tool on standard library test files (This is separate from the initial set of loop-ifs used for the project) | ||
+ | \\ Out of identified 13 loop-ifs, actions were identified for 3 loop-ifs- all three were MAX/MIN. | ||
+ | \\ For rest of the 10 loop-ifs, no actions were identified. | ||
+ | \\ Details of loop code and feature vector values attached.{{:resarch:nlpa:testing_the_tool_on_standard_library_test_files.pdf|}} | ||
+ | |||
+ | [[https://bitbucket.org/udsenlpa/quorum_actionunit_identifier/wiki/Home|Bitbucket Link to Source Code]] |