public StandardizeApartResult standardizeApart(Sentence aSentence,
StandardizeApartIndexical standardizeApartIndexical)
{
List<Variable> toRename = variableCollector
.collectAllVariables(aSentence);
Dictionary<Variable, Term> renameSubstitution = new Dictionary<Variable, Term>();
Dictionary<Variable, Term> reverseSubstitution = new Dictionary<Variable, Term>();
foreach (Variable var in toRename)
{
Variable v = null;
do
{
v = new Variable(standardizeApartIndexical.getPrefix()
+ standardizeApartIndexical.getNextIndex());
// Ensure the new variable name is not already
// accidentally used in the sentence
} while (toRename.Contains(v));
renameSubstitution.Add(var, v);
reverseSubstitution.Add(v, var);
}
Sentence standardized = substVisitor.subst(renameSubstitution,
aSentence);
return new StandardizeApartResult(aSentence, standardized,
renameSubstitution, reverseSubstitution);
}