Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Eclipse maven #1

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions input/expression.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
i plus plus
i equals to 2
10 changes: 6 additions & 4 deletions input/function.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
I want to create a function
create a function
create a function called fibonacci
create a function with int n
create a function called fibonacci that returns an int
create function called fibonacci that returns an int
set x to a plus b
i plus plus
set i to i plus plus
set a to a plus b minus c plus d
set a to result of b plus c times a
17 changes: 17 additions & 0 deletions language_packs/java_syntax.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#plus +
#minus -
#multiply *
#divide /
#less_than <
#greater_than >
#equal ==
#less_equal <=
#greater_equal >=
#not_equal !=
#or ||
#and &&
#bit_and &
#bit_or |
#bit_xor ^
#mod %
#plus_equal +=
Binary file added lib/jwnl-1.3.3.jar
Binary file not shown.
Binary file added lib/opennlp-maxent-3.0.3.jar
Binary file not shown.
Binary file added lib/opennlp-tools-1.5.3.jar
Binary file not shown.
Binary file added lib/opennlp-uima-1.5.3.jar
Binary file not shown.
125 changes: 86 additions & 39 deletions log/log.txt
Original file line number Diff line number Diff line change
@@ -1,47 +1,94 @@
[Sentence] create a function
Creating function
Relations
function(NN) with a(DT) has relation det
create(VB) with function(NN) has relation dobj
No function name found
No function parameters found
[Sentence] create a function called fibonacci
Creating function
Relations
[Sentence] I want to create a function

want(VBP) with I(PRP) has relation nsubj

create(VB) with to(TO) has relation mark

want(VBP) with create(VB) has relation xcomp

function(NN) with a(DT) has relation det

create(VB) with function(NN) has relation dobj
function(NN) with called(VBN) has relation acl
called(VBN) with fibonacci(NNS) has relation dobj
No function parameters found
[Sentence] create a function with int n

[Sentence] create a function

Creating function
Relations
function(NN) with a(DT) has relation det

create(VB) with function(NN) has relation dobj
n(NN) with with(IN) has relation case
n(NN) with int(NN) has relation compound
create(VB) with n(NN) has relation nmod:with

No function name found
[Sentence] create a function called fibonacci that returns an int
Creating function
Relations
function(NN) with a(DT) has relation det
create(VB) with function(NN) has relation dobj
function(NN) with called(VBN) has relation acl
called(VBN) with fibonacci(NNS) has relation dobj
returns(VBZ) with that(WDT) has relation nsubj
fibonacci(NNS) with returns(VBZ) has relation acl:relcl
int(NN) with an(DT) has relation det
returns(VBZ) with int(NN) has relation dobj
No function parameters found
[Sentence] create function called fibonacci that returns an int
Creating function
Relations
create(VB) with function(NN) has relation dobj
function(NN) with called(VBN) has relation acl
called(VBN) with fibonacci(NNS) has relation dobj
returns(VBZ) with that(WDT) has relation nsubj
fibonacci(NNS) with returns(VBZ) has relation acl:relcl
int(NN) with an(DT) has relation det
returns(VBZ) with int(NN) has relation dobj
No function parameters found
[Sentence] set x to a plus b

set(VBN) with x(NN) has relation dobj

a(DT) with to(TO) has relation case

set(VBN) with a(DT) has relation nmod:to

b(NN) with plus(CC) has relation case

a(DT) with b(NN) has relation nmod:plus

[Sentence] i plus plus

i(LS) with plus(CC) has relation advmod

i(LS) with plus(CC) has relation advmod

[Sentence] set i to i plus plus

set(VBN) with i(FW) has relation dobj

i(FW) with to(TO) has relation case

set(VBN) with i(FW) has relation nmod:to

i(FW) with plus(CC) has relation advmod

set(VBN) with plus(CC) has relation advmod

[Sentence] set a to a plus b minus c plus d

b(NN) with a(DT) has relation dep

b(NN) with to(TO) has relation case

b(NN) with a(DT) has relation det

b(NN) with plus(CC) has relation advmod

set(VBN) with b(NN) has relation nmod:to

c(NN) with minus(CC) has relation case

b(NN) with c(NN) has relation nmod:minus

d(NN) with plus(CC) has relation case

c(NN) with d(NN) has relation nmod:plus

[Sentence] set a to result of b plus c times a

set(VBN) with a(DT) has relation dobj

result(VB) with to(TO) has relation mark

set(VBN) with result(VB) has relation xcomp

times(NNS) with of(IN) has relation case

times(NNS) with b(NN) has relation compound

b(NN) with plus(CC) has relation cc

b(NN) with c(NN) has relation conj:plus

times(NNS) with c(NN) has relation compound

result(VB) with times(NNS) has relation nmod:of

times(NNS) with a(DT) has relation dep

10 changes: 10 additions & 0 deletions mappings/mapping.t2e
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
plus # +
minus # -
times # *
divided by # /
equals # =
not equals # !=
plus plus # ++
minus minus # --
mod # %

24 changes: 0 additions & 24 deletions output/out.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,6 @@ void function0 ()
return;
}

void fibonacci ()
{

return;
}

void function2 (int n)
{

return;
}

int fibonacci ()
{

return;
}

int fibonacci ()
{

return;
}

void main()
{

Expand Down
Binary file added relations.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
56 changes: 56 additions & 0 deletions src/ASTTest/ASTTestInputProcessor.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
package ASTTest;
import java.io.*;
import ast.*;
import ast.ASTParser;
import java.util.*;
public class ASTTestInputProcessor {
private ASTParser parser;
public static void main(String[] args){
//parse("Ifinput.txt","Ifoutput.txt");
}
public ASTTestInputProcessor(){

}
protected void parse(String inputPath,String outputPath){
try {
InputStream in = new FileInputStream(new File(inputPath));
//InputStream in = new FileInputStream(new File("Compoundinput.txt"));
//InputStream in = new FileInputStream(new File("Postfixinput.txt"));
//InputStream in = new FileInputStream(new File("Prefixinput.txt"));
//InputStream in = new FileInputStream(new File("Assignmentinput.txt"));
//InputStream in = new FileInputStream(new File("input.txt"));
this.parser = new ASTParser(in);
//File outputFile = new File("output.txt");
//File outputFile = new File("Assignmentoutput.txt");
//File outputFile = new File("Prefixoutput.txt");
//File outputFile = new File("Postfixoutput.txt");
//File outputFile = new File("Compoundoutput.txt");
File outputFile = new File(outputPath);
if(!outputFile.exists()){
outputFile.createNewFile();
}
FileWriter fw = new FileWriter(outputFile.getAbsoluteFile());
ArrayList<String> result = new ArrayList<String>();
BufferedWriter bw = new BufferedWriter(fw);
try {
int i = 0;
while(i<10000){
ASTNode temp = parser.statement();
result.add(temp.toSyntax()+"\n");
i++;
}
System.out.println(result.size());
for(int j = 0;j<result.size();j++){
bw.write(result.get(j));
}
bw.flush();
bw.close();
System.out.println("FINISH");
} catch (Exception ex){
ex.printStackTrace();
}
} catch (IOException e){
e.printStackTrace();
}
}
}
47 changes: 47 additions & 0 deletions src/ASTTest/AssignmentTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package ASTTest;

import static org.junit.Assert.assertEquals;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;

import org.junit.Test;

import ast.ASTParser;
import junit.framework.TestCase;

public class AssignmentTest extends TestCase {
private static ASTParser parser;
@Test
public void testAssignment() {
try {
InputStream in = new FileInputStream(new File("Assignmentinput.txt"));
parser = new ASTParser(in);
InputStream out = new FileInputStream(new File("Assignmentoutput.txt"));
BufferedReader br = new BufferedReader(new InputStreamReader(out));
ArrayList<String> expectedOutput = new ArrayList<String>();
String temp;
int count = 0;
while((temp=br.readLine())!=null){
expectedOutput.add(temp);
count++;
}
int testNo = 0;
while(testNo!=count){
try {
assertEquals(testNo+" "+expectedOutput.get(testNo),testNo+" "+parser.statement().toSyntax());
testNo++;
} catch (Exception ex){
ex.printStackTrace();
}
}
} catch(IOException e){
e.printStackTrace();
}
}
}
47 changes: 47 additions & 0 deletions src/ASTTest/CompoundTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package ASTTest;

import static org.junit.Assert.assertEquals;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;

import org.junit.Test;

import ast.ASTParser;
import junit.framework.TestCase;

public class CompoundTest extends TestCase {
private static ASTParser parser;
@Test
public void testCompound() {
try {
InputStream in = new FileInputStream(new File("Compoundinput.txt"));
parser = new ASTParser(in);
InputStream out = new FileInputStream(new File("Compoundoutput.txt"));
BufferedReader br = new BufferedReader(new InputStreamReader(out));
ArrayList<String> expectedOutput = new ArrayList<String>();
String temp;
int count = 0;
while((temp=br.readLine())!=null){
expectedOutput.add(temp);
count++;
}
int testNo = 0;
while(testNo!=count){
try {
assertEquals(testNo+" "+expectedOutput.get(testNo),testNo+" "+parser.statement().toSyntax());
testNo++;
} catch (Exception ex){
ex.printStackTrace();
}
}
} catch(IOException e){
e.printStackTrace();
}
}
}
Loading