Skip to content

Commit 96c0347

Browse files
committed
update function names
1 parent c3f6f34 commit 96c0347

File tree

4 files changed

+7
-7
lines changed

4 files changed

+7
-7
lines changed

Fuzzywuzzy_swift/StringMatcher.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public class StringMatcher: NSObject {
2121
super.init()
2222
}
2323

24-
public func ratio() -> Float {
24+
public func fuzzRatio() -> Float {
2525
let lenSum = (str1.characters.count + str2.characters.count)
2626
if lenSum == 0 { return 1 }
2727
return Float(lenSum - levenshteinDistance) / Float(lenSum)

Fuzzywuzzy_swift/String_Fuzzywuzzy.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@ import UIKit
1010

1111
public extension String {
1212
/// Basic Scoring Functions
13-
static public func ratio(str1 str1: String, str2: String) -> Int {
13+
static public func fuzzRatio(str1 str1: String, str2: String) -> Int {
1414
let m = StringMatcher(str1: str1, str2: str2)
15-
return Int(m.ratio() * 100)
15+
return Int(m.fuzzRatio() * 100)
1616
}
1717

1818
/// trys to match the shorter string with the most common substring of the longer one
19-
static public func partialRatio(str1 str1: String, str2: String) -> Int {
19+
static public func fuzzPartialRatio(str1 str1: String, str2: String) -> Int {
2020
let shorter: String
2121
let longer: String
2222
if str1.characters.count < str2.characters.count {
@@ -44,7 +44,7 @@ public extension String {
4444
let longSubEnd = longSubStart.advancedBy(shorter.characters.count-1)
4545

4646
let longSubStr = longer.substringWithRange(Range(longSubStart...longSubEnd))
47-
let r = StringMatcher(str1: shorter, str2: longSubStr).ratio()
47+
let r = StringMatcher(str1: shorter, str2: longSubStr).fuzzRatio()
4848
if r > 0.995 { /// magic number appears in original python code
4949
return 1
5050
} else {

Fuzzywuzzy_swiftTests/Fuzzywuzzy_swiftTests.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class Fuzzywuzzy_swiftTests: XCTestCase {
2626
for (str1, str2) in strPairs {
2727
print("STR1: \(str1)")
2828
print("STR2: \(str2)")
29-
print("PARTIO RATIO: \(String.partialRatio(str1: str1, str2: str2))")
29+
print("PARTIO RATIO: \(String.fuzzPartialRatio(str1: str1, str2: str2))")
3030
print("-----------------")
3131
}
3232
}
@@ -50,7 +50,7 @@ class Fuzzywuzzy_swiftTests: XCTestCase {
5050
let strPairs = [("some", ""), ("", "some"), ("", ""), ("我好hungry", "我好饿啊啊啊啊"), ("我好饿啊啊啊啊", "好烦啊")]
5151
for (str1, str2) in strPairs {
5252
let matcher = StringMatcher(str1: str1, str2: str2)
53-
let ratio = matcher.ratio()
53+
let ratio = matcher.fuzzRatio()
5454
XCTAssert(ratio <= 1 && ratio >= 0)
5555
print("STR1: \(str1)")
5656
print("STR2: \(str2)")

0 commit comments

Comments
 (0)