autosuggest 0.2.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fe418b5cfaa006d454a8e061ae08b63821de147677175054be5e28ad254399c6
4
- data.tar.gz: 10c28b44de11f53fccd66a3e6f547a7f97282e23b529452a1db827b3d2dd0624
3
+ metadata.gz: 380bee30bc6228daaeb97b24894e2332a0daad91a3f2dfbf6ba04dbca47b794e
4
+ data.tar.gz: 3df1265dbb5b67b234f023a5595d636d4cd3a244496a467f1b1819c2b9c693f0
5
5
  SHA512:
6
- metadata.gz: 236b65f1939693fd076445ebddff62535d1d1197e44561ade442e2c381f2d3c4bd06572daacc29718dbfb087abc1cf3c001d0152f21c9198d059d8c1d933985c
7
- data.tar.gz: 1ca979179a176b6a7eca3ee8b9593e6479680ea4706e8ad1c004d8c88efe0a1f1a82b779dee050cb1aa3c6af749323a87fc9f93c9c0c4d8eeb530a9e6a9f11cd
6
+ metadata.gz: cd036013fd6ee96dcc935c8ca5551b8c8424af5cb7c7f704617a102798bdb020f30206230876b60843ca31b9395820743b29b6c78438050ed7b69f2dd2eb68a1
7
+ data.tar.gz: 5e66bcba5ad4df678274336f53cc81063117d86a571f252bca8754b28970455de088d775fbc5e493c8910f1f47fb82fd5457c114eefe8359090771b77adc6552
data/CHANGELOG.md CHANGED
@@ -1,3 +1,13 @@
1
+ ## 0.4.0 (2025-10-26)
2
+
3
+ - Switched to keyword arguments for `parse_words` method
4
+ - Dropped support for Ruby < 3.2
5
+
6
+ ## 0.3.0 (2024-05-22)
7
+
8
+ - Switched to Mittens for stemming
9
+ - Dropped support for Ruby < 3.1
10
+
1
11
  ## 0.2.0 (2023-01-29)
2
12
 
3
13
  - Added `language` option
data/LICENSE.txt CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2015-2023 Andrew Kane
1
+ Copyright (c) 2015-2025 Andrew Kane
2
2
 
3
3
  MIT License
4
4
 
data/README.md CHANGED
@@ -4,9 +4,7 @@ Generate autocomplete suggestions based on what your users search
4
4
 
5
5
  :tangerine: Battle-tested at [Instacart](https://www.instacart.com/opensource)
6
6
 
7
- Autosuggest 0.2 was recently released! See [how to upgrade](#upgrading)
8
-
9
- [![Build Status](https://github.com/ankane/autosuggest/workflows/build/badge.svg?branch=master)](https://github.com/ankane/autosuggest/actions)
7
+ [![Build Status](https://github.com/ankane/autosuggest/actions/workflows/build.yml/badge.svg)](https://github.com/ankane/autosuggest/actions)
10
8
 
11
9
  ## Installation
12
10
 
@@ -67,7 +65,7 @@ autosuggest.not_duplicates [["straws", "straus"]]
67
65
 
68
66
  #### Filter misspellings
69
67
 
70
- We tried open-source libraries like [Aspell](http://aspell.net) and [Hunspell](http://hunspell.sourceforge.net/) but quickly realized we needed to build a corpus specific to our application.
68
+ We tried open-source libraries like [Aspell](http://aspell.net) and [Hunspell](https://github.com/hunspell/hunspell) but quickly realized we needed to build a corpus specific to our application.
71
69
 
72
70
  There are two ways to build the corpus, which can be used together.
73
71
 
@@ -123,7 +121,7 @@ Autosuggest::Suggestion.transaction do
123
121
  end
124
122
  ```
125
123
 
126
- Leave out `unique_by` for MySQL, and use [activerecord-import](https://github.com/zdennis/activerecord-import) for upserts with Rails < 6.
124
+ Leave out `unique_by` for MySQL.
127
125
 
128
126
  #### Show suggestions
129
127
 
@@ -201,16 +199,6 @@ Autosuggest::Suggestion.transaction do
201
199
  end
202
200
  ```
203
201
 
204
- ## Upgrading
205
-
206
- ### 0.2.0
207
-
208
- Suggestions are now filtered by default, and only the query and score are returned. To get all queries and fields, use:
209
-
210
- ```ruby
211
- autosuggest.suggestions(filter: false)
212
- ```
213
-
214
202
  ## History
215
203
 
216
204
  View the [changelog](https://github.com/ankane/autosuggest/blob/master/CHANGELOG.md)
@@ -10,8 +10,8 @@ module Autosuggest
10
10
  @profane_words = {}
11
11
  @concept_tree = {}
12
12
  begin
13
- @stemmer = Lingua::Stemmer.new(language: language)
14
- rescue Lingua::StemmerError
13
+ @stemmer = Mittens::Stemmer.new(language: language)
14
+ rescue ArgumentError
15
15
  raise ArgumentError, "Language not available"
16
16
  end
17
17
  # TODO take language into account for profanity
@@ -24,9 +24,7 @@ module Autosuggest
24
24
  @concepts[name] = Set.new(values.map(&:downcase))
25
25
  end
26
26
 
27
- def parse_words(phrases, options = {})
28
- min = options[:min] || 1
29
-
27
+ def parse_words(phrases, min: 1)
30
28
  word_counts = Hash.new(0)
31
29
  phrases.each do |phrase|
32
30
  words = tokenize(phrase)
@@ -1,3 +1,3 @@
1
1
  module Autosuggest
2
- VERSION = "0.2.0"
2
+ VERSION = "0.4.0"
3
3
  end
data/lib/autosuggest.rb CHANGED
@@ -3,7 +3,7 @@ require "set"
3
3
  require "yaml" # for obscenity
4
4
 
5
5
  # dependencies
6
- require "lingua/stemmer"
6
+ require "mittens"
7
7
  require "obscenity"
8
8
 
9
9
  # modules
@@ -22,11 +22,7 @@ module Autosuggest
22
22
  # use connection_config instead of connection.adapter
23
23
  # so database connection isn't needed
24
24
  def adapter
25
- if ActiveRecord::VERSION::STRING.to_f >= 6.1
26
- ActiveRecord::Base.connection_db_config.adapter.to_s
27
- else
28
- ActiveRecord::Base.connection_config[:adapter].to_s
29
- end
25
+ ActiveRecord::Base.connection_db_config.adapter.to_s
30
26
  end
31
27
  end
32
28
  end
metadata CHANGED
@@ -1,17 +1,16 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: autosuggest
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Kane
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2023-01-30 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
- name: ruby-stemmer
13
+ name: mittens
15
14
  requirement: !ruby/object:Gem::Requirement
16
15
  requirements:
17
16
  - - ">="
@@ -38,7 +37,6 @@ dependencies:
38
37
  - - ">="
39
38
  - !ruby/object:Gem::Version
40
39
  version: '0'
41
- description:
42
40
  email: andrew@ankane.org
43
41
  executables: []
44
42
  extensions: []
@@ -57,7 +55,6 @@ homepage: https://github.com/ankane/autosuggest
57
55
  licenses:
58
56
  - MIT
59
57
  metadata: {}
60
- post_install_message:
61
58
  rdoc_options: []
62
59
  require_paths:
63
60
  - lib
@@ -65,15 +62,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
65
62
  requirements:
66
63
  - - ">="
67
64
  - !ruby/object:Gem::Version
68
- version: '2.7'
65
+ version: '3.2'
69
66
  required_rubygems_version: !ruby/object:Gem::Requirement
70
67
  requirements:
71
68
  - - ">="
72
69
  - !ruby/object:Gem::Version
73
70
  version: '0'
74
71
  requirements: []
75
- rubygems_version: 3.4.1
76
- signing_key:
72
+ rubygems_version: 3.6.9
77
73
  specification_version: 4
78
74
  summary: Generate autocomplete suggestions based on what your users search
79
75
  test_files: []