Interesting problem!
There is no way to do this as described, just with DataMapper core methods. I'm just speculating about the nature of the data now... but I am curious if you might be able to come up with a "canonical" representation of any given Expression
such that it could look like:
class Expression
belongs_to :canonical_translation
...
def equivalent_expressions
canonical_translation.expressions.all(:id.not => self.id)
end
end
class CanonicalTranslation
property :representation, SomeDataType
has n :expressions
end
If not, you may be forced to use a custom method on the Expression object, something like:
has n, :these_translations, :model => TranslationPair, :child_key => [:exp_1]
has n, :those_translations, :model => TranslationPair, :child_key => [:exp_2]
def translation_pairs
these_translations + those_translations
end