ruby / ruby/did_you_mean

TreeSpellChecker: cases where it doesn't work as expected?

Open
#166 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Ruby
Stars
1.9k
Forks
113
PR merge metrics
No merged PRs in 30d

Description

I've just started playing with TreeSpellChecker and found a couple of cases where it doesn't give me the corrections I would expect.

If I run this script in ruby-3.0.3:

#!/usr/bin/env ruby
require 'set'

paths = [
  "dir/typo",
  "typo",
]
sc = DidYouMean::TreeSpellChecker.new(dictionary: paths)
puts "*** none slashed:"
puts sc.correct("tyop")

paths = [
  "dir/typo",
  "typo",
]
sc = DidYouMean::TreeSpellChecker.new(dictionary: paths)
puts "*** query slashed:"
puts sc.correct("/tyop")

paths = [
  "dir/typo",
  "/typo",
]
sc = DidYouMean::TreeSpellChecker.new(dictionary: paths)
puts "*** dict slashed:"
puts sc.correct("tyop")

paths = [
  "dir/typo",
  "/typo",
]
sc = DidYouMean::TreeSpellChecker.new(dictionary: paths)
puts "*** both slashed:"
puts sc.correct("/tyop")

I get this output:

*** none slashed:
*** query slashed:
dir/typo
*** dict slashed:
*** both slashed:
/typo

And I think in all the cases, the second path on the list (either typo or /typo) should be suggested.

What do you think? ✨✨✨
cc @yuki24

Contributor guide

No contributing guide indexed for this repository

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 with the TreeSpellChecker entry point and run the four Ruby examples from the issue to reproduce the slash and dictionary combinations. Trace how correct handles these paths, then verify that each case suggests the second path shown in the examples.

Written by the indexing model from the issue text.

Assessment

Tech stack
ruby
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.