blob: 5cfb6b2dc37b5f0ac6e50c2f1b74c47468224c9d [file] [log] [blame]
-- @atlcompiler atl2006
module Assign_NameSim; -- Module Template
create OUT : AMW from IN : AMW, left : MOF, right : MOF;
helper context MOF!EModelElement def: matches(other : MOF!EModelElement) : Boolean =
let left : String = self.name.toLower() in
let right : String = other.name.toLower() in
left = right;
helper context MOF!EModelElement def: similarityName(right : MOF!EModelElement) : Real =
if self.matches(right) then
1
else
self.name.getSimilarity(right.name)
endif;
rule UpdateSim {
from
mmw : AMW!Equivalent
using {
left : MOF!EModelElement = MOF!EModelElement.getInstanceById('left',mmw.left.element.ref);
right : MOF!EModelElement = MOF!EModelElement.getInstanceById('right',mmw.right.element.ref);
}
to
alink : AMW!Equivalent (
name <- mmw.name,
model <- mmw.model,
left <- mmw.left,
right <- mmw.right,
similarity <- mmw.similarity +
left.similarityName(right)
)
}
------------------------------copied rules---------------------------------------------------
rule leftElement {
from
mmw : AMW!LeftElement
to
out : AMW!LeftElement (
name <- mmw.name,
element <- mmw.element
)
}
rule rightElement {
from
mmw : AMW!RightElement
to
out : AMW!RightElement (
name <- mmw.name,
element <- mmw.element
)
}
rule ElementRefs {
from
mmw : AMW!ElementRef
to
out : AMW!ElementRef (
name <- mmw.name,
ref <- mmw.ref,
modelRef <- mmw.modelRef
)
}
rule matchmodel {
from
mmw: AMW!MatchModel
to
model : AMW!MatchModel (
name <- mmw.name,
leftM <- mmw.leftM,
rightM <- mmw.rightM,
methods <- mmw.methods->union(Sequence{method})
),
method : AMW!Method (
name <- 'string comparison - Levenshtein distance'
)
}
rule method {
from
mmw : AMW!Method
to
method : AMW!Method (
name <- mmw.name
)
}
rule modelref {
from
mmw : AMW!ModelRef
to
out : AMW!ModelRef (
name <- mmw.name,
ref <- mmw.ref
)
}