Soeren.oldag has submitted this change and it was merged.
Change subject: Fix tests and set new threshold
......................................................................
Fix tests and set new threshold
Change-Id: I3738eb96beb2ac67e3deb1158ddee4efe4495e26
---
M includes/CrossCheck/Comparer/StringComparer.php
M tests/phpunit/CrossCheck/Comparer/StringComparerTest.php
M tests/phpunit/Violations/CrossCheckViolationContextTest.php
3 files changed, 23 insertions(+), 9 deletions(-)
Approvals:
Soeren.oldag: Verified; Looks good to me, approved
diff --git a/includes/CrossCheck/Comparer/StringComparer.php
b/includes/CrossCheck/Comparer/StringComparer.php
index 757d1aa..aa09a96 100755
--- a/includes/CrossCheck/Comparer/StringComparer.php
+++ b/includes/CrossCheck/Comparer/StringComparer.php
@@ -17,7 +17,7 @@
/**
* Threshold for matching compliance in prefix/suffix similarity checks
*/
- const SIMILARITY_THRESHOLD = 0.8;
+ const SIMILARITY_THRESHOLD = 0.75;
/**
* Compares two strings with each other.
@@ -181,7 +181,7 @@
$prefixLength++;
}
- return $prefixLength / max ( $localLength, $externalLength );
+ return $prefixLength / max ( $localLength, $externalLength );
}
/**
@@ -218,7 +218,6 @@
private function percentageLevenshteinDistance( $value, $comparativeValue
) {
$distance = levenshtein( $value, $comparativeValue );
$percentage = 1.0 - $distance/max( strlen( $value ), strlen(
$comparativeValue ) );
-
return $percentage;
}
}
diff --git a/tests/phpunit/CrossCheck/Comparer/StringComparerTest.php
b/tests/phpunit/CrossCheck/Comparer/StringComparerTest.php
index 561b4e2..542bdf7 100755
--- a/tests/phpunit/CrossCheck/Comparer/StringComparerTest.php
+++ b/tests/phpunit/CrossCheck/Comparer/StringComparerTest.php
@@ -112,6 +112,11 @@
'oobar',
CompareResult::STATUS_PARTIAL_MATCH
),
+ array(
+ 'New York City',
+ 'New York City, NY',
+ CompareResult::STATUS_PARTIAL_MATCH
+ ),
// levenshtein partial match
array(
'foobar',
@@ -133,6 +138,11 @@
'Schloßstraße',
CompareResult::STATUS_PARTIAL_MATCH
),
+ array(
+ 'Yoko Ono',
+ 'Yōko Ono',
+ CompareResult::STATUS_PARTIAL_MATCH
+ ),
// mismatches
array(
'fo',
@@ -158,7 +168,12 @@
'Johanna von Österreich',
'Johanna',
CompareResult::STATUS_MISMATCH
- )
+ ),
+ array(
+ 'New York',
+ 'New York, NY',
+ CompareResult::STATUS_MISMATCH
+ )
);
}
diff --git a/tests/phpunit/Violations/CrossCheckViolationContextTest.php
b/tests/phpunit/Violations/CrossCheckViolationContextTest.php
index 08c9289..d9e0844 100755
--- a/tests/phpunit/Violations/CrossCheckViolationContextTest.php
+++ b/tests/phpunit/Violations/CrossCheckViolationContextTest.php
@@ -95,21 +95,21 @@
/**
- * @dataProvider getIconPathDataProvider
+ * @dataProvider getIconClassDataProvider
*/
- public function testGetIconPath( $violation, $expectedException = null ) {
+ public function testGetIconClass( $violation, $expectedException = null ) {
$this->setExpectedException( $expectedException );
- $actualResult = $this->violationContext->getIconPath( $violation );
+ $actualResult = $this->violationContext->getIconClass( $violation );
$this->assertTrue( is_string( $actualResult ) );
}
/**
- * Test cases for getIconPathDataProvider
+ * Test cases for getIconClassDataProvider
* @return array
*/
- public function getIconPathDataProvider() {
+ public function getIconClassDataProvider() {
return array(
array(
$this->getViolationMock( new ItemId( 'Q42' ), 'foobar',
'wbqev|foobar' )
--
To view, visit https://gerrit.wikimedia.org/r/216670
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I3738eb96beb2ac67e3deb1158ddee4efe4495e26
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/WikidataQualityExternalValidation
Gerrit-Branch: master
Gerrit-Owner: Dominic.sauer <[email protected]>
Gerrit-Reviewer: Soeren.oldag <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits