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

deleted main methods where not needed

parent 751b59db
No related branches found
No related tags found
No related merge requests found
...@@ -91,7 +91,7 @@ public abstract class Grammar { ...@@ -91,7 +91,7 @@ public abstract class Grammar {
} }
} }
if (it.hasNext()) { if (it.hasNext()) {
sb.append(", "); sb.append(",\n ");
} }
} }
sb.append("}"); sb.append("}");
......
...@@ -27,15 +27,4 @@ public class Type2Grammar extends Grammar { ...@@ -27,15 +27,4 @@ public class Type2Grammar extends Grammar {
} }
public static void main(String[] args) {
String[] vars = { "S", "A", "B" };
int alphaSize = 2;
String start = "S";
int maxConclusios = 2;
int maxConclusioSize = 3;
int mode = 3;
Grammar gr = new Type2Grammar(vars, alphaSize, start, maxConclusios, maxConclusioSize, mode);
System.out.println(gr);
}
} }
...@@ -412,23 +412,4 @@ public class Type2Parser { ...@@ -412,23 +412,4 @@ public class Type2Parser {
return cyk(cnfRules, word, cnfRules.containsKey("S'") ? "S'" : start); return cyk(cnfRules, word, cnfRules.containsKey("S'") ? "S'" : start);
} }
public static void main(String[] args) {
Type2Parser parser2 = new Type2Parser();
Map<String, List<List<String>>> rules = new HashMap<>();
List<List<String>> s = List.of(List.of("C", "C", "a"), List.of("B"), List.of("c"));
rules.put("S", s);
List<List<String>> a = List.of(List.of("a", "C", "S"), List.of("b"), List.of("b", "D"));
rules.put("A", a);
List<List<String>> b = List.of(List.of(), List.of("S", "A"));
rules.put("B", b);
List<List<String>> c = List.of(List.of("B", "B", "A"), List.of("c", "B", "c"));
rules.put("C", c);
List<List<String>> d = List.of(List.of("c", "c", "D"), List.of("a", "c"), List.of("c"));
rules.put("D", d);
Map<String, List<List<String>>> cnfRules = parser2.createCNF(rules, "S");
System.out.println(cnfRules);
System.out.println(parser2.isPartOfLanguage(cnfRules,
"bcacaaccccaaabacbccacbacbabbacbaabcabcbaaaacabacbaaabccccacacbccaccbcccaabacbabbaca", "S"));
}
} }
...@@ -7,7 +7,6 @@ import java.util.Map; ...@@ -7,7 +7,6 @@ import java.util.Map;
import java.util.Map.Entry; import java.util.Map.Entry;
import auxiliary.ListOfListContains; import auxiliary.ListOfListContains;
import word_generator.WordGenerator;
public class Type3Parser { public class Type3Parser {
...@@ -49,25 +48,4 @@ public class Type3Parser { ...@@ -49,25 +48,4 @@ public class Type3Parser {
return isPart; return isPart;
} }
public static void main(String[] args) {
Type3Parser parser3 = new Type3Parser();
Map<String, List<List<String>>> rules = new HashMap<>();
List<List<String>> s = List.of(List.of("a", "A"), List.of("b", "B"), List.of("a", "C"), List.of("a"));
rules.put("S", s);
List<List<String>> a = List.of(List.of("b", "Q"));
rules.put("A", a);
List<List<String>> q = List.of(List.of("b", "B"));
rules.put("Q", q);
List<List<String>> b = List.of(List.of("a", "A"), List.of("b"), List.of("a"));
rules.put("B", b);
List<List<String>> c = List.of(List.of("b", "B"), List.of("c", "C"));
rules.put("C", c);
FiniteStateMachine fsm = parser3.grammarToFSM(rules, "S");
// System.out.println(parser3.isPartOfLanguage(fsm, "ab"));
// System.out.println(parser3.isPartOfLanguage(fsm, "abb"));
WordGenerator wg = new WordGenerator();
String word = wg.wordGeneratorOverType3Grammar(4, fsm, 3);
System.out.println(word);
}
} }
...@@ -23,7 +23,7 @@ public class WordGenerator { ...@@ -23,7 +23,7 @@ public class WordGenerator {
public String wordGeneratorOverType2Grammar(int maxLength, Map<String, List<List<String>>> cnfGrammar) { public String wordGeneratorOverType2Grammar(int maxLength, Map<String, List<List<String>>> cnfGrammar) {
String s = ""; String s = "";
while (s.equals("") || !s.equals(s.toLowerCase())) { while (s.equals("") || !s.equals(s.toLowerCase())) {
s = wordGeneratorOverType2GrammarTry(maxLength, cnfGrammar); s = wordGeneratorOverType2GrammarTry(random.nextInt(maxLength - 1) + 1, cnfGrammar);
} }
return s; return s;
} }
...@@ -75,9 +75,4 @@ public class WordGenerator { ...@@ -75,9 +75,4 @@ public class WordGenerator {
return sb.toString(); return sb.toString();
} }
public static void main(String[] args) {
String s = "ab";
System.out.println(s.equals(s.toLowerCase()));
}
} }
...@@ -165,18 +165,7 @@ public class Writer { ...@@ -165,18 +165,7 @@ public class Writer {
String start = "S"; String start = "S";
int mode = 3; int mode = 3;
// Type2Grammar g = new Type2Grammar(vars, alphaSize, start, maxConclusios, maxConclusioSize, mode); // Type2Grammar g = new Type2Grammar(vars, alphaSize, start, maxConclusios, maxConclusioSize, mode);
// Map<String, List<List<String>>> normalizedRuleSet = w.t2p.createCNF(g.getRules(), g.getStart()); // System.out.println(g);
// Set<String> words = new HashSet<>();
// String word0 = w.wg.wordGenerator(MAX_LENGTH);
// String word1 = w.wg.wordGeneratorOverAlphabet(MAX_LENGTH, alphaSize);
// String word2 = w.wg.wordGeneratorOverType2Grammar(MAX_LENGTH, normalizedRuleSet);
// words.add(word0);
// words.add(word1);
// words.add(word2);
// System.out.println(w.createGrammarWordsPair(g.toString(), words));
// System.out.println(w.t2p.isPartOfLanguage(normalizedRuleSet, word0, start));
// System.out.println(w.t2p.isPartOfLanguage(normalizedRuleSet, word1, start));
// System.out.println(w.t2p.isPartOfLanguage(normalizedRuleSet, word2, start));
w.runType3Grammar(vars, alphaSize, maxConclusios, start, mode, 3); w.runType3Grammar(vars, alphaSize, maxConclusios, start, mode, 3);
} }
......
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