wordpress-mobile / wordpress-mobile/WordPress-iOS

StringRankedSearch inconsistent results when numbers and letters are mixed

Open
#24,274 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

[Type] Enhancement General
Dominant language
Swift
Stars
3.9k
Forks
1.2k
Avg merge
23h 51m
Merged PRs (30d)
58

Description

Demonstrated by the following unit tests (originally reported here https://github.com/wordpress-mobile/WordPress-iOS/pull/23776/):

  func testSearchBeginingOrEnd() {
         XCTAssertEqual(score("AB00", "AB"), score("ABXX", "AB"), accuracy: 0.1)
         XCTAssertEqual(score("4200", "42"), score("42XX", "42"), accuracy: 0.1)

         XCTAssertEqual(score("00AB", "AB"), score("XXAB", "AB"), accuracy: 0.1)
         XCTAssertEqual(score("0042", "42"), score("XX42", "42"), accuracy: 0.1)

         XCTAssertEqual(score("AB_00", "AB"), score("AB_XX", "AB"), accuracy: 0.1)
         XCTAssertEqual(score("42_00", "42"), score("42_XX", "42"), accuracy: 0.1)

         XCTAssertEqual(score("00_AB", "AB"), score("XX_AB", "AB"), accuracy: 0.1)
         XCTAssertEqual(score("00_42", "42"), score("XX_42", "42"), accuracy: 0.1)

         XCTAssertEqual(score("AB/00", "AB"), score("AB/XX", "AB"), accuracy: 0.1)
         XCTAssertEqual(score("42/00", "42"), score("42/XX", "42"), accuracy: 0.1)

         XCTAssertEqual(score("00/AB", "AB"), score("XX/AB", "AB"), accuracy: 0.1)
         XCTAssertEqual(score("00/42", "42"), score("XX/42", "42"), accuracy: 0.1)
     }

     func testCompareSearchNumbersAndLetters() {
         XCTAssertEqual(score("42XX", "42"), score("ABXX", "AB"), accuracy: 0.1)
         XCTAssertEqual(score("0042", "42"), score("XXAB", "AB"), accuracy: 0.1)
         XCTAssertEqual(score("42_00", "42"), score("AB_XX", "AB"), accuracy: 0.1)
         XCTAssertEqual(score("00_42", "42"), score("XX_AB", "AB"), accuracy: 0.1)
         XCTAssertEqual(score("42/00", "42"), score("AB/XX", "AB"), accuracy: 0.1)
         XCTAssertEqual(score("00/42", "42"), score("XX/AB", "AB"), accuracy: 0.1)
     }

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating StringRankedSearch and the unit-test target containing the score(...) helper. Use the demonstrated assertions as regression criteria for mixed numbers and letters, including separators and matches at either end. Done means all listed comparisons pass with the stated accuracy.

Written by the indexing model from the issue text.

Assessment

Tech stack
ios, swift
Domain
mobile-dev, search
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.