Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add unit tests of comparing score of similar searches #23776

Draft
wants to merge 1 commit into
base: trunk
Choose a base branch
from

Conversation

crazytonyli
Copy link
Contributor

This is more of a bug report than a PR.

I noticed that StringRankedSearch has inconsistent behavior around searching the beginning or ending part of a string.

@kean Do you mind looking at these test cases? A few of them fail, which IMO is unexpected. For example, search "42" in "0042" produces a score of 0.5, but searching it in "XX42" produces a score of 0.8.

Regression Notes

  1. Potential unintended areas of impact

  2. What I did to test those areas of impact (or what existing automated tests I relied on)

  3. What automated tests I added (or what prevented me from doing so)

PR submission checklist:

  • I have completed the Regression Notes.
  • I have considered adding unit tests for my changes.
  • I have considered adding accessibility improvements for my changes.
  • I have considered if this change warrants user-facing release notes and have added them to RELEASE-NOTES.txt if necessary.

Testing checklist:

  • WordPress.com sites and self-hosted Jetpack sites.
  • Portrait and landscape orientations.
  • Light and dark modes.
  • Fonts: Larger, smaller and bold text.
  • High contrast.
  • VoiceOver.
  • Languages with large words or with letters/accents not frequently used in English.
  • Right-to-left languages. (Even if translation isn’t complete, formatting should still respect the right-to-left layout)
  • iPhone and iPad.
  • Multi-tasking: Split view and Slide over. (iPad)

@crazytonyli crazytonyli requested a review from kean November 6, 2024 00:24
@dangermattic
Copy link
Collaborator

1 Message
📖 This PR is still a Draft: some checks will be skipped.

Generated by 🚫 Danger

@wpmobilebot
Copy link
Contributor

WordPress Alpha📲 You can test the changes from this Pull Request in WordPress Alpha by scanning the QR code below to install the corresponding build.
App NameWordPress Alpha WordPress Alpha
ConfigurationRelease-Alpha
Build Numberpr23776-cf9698c
Version25.4.2
Bundle IDorg.wordpress.alpha
Commitcf9698c
App Center BuildWPiOS - One-Offs #10999
Automatticians: You can use our internal self-serve MC tool to give yourself access to App Center if needed.

@wpmobilebot
Copy link
Contributor

Jetpack Alpha📲 You can test the changes from this Pull Request in Jetpack Alpha by scanning the QR code below to install the corresponding build.
App NameJetpack Alpha Jetpack Alpha
ConfigurationRelease-Alpha
Build Numberpr23776-cf9698c
Version25.4.2
Bundle IDcom.jetpack.alpha
Commitcf9698c
App Center Buildjetpack-installable-builds #10039
Automatticians: You can use our internal self-serve MC tool to give yourself access to App Center if needed.

@kean
Copy link
Contributor

kean commented Nov 6, 2024

Hmm, there seems to be some issue with WordPressSharedTests. The WordPressShared isnt' configured to run it when you open it from the main Xcode project.

@kean
Copy link
Contributor

kean commented Nov 6, 2024

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

The issue is with the following rule:

else if term[termIndex].isLetter != input[input.index(before: matchIndex)].isLetter {
                    score += 0.8 // Bonus: letter followed by non-letter or the other way around
                }

It heavily skews towards letter followed by non-letters. It was originally designed for searching in the list of full names and tags. This makes sure that if you search for "app" in "#john-appleseed", you get a high score. I'm not entire sure how to address it, yet, but it needs the same or similar bonus point for numbers.


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

The score in "XXAB" being lower than in "00AB" makes sense to me because of the previous rules, but since there is an exact "contains" match, it should definitely has a score higher than 0.5.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants