@Override public DungTheory next() { Argument a = new Argument("a"); return this.next(a); }
@Override public int hashCode() { final int prime = 31; int result = super.hashCode(); result = prime * result + ((rule == null) ? 0 : rule.hashCode()); result = prime * result + ((subs == null) ? 0 : subs.hashCode()); return result; }
@Override public DungTheory parse(Reader reader) throws IOException { DungTheory theory = new DungTheory(); BufferedReader in = new BufferedReader(reader); String row = null; boolean argumentSection = true; Map<String,Argument> arguments = new HashMap<String,Argument>(); while ((row = in.readLine()) != null) { if(row.trim().equals("")) continue; if(row.trim().equals("#")){ argumentSection = false; continue; } if(argumentSection) { Argument a = new Argument(row.trim()); arguments.put(a.getName(), a); theory.add(a); } else{ theory.addAttack(arguments.get(row.substring(0, row.indexOf(" ")).trim()),arguments.get(row.substring(row.indexOf(" ")+1,row.length()).trim())); } } in.close(); return theory; } }
@Override public LdoFormula getLdoFormula() { return getLdoArgument(); }
@Override public LdoFormula getLdoFormula() { return new LdoRelation(this.getAttacker().getLdoFormula(), new LdoNegation(this.getAttacked().getLdoFormula())); }
/** Pretty print of the theory. */ public String prettyPrint(){ String output = new String(); Iterator<Argument> it = this.iterator(); while(it.hasNext()) output += "argument("+it.next().toString()+").\n"; output += "\n"; Iterator<Attack> it2 = this.getAttacks().iterator(); while(it2.hasNext()) output += "attack"+it2.next().toString()+".\n"; return output; }
/** * Returns an argument representation (in Dung-style) * of this LdoArgument. * @return an argument representation (in Dung-style) * of this LdoArgument. */ public Argument getArgument(){ return new Argument(this.getName()); }
@SuppressWarnings("rawtypes") @Override public boolean equals(Object obj) { if (this == obj) return true; if (!super.equals(obj)) return false; if (getClass() != obj.getClass()) return false; Deduction other = (Deduction) obj; if (rule == null) { if (other.rule != null) return false; } else if (!rule.equals(other.rule)) return false; if (subs == null) { if (other.subs != null) return false; } else if (!subs.equals(other.subs)) return false; return true; }
@Override public int hashCode() { final int prime = 31; int result = super.hashCode(); result = prime * result + ((derivation == null) ? 0 : derivation.hashCode()); return result; }
@Override public Collection<AbaExtension<T>> getModels(ABATheory<T> abat) { DungTheory dt = abat.asDungTheory(); AbstractExtensionReasoner aer = AbstractExtensionReasoner.getSimpleReasonerForSemantics(semantics); Collection<AbaExtension<T>> result = new HashSet<>(); for (Extension ext : aer.getModels(dt)) { AbaExtension<T> abaext = new AbaExtension<T>(); for (Argument arg : ext) { for (Assumption<T> ass : abat.getAssumptions()) { if (ass.toString().equals(arg.toString())) { abaext.add(ass); break; } } } result.add(abaext); } return result; } }
/** * Returns a collection view of the given set of arguments * * @param s * some string in the format "[arg1,...,argn]". * @return a collection view of the given arguments */ public static Extension parseArgumentList(String s) { s = s.trim(); if (!s.startsWith("[") || !s.endsWith("]")) throw new IllegalArgumentException("Expected list of arguments but encountered " + s); String s2 = s.substring(1, s.length() - 1); StringTokenizer tokenizer = new StringTokenizer(s2, ","); Extension args = new Extension(); while (tokenizer.hasMoreTokens()) args.add(new Argument(tokenizer.nextToken().trim())); return args; }
@Override public boolean equals(Object obj) { if (this == obj) return true; if (!super.equals(obj)) return false; if (getClass() != obj.getClass()) return false; ArgumentStructure other = (ArgumentStructure) obj; if (derivation == null) { if (other.derivation != null) return false; } else if (!derivation.equals(other.derivation)) return false; return true; }
/** * returns true if one arguments in <source>arguments</source> attacks another within this attack relation. * @param arguments a list of arguments * @return returns true if one arguments in <source>arguments</source> attacks another. */ public boolean isConflictFree(Collection<? extends Argument> arguments){ Iterator<? extends Argument> it = arguments.iterator(); while(it.hasNext()){ Argument arg = (Argument) it.next(); if(arg.equals(this.getAttacker())){ Iterator<? extends Argument> it2 = arguments.iterator(); while(it2.hasNext()){ Argument arg2 = (Argument) it2.next(); if(arg2.equals(this.getAttacked())) return false; } } } return true; }
@Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((argument == null) ? 0 : argument.hashCode()); result = prime * result + ((epsilon == null) ? 0 : epsilon.hashCode()); result = prime * result + ((theory == null) ? 0 : theory.hashCode()); result = prime * result + ((faction == null) ? 0 : faction.hashCode()); return result; }
Argument a = new Argument(row); arguments.put(row, a); theory.add(a);