Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/julianmendez/uel into asy…
Browse files Browse the repository at this point in the history
…nc-asp

Conflicts:
	uel-asp/src/main/java/de/tudresden/inf/lat/uel/asp/solver/AspUnificationAlgorithm.java
	uel-asp/src/main/java/de/tudresden/inf/lat/uel/asp/solver/ClingoOutput.java
	uel-asp/src/main/java/de/tudresden/inf/lat/uel/asp/solver/ClingoSolver.java
	uel-core/src/main/java/de/tudresden/inf/lat/uel/core/main/AlternativeUelStarter.java
	uel-core/src/main/java/de/tudresden/inf/lat/uel/core/processor/UelModel.java
	uel-core/src/main/java/de/tudresden/inf/lat/uel/core/processor/UelOntology.java
	uel-core/src/main/java/de/tudresden/inf/lat/uel/core/processor/UelOntologyGoal.java
	uel-core/src/test/java/de/tudresden/inf/lat/uel/core/main/ProcessorTest.java
	uel-rule/src/main/java/de/tudresden/inf/lat/uel/rule/RuleBasedUnificationAlgorithm.java
	uel-sat/src/main/java/de/tudresden/inf/lat/uel/sat/literals/Choice.java
	uel-sat/src/main/java/de/tudresden/inf/lat/uel/sat/solver/CNFMaxSatSolver.java
	uel-sat/src/main/java/de/tudresden/inf/lat/uel/sat/solver/MiniSatSolver.java
	uel-sat/src/main/java/de/tudresden/inf/lat/uel/sat/solver/Sat4jMaxSatSolver.java
	uel-sat/src/main/java/de/tudresden/inf/lat/uel/sat/solver/Sat4jSolver.java
	uel-sat/src/main/java/de/tudresden/inf/lat/uel/sat/solver/SatUnificationAlgorithm.java
	uel-sat/src/main/java/de/tudresden/inf/lat/uel/sat/type/SatInput.java
	uel-type/src/main/java/de/tudresden/inf/lat/uel/type/impl/AtomManagerImpl.java
	uel-ui/src/main/java/de/tudresden/inf/lat/uel/plugin/ui/RefineController.java
	uel-ui/src/main/java/de/tudresden/inf/lat/uel/plugin/ui/UelController.java
  • Loading branch information
Julian Mendez committed Dec 29, 2016
2 parents e0581b9 + d4039f4 commit 5d5cd99
Show file tree
Hide file tree
Showing 24 changed files with 57 additions and 68 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ private void extendAssignment(Map<Integer, Set<Integer>> assignment, String subs

Set<Integer> subsumers = assignment.get(varId);
if (subsumers == null) {
subsumers = new HashSet<Integer>();
subsumers = new HashSet<>();
assignment.put(varId, subsumers);
}
subsumers.add(atomId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ private void handleClingoExitCode() {
}

private List<String> getClingoArguments() {
List<String> arguments = new ArrayList<String>();
List<String> arguments = new ArrayList<>();
arguments.add(CLINGO_COMMAND);
arguments.addAll(Arrays.asList(COMMON_ARGUMENTS.split(" ")));
if (minimize) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,10 +204,7 @@ private static void printSyntax() {
try {
BufferedReader reader = new BufferedReader(
new InputStreamReader(AlternativeUelStarter.class.getResourceAsStream("/help")));
String line = null;
while ((line = reader.readLine()) != null) {
System.out.println(line);
}
reader.lines().forEach(line -> System.out.println(line));
System.out.flush();
reader.close();
} catch (IOException ex) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ private static String removeQuotes(String str) {
return ret;
}

private final Map<String, String> cache = new HashMap<String, String>();
private final Map<String, String> cache = new HashMap<>();

public abstract OWLOntology createOntology();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ public Goal getGoal() {
* @return the list of loaded ontologies
*/
public List<OWLOntology> getOntologyList() {
List<OWLOntology> list = new ArrayList<OWLOntology>();
List<OWLOntology> list = new ArrayList<>();
list.add(EMPTY_ONTOLOGY);
list.addAll(provider.getOntologies());
return list;
Expand Down Expand Up @@ -312,7 +312,7 @@ public List<Unifier> getUnifierList() {
* @return the current set of user variable names
*/
public Set<String> getUserVariableNames() {
Set<String> names = new HashSet<String>();
Set<String> names = new HashSet<>();
for (Integer varId : atomManager.getUserVariables()) {
names.add(atomManager.printConceptName(varId));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ private Set<Integer> flattenClassExpression(OWLClassExpression expression, Set<D

private Set<Integer> flattenConjunction(OWLObjectIntersectionOf conjunction, Set<Definition> newDefinitions,
Set<Integer> newNames) {
Set<Integer> atomIds = new HashSet<Integer>();
Set<Integer> atomIds = new HashSet<>();
for (OWLClassExpression operand : conjunction.getOperands()) {
atomIds.addAll(flattenClassExpression(operand, newDefinitions, newNames, false));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public static UnificationAlgorithm instantiateAlgorithm(String name, Goal input)
* @return all the algorithms that this factory can construct
*/
public static List<String> getAlgorithmNames() {
List<String> ret = new ArrayList<String>();
List<String> ret = new ArrayList<>();
ret.add(SAT_BASED_ALGORITHM);
ret.add(SAT_BASED_ALGORITHM_MINIMAL);
ret.add(RULE_BASED_ALGORITHM);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ protected OWLClassExpression finalizeExpression() {

@Override
protected void initialize() {
axioms = new HashSet<OWLAxiom>();
axioms = new HashSet<>();
expr = null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public AlternativeUelStarterTest(OWLOntology mainOntology, OWLOntology subsumpti
*/
@Parameters(name = "{index}")
public static Collection<Object[]> data() {
Collection<Object[]> data = new ArrayList<Object[]>();
Collection<Object[]> data = new ArrayList<>();

for (int i = 1; i <= maxTest; i++) {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ static String readNextLine(BufferedReader reader) throws IOException {

@Parameters(name = "{index}: {0}, {4}")
public static Collection<Object[]> data() {
Collection<Object[]> data = new ArrayList<Object[]>();
Collection<Object[]> data = new ArrayList<>();

System.out.println("Preparing tests.");
for (int i = 1; i <= maxTest; i++) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/
public class Assignment {

private final Map<Atom, Set<Atom>> subs = new HashMap<Atom, Set<Atom>>();
private final Map<Atom, Set<Atom>> subs = new HashMap<>();

/**
* Create an empty assignment.
Expand Down Expand Up @@ -146,7 +146,7 @@ Set<Atom> getKeys() {
private Set<Atom> getOrInit(Atom var) {
Set<Atom> flatAtoms = subs.get(var);
if (flatAtoms == null) {
flatAtoms = new HashSet<Atom>();
flatAtoms = new HashSet<>();
subs.put(var, flatAtoms);
}
return flatAtoms;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ private static void convert(Subsumption s, AtomManager atomManager, Set<FlatSubs
}

private static Set<FlatSubsumption> convertInput(Goal input) {
Set<FlatSubsumption> flatSubsumptions = new HashSet<FlatSubsumption>();
Set<FlatSubsumption> flatSubsumptions = new HashSet<>();
for (Definition d : input.getDefinitions()) {
convert(d, input.getAtomManager(), flatSubsumptions);
}
Expand All @@ -68,7 +68,7 @@ private static Set<FlatSubsumption> convertInput(Goal input) {
}

private static List<Atom> toAtoms(Set<Integer> atomIds, AtomManager atomManager) {
List<Atom> atoms = new ArrayList<Atom>();
List<Atom> atoms = new ArrayList<>();
for (Integer atomId : atomIds) {
atoms.add(atomManager.getAtom(atomId));
}
Expand All @@ -89,8 +89,8 @@ private static List<Atom> toAtoms(Set<Integer> atomIds, AtomManager atomManager)
NormalizedGoal(Goal input) {
goal = convertInput(input);
maxSize = goal.size();
variableBodyIndex = new HashMap<Atom, Set<FlatSubsumption>>();
variableHeadIndex = new HashMap<Atom, Set<FlatSubsumption>>();
variableBodyIndex = new HashMap<>();
variableHeadIndex = new HashMap<>();
for (FlatSubsumption sub : goal) {
addToIndex(sub);
}
Expand Down Expand Up @@ -157,7 +157,7 @@ public boolean containsAll(Collection<?> c) {
* operation
*/
Set<FlatSubsumption> expand(Assignment assign) {
Set<FlatSubsumption> newSubs = new HashSet<FlatSubsumption>();
Set<FlatSubsumption> newSubs = new HashSet<>();
for (Atom var : assign.getKeys()) {
for (FlatSubsumption sub : getOrInitHeadIndex(var)) {
expand(sub, assign.getSubsumers(var), newSubs);
Expand All @@ -177,7 +177,7 @@ Set<FlatSubsumption> expand(Assignment assign) {
* operation
*/
Set<FlatSubsumption> expand(FlatSubsumption sub, Set<Atom> subsumers) {
Set<FlatSubsumption> newSubs = new HashSet<FlatSubsumption>();
Set<FlatSubsumption> newSubs = new HashSet<>();
expand(sub, subsumers, newSubs);
return newSubs;
}
Expand All @@ -203,14 +203,14 @@ public int getMaxSize() {

private Set<FlatSubsumption> getOrInitBodyIndex(Atom var) {
if (!variableBodyIndex.containsKey(var)) {
variableBodyIndex.put(var, new HashSet<FlatSubsumption>());
variableBodyIndex.put(var, new HashSet<>());
}
return variableBodyIndex.get(var);
}

private Set<FlatSubsumption> getOrInitHeadIndex(Atom var) {
if (!variableHeadIndex.containsKey(var)) {
variableHeadIndex.put(var, new HashSet<FlatSubsumption>());
variableHeadIndex.put(var, new HashSet<>());
}
return variableHeadIndex.get(var);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ public final class Result {

private final FlatSubsumption subsumption;
private final Application application;
private final Set<FlatSubsumption> newUnsolvedSubsumptions = new HashSet<FlatSubsumption>();
private final Set<FlatSubsumption> newSolvedSubsumptions = new HashSet<FlatSubsumption>();
private final Set<FlatSubsumption> solvedSubsumptions = new HashSet<FlatSubsumption>();
private final Set<FlatSubsumption> newUnsolvedSubsumptions = new HashSet<>();
private final Set<FlatSubsumption> newSolvedSubsumptions = new HashSet<>();
private final Set<FlatSubsumption> solvedSubsumptions = new HashSet<>();
private final Assignment newSubsumers = new Assignment();
private boolean successful;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,14 +106,14 @@ protected void updateInfo() {
* unification in EL w.r.t. the empty TBox.
*/
private void initRules() {
staticEagerRules = new ArrayList<EagerRule>();
staticEagerRules = new ArrayList<>();
staticEagerRules.add(new EagerGroundSolvingRule());
staticEagerRules.add(new EagerSolving1Rule());
staticEagerRules.add(new EagerConflictRule());
dynamicEagerRules = new ArrayList<EagerRule>();
dynamicEagerRules = new ArrayList<>();
dynamicEagerRules.add(new EagerSolving2Rule());
dynamicEagerRules.add(new EagerExtensionRule());
nondeterministicRules = new ArrayList<Rule>();
nondeterministicRules = new ArrayList<>();
nondeterministicRules.add(new DecompositionRule());
nondeterministicRules.add(new ExtensionRule());
}
Expand Down Expand Up @@ -141,7 +141,7 @@ public boolean computeNextUnifier() throws InterruptedException {
}

if (searchStack == null) {
searchStack = new ArrayDeque<Result>();
searchStack = new ArrayDeque<>();

// apply eager rules to each unsolved subsumption
Result res = applyEagerRules(normalizedGoal, staticEagerRules, null);
Expand Down Expand Up @@ -176,7 +176,7 @@ public Unifier getUnifier() {
AtomManager atomManager = goal.getAtomManager();
DefinitionSet definitions = new DefinitionSet(atomManager.getVariables().size());
for (Integer varId : atomManager.getVariables()) {
Set<Integer> body = new HashSet<Integer>();
Set<Integer> body = new HashSet<>();
for (Atom subsumer : assignment.getSubsumers(atomManager.getAtom(varId))) {
body.add(atomManager.getIndex(subsumer));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public static int[] toArray(Set<Integer> clause) {
return ret;
}

private Collection<Set<Integer>> clauses = new ArrayList<Set<Integer>>();
private Collection<Set<Integer>> clauses = new ArrayList<>();
private Integer lastId = 0;
private Set<Integer> minimizeLiterals = new HashSet<Integer>();
private Collection<Set<Integer>> softClauses = new ArrayList<Set<Integer>>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
*/
public class SatOutput {

private Set<Integer> clause = new TreeSet<Integer>();
private Set<Integer> clause = new TreeSet<>();
private boolean satisfiable = false;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
*/
public class IndexedSetImpl<T> implements IndexedSet<T> {

private Map<Integer, T> invMap = new HashMap<Integer, T>();
private Map<T, Integer> map = new HashMap<T, Integer>();
private Map<Integer, T> invMap = new HashMap<>();
private Map<T, Integer> map = new HashMap<>();
private Integer maxIndex = 0;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ public Map<LabelId, List<LabelId>> getSelectedAtoms() {
*/
public void updateSelectionPanel(Map<LabelId, List<LabelId>> unifier) {
selectionPanel.removeAll();
content = new HashMap<LabelId, JList<LabelId>>();
content = new HashMap<>();

int rowCount = 0;
for (LabelId var : unifier.keySet()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ static JLabel createLabel(String text, String toolTipText) {
}

static <T> JList<T> createList(List<T> data, String toolTipText, boolean border) {
return setupList(new JList<T>(new Vector<T>(data)), toolTipText, border);
return setupList(new JList<T>(new Vector<>(data)), toolTipText, border);
}

static JScrollPane createScrollableTextArea(JTextArea textArea, String toolTipText) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,14 @@ public void open() {
private void updateLists() {
StringRenderer renderer = model.getStringRenderer(null);

List<LabelId> constants = new ArrayList<LabelId>();
List<LabelId> constants = new ArrayList<>();
for (Integer id : model.getGoal().getAtomManager().getConstants()) {
constants.add(new LabelId(renderer.renderAtom(id, false), id));
}
Collections.sort(constants);
view.setConstants(constants);

List<LabelId> variables = new ArrayList<LabelId>();
List<LabelId> variables = new ArrayList<>();
for (Integer id : model.getGoal().getAtomManager().getUserVariables()) {
variables.add(new LabelId(renderer.renderAtom(id, false), id));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +107,12 @@ public Collection<LabelId> getSelectedVariables() {
}

public void setConstants(List<LabelId> constants) {
this.listConstants.setListData(new Vector<LabelId>(constants));
this.listConstants.setListData(new Vector<>(constants));
this.listConstants.clearSelection();
}

public void setVariables(List<LabelId> variables) {
this.listVariables.setListData(new Vector<LabelId>(variables));
this.listVariables.setListData(new Vector<>(variables));
this.listVariables.clearSelection();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public CNFChecker(String filename) throws IOException {
private void constructInput(String cnfFile) throws IOException {
BufferedReader reader = new BufferedReader(new FileReader(cnfFile));
final AtomManager atomManager = new AtomManagerImpl();
final Set<Equation> equations = new HashSet<Equation>();
final Set<Equation> equations = new HashSet<>();

String[] line;
// ignore initial comments and empty lines
Expand Down Expand Up @@ -100,7 +100,7 @@ private void constructInput(String cnfFile) throws IOException {
}

// construct concept names for all literals in this clause
Set<Integer> literals = new HashSet<Integer>();
Set<Integer> literals = new HashSet<>();
for (int litIdx = 0; litIdx < line.length - 1; litIdx++) {
int literal = Integer.parseInt(line[litIdx]);
if (literal == 0) {
Expand Down Expand Up @@ -200,7 +200,7 @@ public void runAlgorithm(String algorithmName) throws InterruptedException {
}

private static <T> Set<T> set(T a, T b) {
Set<T> set = new HashSet<T>();
Set<T> set = new HashSet<>();
set.add(a);
set.add(b);
return set;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,22 +73,18 @@ private String processTag(String line, Map<String, String> map, String header, S
}

private Map<String, String> readMap(File mapFile) throws IOException {
Map<String, String> ret = new TreeMap<String, String>();
Map<String, String> ret = new TreeMap<>();
BufferedReader reader = new BufferedReader(new FileReader(mapFile));
String line = "";
while (line != null) {
line = reader.readLine();
if (line != null) {
StringTokenizer stok = new StringTokenizer(line, "\t");
reader.lines().forEach(line -> {
StringTokenizer stok = new StringTokenizer(line, "\t");
if (stok.hasMoreTokens()) {
String key = stok.nextToken();
if (stok.hasMoreTokens()) {
String key = stok.nextToken();
if (stok.hasMoreTokens()) {
String value = stok.nextToken();
ret.put(toXMLEncoding(key), toXMLEncoding(value));
}
String value = stok.nextToken();
ret.put(toXMLEncoding(key), toXMLEncoding(value));
}
}
}
});
reader.close();
return ret;
}
Expand All @@ -97,14 +93,10 @@ public void run(File inputFile, File mapFile, File outputFile) throws IOExceptio
Map<String, String> nameMap = readMap(mapFile);
BufferedWriter writer = new BufferedWriter(new FileWriter(outputFile));
BufferedReader reader = new BufferedReader(new FileReader(inputFile));
String line = "";
while (line != null) {
line = reader.readLine();
if (line != null) {
line = processTag(line, nameMap, classRdfAbout, classEnd);
line = processTag(line, nameMap, objectPropertyRdfAbout, objectPropertyEnd);
writer.write(line + "\n");
}
for (String line = reader.readLine(); line != null; line = reader.readLine()) {
line = processTag(line, nameMap, classRdfAbout, classEnd);
line = processTag(line, nameMap, objectPropertyRdfAbout, objectPropertyEnd);
writer.write(line + "\n");
}
writer.flush();
reader.close();
Expand Down
Loading

0 comments on commit 5d5cd99

Please sign in to comment.