Skip to content
Snippets Groups Projects
Commit 0923716b authored by Noah Heuser's avatar Noah Heuser
Browse files

remove line breaks in grammar toString(), changed file path of result

files
parent 4f85bb95
No related branches found
No related tags found
No related merge requests found
......@@ -53,7 +53,7 @@ public abstract class Grammar {
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("G = (V, T, R, " + this.getStart() + ")\n");
sb.append("G = (V, T, R, " + this.getStart() + "), ");
sb.append("V = {");
for (int i = 0; i < this.getVars().length; i++) {
sb.append(this.getVars()[i]);
......@@ -61,7 +61,7 @@ public abstract class Grammar {
sb.append(", ");
}
}
sb.append("}\n");
sb.append("}, ");
sb.append("T = {");
for (int i = 97; i < 97 + this.getAlphaSize(); i++) {
sb.append((char) i);
......@@ -69,7 +69,7 @@ public abstract class Grammar {
sb.append(", ");
}
}
sb.append("}\n");
sb.append("}, ");
sb.append("R = {");
Iterator<Entry<String, List<List<String>>>> it = this.getRules().entrySet().iterator();
while (it.hasNext()) {
......@@ -91,7 +91,7 @@ public abstract class Grammar {
}
}
if (it.hasNext()) {
sb.append(",\n ");
sb.append(", ");
}
}
sb.append("}");
......
......@@ -39,7 +39,8 @@ public class Writer {
}
private void writePairToFile(List<String> pairs) {
try (BufferedWriter bw = new BufferedWriter(new FileWriter("../PythonAPI/grammarWordsPairs.txt"))) {
try (BufferedWriter bw = new BufferedWriter(
new FileWriter("//wsl.localhost/Ubuntu/home/noah/gptgrammarparsing/PythonAPI/grammarWordsPairs.txt"))) {
bw.write(pairs.toString());
} catch (IOException e) {
e.printStackTrace();
......@@ -48,7 +49,7 @@ public class Writer {
private void writeResultToFileType2(List<Grammar> grammars, List<Map<String, List<List<String>>>> normalizedRuleSet,
List<String> words) {
try (BufferedWriter bw = new BufferedWriter(new FileWriter("../PythonAPI/resultsOfMembershipTest.txt"))) {
try (BufferedWriter bw = new BufferedWriter(new FileWriter("resultsOfMembershipTest.txt"))) {
int i = 0;
int k = 0;
for (Grammar g : grammars) {
......@@ -66,7 +67,8 @@ public class Writer {
}
private void writeResultToFileType3(List<FiniteStateMachine> fsms, List<String> words) {
try (BufferedWriter bw = new BufferedWriter(new FileWriter("../PythonAPI/resultsOfMembershipTest.txt"))) {
try (BufferedWriter bw = new BufferedWriter(new FileWriter(
"//wsl.localhost/Ubuntu/home/noah/gptgrammarparsing/PythonAPI/resultsOfMembershipTest.txt"))) {
int i = 0;
for (FiniteStateMachine fsm : fsms) {
for (int j = 0; j < DISTINCT_WORDS; j++) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment