-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adding code for datarinse, codebreaker
- Loading branch information
1 parent
4911bbc
commit dad9df7
Showing
276 changed files
with
1,164,646 additions
and
356 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<classpath> | ||
<classpathentry kind="src" output="target/classes" path="src/main/java"> | ||
<attributes> | ||
<attribute name="optional" value="true"/> | ||
<attribute name="maven.pomderived" value="true"/> | ||
</attributes> | ||
</classpathentry> | ||
<classpathentry kind="src" output="target/test-classes" path="src/test/java"> | ||
<attributes> | ||
<attribute name="test" value="true"/> | ||
<attribute name="optional" value="true"/> | ||
<attribute name="maven.pomderived" value="true"/> | ||
</attributes> | ||
</classpathentry> | ||
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources"> | ||
<attributes> | ||
<attribute name="maven.pomderived" value="true"/> | ||
</attributes> | ||
</classpathentry> | ||
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources"> | ||
<attributes> | ||
<attribute name="test" value="true"/> | ||
<attribute name="maven.pomderived" value="true"/> | ||
</attributes> | ||
</classpathentry> | ||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-11"> | ||
<attributes> | ||
<attribute name="maven.pomderived" value="true"/> | ||
</attributes> | ||
</classpathentry> | ||
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER"> | ||
<attributes> | ||
<attribute name="maven.pomderived" value="true"/> | ||
</attributes> | ||
</classpathentry> | ||
<classpathentry kind="output" path="target/classes"/> | ||
</classpath> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
/target/ | ||
/dependency-reduced-pom.xml | ||
/.idea/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<projectDescription> | ||
<name>CodeBreaker</name> | ||
<comment></comment> | ||
<projects> | ||
</projects> | ||
<buildSpec> | ||
<buildCommand> | ||
<name>org.eclipse.jdt.core.javabuilder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
<buildCommand> | ||
<name>org.eclipse.m2e.core.maven2Builder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
</buildSpec> | ||
<natures> | ||
<nature>org.eclipse.jdt.core.javanature</nature> | ||
<nature>org.eclipse.m2e.core.maven2Nature</nature> | ||
</natures> | ||
</projectDescription> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
eclipse.preferences.version=1 | ||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled | ||
org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate | ||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=11 | ||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve | ||
org.eclipse.jdt.core.compiler.compliance=11 | ||
org.eclipse.jdt.core.compiler.debug.lineNumber=generate | ||
org.eclipse.jdt.core.compiler.debug.localVariable=generate | ||
org.eclipse.jdt.core.compiler.debug.sourceFile=generate | ||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error | ||
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled | ||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error | ||
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning | ||
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning | ||
org.eclipse.jdt.core.compiler.release=disabled | ||
org.eclipse.jdt.core.compiler.source=11 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
activeProfiles= | ||
eclipse.preferences.version=1 | ||
resolveWorkspaceProjects=true | ||
version=1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4"> | ||
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_11"> | ||
<output url="file://$MODULE_DIR$/target/classes" /> | ||
<output-test url="file://$MODULE_DIR$/target/test-classes" /> | ||
<content url="file://$MODULE_DIR$"> | ||
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" /> | ||
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" /> | ||
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" /> | ||
<sourceFolder url="file://$MODULE_DIR$/src/test/resources" type="java-test-resource" /> | ||
<excludeFolder url="file://$MODULE_DIR$/target" /> | ||
</content> | ||
<orderEntry type="inheritedJdk" /> | ||
<orderEntry type="sourceFolder" forTests="false" /> | ||
<orderEntry type="library" name="Maven: CodeKnowledgeGraph:CodeBreakerBase:0.0.1-SNAPSHOT" level="project" /> | ||
<orderEntry type="library" name="Maven: co.elastic.clients:elasticsearch-java:8.2.3" level="project" /> | ||
<orderEntry type="library" name="Maven: org.elasticsearch.client:elasticsearch-rest-client:8.2.3" level="project" /> | ||
<orderEntry type="library" name="Maven: org.apache.httpcomponents:httpclient:4.5.10" level="project" /> | ||
<orderEntry type="library" name="Maven: org.apache.httpcomponents:httpcore:4.4.12" level="project" /> | ||
<orderEntry type="library" name="Maven: org.apache.httpcomponents:httpasyncclient:4.1.4" level="project" /> | ||
<orderEntry type="library" name="Maven: org.apache.httpcomponents:httpcore-nio:4.4.12" level="project" /> | ||
<orderEntry type="library" name="Maven: commons-codec:commons-codec:1.14" level="project" /> | ||
<orderEntry type="library" name="Maven: commons-logging:commons-logging:1.1.3" level="project" /> | ||
<orderEntry type="library" name="Maven: com.google.code.findbugs:jsr305:3.0.2" level="project" /> | ||
<orderEntry type="library" name="Maven: jakarta.json:jakarta.json-api:2.0.1" level="project" /> | ||
<orderEntry type="library" name="Maven: org.eclipse.parsson:parsson:1.0.0" level="project" /> | ||
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-databind:2.12.3" level="project" /> | ||
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-annotations:2.12.3" level="project" /> | ||
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-core:2.12.3" level="project" /> | ||
<orderEntry type="library" name="Maven: org.json:json:20230227" level="project" /> | ||
</component> | ||
</module> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
The script `code_knowledge_graph/scripts/setup.sh` has the steps to build the analysis code for both Python 2 and Python 3. In the parent directory of the repository, run `bash code_knowledge_graph/scripts/setup.sh` to build the code. | ||
|
||
To run the code on a given python file: | ||
|
||
- For Python 3: in code_breaker_py3: `java -DquadFile=<nq file name> -DoutputDir=<dir for json files> -cp target/CodeBreaker_py3-0.0.1-SNAPSHOT.jar util.RunTurtleSingleAnalysis <dir containing files/single file> <repoPath> <path>` for running the analysis on a given python file. | ||
|
||
- For Python 2: In code_breaker_py2: `java -DquadFile=<nq file name> -DoutputDir=<dir for json files> -cp target/CodeBreaker_py2-0.0.1-SNAPSHOT.jar util.RunTurtleSingleAnalysis <dir containing files/single file> <repoPath> <path>` for running the analysis on a given python file. | ||
|
||
To run summaries for data science pipelines: | ||
In code_breaker_py3: `java -cp target/CodeBreaker_py3-0.0.1-SNAPSHOT.jar util.SummarizeDataScienceGraphsFromJSON <input JSON file from analysis> <output JSON file to store subgraphs>` for running the analysis on a given python file. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
generated by: | ||
|
||
/Volume1/AI4CODE/CodeNet/AI4Code-Datasets/scripts/codenet_aggregate.sh -c=julian-samples.conf -o=julian | ||
|
||
from config file: | ||
|
||
PROBLEMS=( | ||
p00017 # Caesar Cipher | ||
p00029 # English Sentence | ||
p00052 # Factorial II | ||
p00061 # Rank Checker | ||
p00105 # Book Index | ||
) | ||
|
||
LANGUAGES=( | ||
Java | ||
) | ||
|
||
STATUSES=( | ||
Accepted | ||
) | ||
|
||
# Select on code size (>= 0). Bounds are inclusive. | ||
MIN_CODE_SIZE=50 | ||
MAX_CODE_SIZE= # undefined means unlimited | ||
|
||
# How many samples to provide per selection. | ||
# A selection is a problem/language/status combination. | ||
# When not defined, it means all available. | ||
NUM_SAMPLES=10 |
121 changes: 121 additions & 0 deletions
121
code_breaker/data/CodeNet_sample/p00017/s091933654/Main.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
import java.io.BufferedReader; | ||
import java.io.IOException; | ||
import java.io.InputStreamReader; | ||
|
||
public class Main { | ||
|
||
private static final char START_ALPHABET = 'a'; | ||
private static final char END_ALPHABET = 'z'; | ||
private static final char CHAR_T = 't'; | ||
private static final char CHAR_PERIOD = '.'; | ||
private static final String COMPARE_THE = "the"; | ||
private static final String COMPARE_THIS = "this"; | ||
private static final String COMPARE_THAT = "that"; | ||
private static final String BLANK = " "; | ||
|
||
public static void main(String[] args) { | ||
|
||
BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); | ||
|
||
try { | ||
String input = null; | ||
while ((input = in.readLine()) != null) { | ||
|
||
String[] cutData = input.split(BLANK); | ||
int caesarNum = solveCaesarNum(cutData); | ||
|
||
StringBuilder result = new StringBuilder(); | ||
|
||
for (String data : cutData) { | ||
result.append(routation(data, caesarNum)).append(BLANK); | ||
} | ||
|
||
// 最後の空白を削除 | ||
result.delete(result.length() - 1, result.length()); | ||
|
||
System.out.println(result.toString()); | ||
} | ||
|
||
} catch (IOException e) { | ||
e.printStackTrace(); | ||
} finally { | ||
try { | ||
in.close(); | ||
} catch (IOException e) { | ||
e.printStackTrace(); | ||
} | ||
} | ||
} | ||
|
||
private static int solveCaesarNum(String[] cutData) { | ||
|
||
int cnt = 0; | ||
boolean stopFlg = false; | ||
|
||
while (cnt < END_ALPHABET - START_ALPHABET + 1) { | ||
|
||
for (String data : cutData) { | ||
|
||
String checkData = data; | ||
|
||
// 単語の最後がピリオドならば、ピリオドは除外 | ||
if (data.charAt(data.length() - 1) == CHAR_PERIOD) { | ||
checkData = data.substring(0, data.length() - 1); | ||
} | ||
|
||
if (checkData.length() == 3) { | ||
String checkThe = routation(checkData, | ||
CHAR_T - checkData.charAt(0)); | ||
|
||
if (COMPARE_THE.equals(checkThe)) { | ||
stopFlg = true; | ||
cnt = CHAR_T - checkData.charAt(0); | ||
break; | ||
} | ||
} else if (checkData.length() == 4) { | ||
|
||
String checkThe = routation(checkData, | ||
CHAR_T - checkData.charAt(0)); | ||
|
||
if (COMPARE_THAT.equals(checkThe) | ||
|| COMPARE_THIS.equals(checkThe)) { | ||
stopFlg = true; | ||
cnt = CHAR_T - checkData.charAt(0); | ||
break; | ||
} | ||
} | ||
} | ||
|
||
if (stopFlg) { | ||
break; | ||
} | ||
|
||
cnt++; | ||
} | ||
|
||
return cnt; | ||
} | ||
|
||
private static String routation(String data, int caesarNum) { | ||
|
||
char[] convertChar = data.toCharArray(); | ||
|
||
for (int i = 0; i < convertChar.length; i++) { | ||
|
||
// カンマはスルー | ||
if (convertChar[i] == CHAR_PERIOD) { | ||
continue; | ||
} | ||
|
||
convertChar[i] += caesarNum; | ||
|
||
if (convertChar[i] < START_ALPHABET) { | ||
convertChar[i] += END_ALPHABET - START_ALPHABET + 1; | ||
} else if (convertChar[i] > END_ALPHABET) { | ||
convertChar[i] += START_ALPHABET - END_ALPHABET - 1; | ||
} | ||
} | ||
|
||
return String.valueOf(convertChar); | ||
} | ||
} |
47 changes: 47 additions & 0 deletions
47
code_breaker/data/CodeNet_sample/p00017/s236746930/Main.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import java.util.Scanner; | ||
class Main { | ||
public static void main(String args[]){ | ||
Scanner scan = new Scanner(System.in); | ||
|
||
while(scan.hasNextLine()){ | ||
String line = scan.nextLine(); | ||
String[] cipher = line.split(" "); | ||
char[][] ch = new char[cipher.length][]; | ||
int i,j; | ||
|
||
for(i=0;i<cipher.length;i++){ | ||
ch[i] = cipher[i].toCharArray(); | ||
} | ||
|
||
String[] str = new String[cipher.length]; | ||
String s = ""; | ||
out : while(true){ | ||
for(i=0;i<cipher.length;i++){ | ||
for(j=0;j<cipher[i].length();j++){ | ||
if(ch[i][j]!='.' && ch[i][j]!=' '){ | ||
if(ch[i][j] == 'z'){ | ||
ch[i][j] = 'a'; | ||
}else{ | ||
ch[i][j] = (char)(ch[i][j]+1); | ||
} | ||
} | ||
} | ||
str[i] = String.valueOf(ch[i]); | ||
} | ||
|
||
for(i=0;i<cipher.length;i++){ | ||
if(str[i].equals("the") || str[i].equals("this") || str[i].equals("that") | ||
|| str[i].equals("the.") || str[i].equals("this.") || str[i].equals("that.")){ | ||
break out; | ||
} | ||
} | ||
} | ||
|
||
for(i=0;i<cipher.length-1;i++){ | ||
s+=(str[i]+" "); | ||
} | ||
s+=str[cipher.length-1]; | ||
System.out.println(s); | ||
} | ||
} | ||
} |
Oops, something went wrong.