|
@@ -93,11 +93,12 @@ LevenshteinMatrice_base *LevenshteinMatrice_base::Builder::build(const JSonEleme
|
|
|
{
|
|
{
|
|
|
if (a->stringify() == b->stringify())
|
|
if (a->stringify() == b->stringify())
|
|
|
return LevenshteinMatrice_base::Builder::build(*(const JSonObjectEntry&)(*a), *(const JSonObjectEntry&)(*b));
|
|
return LevenshteinMatrice_base::Builder::build(*(const JSonObjectEntry&)(*a), *(const JSonObjectEntry&)(*b));
|
|
|
- return new LevenshteinMatriceWithScore(0.f, a, b);
|
|
|
|
|
|
|
+ return new LevenshteinMatriceWithScore(0.f, a, b, true);
|
|
|
}
|
|
}
|
|
|
else if (aIsObject || bIsObject)
|
|
else if (aIsObject || bIsObject)
|
|
|
- return new LevenshteinMatriceWithScore(0.f, a, b);
|
|
|
|
|
- return new LevenshteinMatriceWithScore(levenshteinPercent(a->stringify(), b->stringify()), a, b, ((const AJSonPrimitive*)a)->sameType((const AJSonPrimitive *)b));
|
|
|
|
|
|
|
+ return new LevenshteinMatriceWithScore(0.f, a, b, false);
|
|
|
|
|
+ return new LevenshteinMatriceWithScore(levenshteinPercent(a->stringify(), b->stringify()),
|
|
|
|
|
+ a, b, ((const AJSonPrimitive*)a)->sameType((const AJSonPrimitive *)b));
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -167,33 +168,20 @@ bool LevenshteinMatrice_manual::areSimilar() const
|
|
|
/**
|
|
/**
|
|
|
* Score matrice
|
|
* Score matrice
|
|
|
**/
|
|
**/
|
|
|
-LevenshteinMatriceWithScore::LevenshteinMatriceWithScore(float s, const JSonElement *a, const JSonElement *b)
|
|
|
|
|
-{
|
|
|
|
|
- _result = s > LEVENSHTEIN_SENSIBILITY;
|
|
|
|
|
- if (_result)
|
|
|
|
|
- {
|
|
|
|
|
- equivalentA = a;
|
|
|
|
|
- equivalentB = b;
|
|
|
|
|
- }
|
|
|
|
|
- else
|
|
|
|
|
- equivalentA = equivalentB = nullptr;
|
|
|
|
|
- operations[a] = operations[b] = (_result ? eLevenshteinOperator::equ : eLevenshteinOperator::add);
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
LevenshteinMatriceWithScore::LevenshteinMatriceWithScore(float s, const JSonElement *a, const JSonElement *b, bool sameType)
|
|
LevenshteinMatriceWithScore::LevenshteinMatriceWithScore(float s, const JSonElement *a, const JSonElement *b, bool sameType)
|
|
|
{
|
|
{
|
|
|
_result = s > LEVENSHTEIN_SENSIBILITY;
|
|
_result = s > LEVENSHTEIN_SENSIBILITY;
|
|
|
- if (_result)
|
|
|
|
|
|
|
+ if (sameType)
|
|
|
{
|
|
{
|
|
|
equivalentA = a;
|
|
equivalentA = a;
|
|
|
equivalentB = b;
|
|
equivalentB = b;
|
|
|
}
|
|
}
|
|
|
else
|
|
else
|
|
|
equivalentA = equivalentB = nullptr;
|
|
equivalentA = equivalentB = nullptr;
|
|
|
- if (_result)
|
|
|
|
|
- operations[a] = operations[b] = (sameType ? eLevenshteinOperator::equ : eLevenshteinOperator::mod);
|
|
|
|
|
|
|
+ if (sameType)
|
|
|
|
|
+ operations[a] = operations[b] = (_result ? eLevenshteinOperator::equ : eLevenshteinOperator::mod);
|
|
|
else
|
|
else
|
|
|
- operations[a] = operations[b] = eLevenshteinOperator::mod;
|
|
|
|
|
|
|
+ operations[a] = operations[b] = eLevenshteinOperator::add;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
const JSonElement * LevenshteinMatriceWithScore::getEquivalence(const JSonElement *a) const
|
|
const JSonElement * LevenshteinMatriceWithScore::getEquivalence(const JSonElement *a) const
|