ruby-jdict 0.0.1 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +3 -0
- data/examples/query.rb +1 -0
- data/lib/index.rb +6 -8
- data/lib/ruby-jdict/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 58dbc6bc5ed75fbff7f33a6e86c4bc490cff1de7
|
4
|
+
data.tar.gz: 312d82389911dc301efe8e21dd6df5d4433b326b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f15f93d16609e867021a3250402cf886f04718cb7d86c5e9de3dc7fba69e703fa2fab4d053df79dd6b52a594361064bae64730b062cc8ff8124d875a1f016b1c
|
7
|
+
data.tar.gz: 08252da028585416346a3cecf6d5f75813bf1a74e4127e24b979eee5f0c8e136559d16718bb0940474336be245fad6f3a7806e45a9c308f2064a57eb49da25f4
|
data/README.md
CHANGED
data/examples/query.rb
CHANGED
data/lib/index.rb
CHANGED
@@ -88,15 +88,20 @@ module JDict
|
|
88
88
|
|
89
89
|
@entries_cache = []
|
90
90
|
|
91
|
+
# convert full-width katakana to hiragana
|
92
|
+
# TODO: convert half-width katakana to hiragana
|
93
|
+
term.tr!('ァ-ン','ぁ-ん')
|
94
|
+
|
91
95
|
# search for:
|
92
96
|
# kanji... one field
|
93
97
|
# kana ... up to 10 fields
|
94
98
|
# sense... up to 10 fields
|
95
99
|
# query = 'kanji OR ' + (0..10).map { |x| "kana_#{x} OR sense_#{x}" }.join(' OR ') + ":\"#{term}\""
|
100
|
+
|
96
101
|
query = "{kanji kana senses} : \"#{term}\""
|
97
102
|
query += "*" unless exact
|
98
103
|
|
99
|
-
@index.execute("SELECT kanji, kana, senses, bm25(search) as score FROM search WHERE search MATCH
|
104
|
+
@index.execute("SELECT kanji, kana, senses, bm25(search) as score FROM search WHERE search MATCH ? LIMIT ?", query, JDict.configuration.num_results) do |row|
|
100
105
|
entry = Entry.from_sql(row)
|
101
106
|
score = 0.0
|
102
107
|
|
@@ -117,13 +122,6 @@ module JDict
|
|
117
122
|
is_exact_match = entry.kanji == term ||
|
118
123
|
entry.kana.any? { |k| k == term }
|
119
124
|
|
120
|
-
re = Regexp.new("#{term}", Regexp::IGNORECASE) # match the search term, ignoring case
|
121
|
-
# entry.senses.each do |s|
|
122
|
-
# s.glosses.each { |g| is_exact_match = is_exact_match || g.force_encoding("UTF-8").match(re) }
|
123
|
-
# end
|
124
|
-
|
125
|
-
# score = 1.0 if is_exact_match
|
126
|
-
|
127
125
|
# add the result
|
128
126
|
results << [score, entry]
|
129
127
|
end
|
data/lib/ruby-jdict/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby-jdict
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ian Pickering
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-12-
|
11
|
+
date: 2015-12-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: libxml-ruby
|