-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
411: Add typo-tolerance APIs r=curquiza a=Sherlouk # Pull Request ## Related issue Fixes #282 ## What does this PR do? - Adds support for reading, updating, and resetting typo-tolerance preferences ## PR checklist Please check if your PR fulfills the following requirements: - [x] Does this PR fix an existing issue, or have you listed the changes applied in the PR description (and why they are needed)? - [x] Have you read the contributing guidelines? - [x] Have you made sure that the title is accurate and descriptive of the changes? Thank you so much for contributing to Meilisearch! Co-authored-by: James Sherlock <15193942+Sherlouk@users.noreply.github.com>
- Loading branch information
Showing
9 changed files
with
386 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import Foundation | ||
|
||
/** | ||
`TypoTolerance` settings provided by the user. | ||
*/ | ||
public struct TypoTolerance: Codable, Equatable { | ||
// MARK: Properties | ||
|
||
/// Whether typo tolerance is enabled or not | ||
public let enabled: Bool? | ||
|
||
/// The minimum word size for accepting typos | ||
public let minWordSizeForTypos: MinWordSize? | ||
|
||
/// An array of words for which the typo tolerance feature is disabled | ||
public let disableOnWords: [String]? | ||
|
||
/// An array of attributes for which the typo tolerance feature is disabled | ||
public let disableOnAttributes: [String]? | ||
|
||
public struct MinWordSize: Codable, Equatable { | ||
/// The minimum word size for accepting 1 typo; must be between 0 and `twoTypos` | ||
public let oneTypo: Int? | ||
|
||
/// The minimum word size for accepting 2 typos; must be between `oneTypo` and 255 | ||
public let twoTypos: Int? | ||
|
||
public init( | ||
oneTypo: Int? = nil, | ||
twoTypos: Int? = nil | ||
) { | ||
self.oneTypo = oneTypo | ||
self.twoTypos = twoTypos | ||
} | ||
} | ||
|
||
public init( | ||
enabled: Bool? = nil, | ||
minWordSizeForTypos: TypoTolerance.MinWordSize? = nil, | ||
disableOnWords: [String]? = nil, | ||
disableOnAttributes: [String]? = nil | ||
) { | ||
self.enabled = enabled | ||
self.minWordSizeForTypos = minWordSizeForTypos | ||
self.disableOnWords = disableOnWords | ||
self.disableOnAttributes = disableOnAttributes | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import Foundation | ||
|
||
/** | ||
`TypoToleranceResult` instances represent the current typo tolerance settings. | ||
*/ | ||
public struct TypoToleranceResult: Codable, Equatable { | ||
// MARK: Properties | ||
|
||
/// Whether typo tolerance is enabled or not | ||
public let enabled: Bool | ||
|
||
/// The minimum word size for accepting typos | ||
public let minWordSizeForTypos: MinWordSize | ||
|
||
/// An array of words for which the typo tolerance feature is disabled | ||
public let disableOnWords: [String] | ||
|
||
/// An array of attributes for which the typo tolerance feature is disabled | ||
public let disableOnAttributes: [String] | ||
|
||
public struct MinWordSize: Codable, Equatable { | ||
/// The minimum word size for accepting 1 typo; must be between 0 and `twoTypos` | ||
public let oneTypo: Int | ||
|
||
/// The minimum word size for accepting 2 typos; must be between `oneTypo` and 255 | ||
public let twoTypos: Int | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.