Glench / fuzzyset.js

fuzzyset.js - A fuzzy string set for javascript
http://glench.github.io/fuzzyset.js/
Other
1.37k stars 105 forks source link

Why does Inactive Sample Find No Match but my Code Does? #34

Closed chobo2 closed 6 years ago

chobo2 commented 6 years ago

Hi

I popped this list into your interactive example

Side Shift
Condition
Drive
SubCategory
Mast Type
SubCategory
Fuel
Description
Year
Brand
Model
Capacity (LB)
Mast Height: Lowered (Inch)
Mast Height: Raised (Inch)
Serial #
Hour Meter
Location
Model #
Stock #
Height (FT)
Max Fwd Reach (FT)
Sweep Path (Inch)
Platform Wdith (Inch)
Platform Length (Inch)

and used "Equipment Id", 0.5 and no match was found. Which is great that is what I expected but when I do it in my code

const dic = FuzzySet(["Side Shift",
      "Condition",
      "Drive",
      "SubCategory",
      "Mast Type",
      "SubCategory",
      "Fuel",
      "Description",
      "Year",
      "Brand",
      "Model",
      "Capacity (LB)",
      "Mast Height: Lowered (Inch)",
      "Mast Height: Raised (Inch)",
      "Serial #",
      "Hour Meter",
      "Location",
      "Model #",
      "Stock #",
      "Height (FT)",
      "Max Fwd Reach (FT)",
      "Sweep Path (Inch)",
      "Platform Wdith (Inch)",
      "Platform Length (Inch)"], 3, 2);

  const fuzzyMatches = dic.get(Equipment Id, 0.5);

Result comes back: [0.33333333333333337, "Hour Meter"]

Glench commented 6 years ago

The get method's signature is:

get(value, [default], [minScore])

In your case, you probably want to do something like this:

const fuzzyMatches = dic.gt('Equipment Id', null, 0.5)

I see on the interactive documentation that I had an incorrect example. I just fixed that so hopefully it should be clearer.

chobo2 commented 6 years ago

@Glench

Ah, ic but would that mean fuzzMatches would = null if nothing is found and if found it would be an array of data?

Glench commented 6 years ago

Exactly. That's what currently happens when you call .get() with no [default] parameter.

chobo2 commented 6 years ago

Cool Thanks for the help.

Glench commented 6 years ago

No problem!