AIã¿ã¤ãã«ã¢ã·ã¹ã
ãããæ¤ç´¢ã®çµæããéè¤ããããããåãé¤ããã
ãã±ã«ã®ãããæ¤ç´¢ã10ä¸ãããããæ¤ç´¢ã§ããã®ã ãã©ãæå³ãéè¤ããããããããããã¦ãæ¤ç´¢çµæãåããããã«ã°ããã«ãªã£ã¦ãã¾ããã¨ãå¤ããªã£ãã
ããã§ãæ¤ç´¢æã«åãæå³ã®ãããã¯æ¤ç´¢ãããªãããã«ããããªã£ã¦ããï¼
ä½æ¦
@deckã¨ããå¤æ°ã¯ãã¼ããããã®ã³ã¼ããå¤ããããã表ç¾ãããã¯ãã«ï¼Arrayï¼ã®Hashã§ããã
ã¹ãã¬ã¼ã¸ï¼sqlite3ï¼ããèªã¿åºããé ã§Hashãä½ã£ã¦ããã®ã ãããã®é ã工夫ããã°è¯ããããªæ°ãããã
- @deckãvalueã§åé¡ãããåé¡ã£ã¦ããã®ã¯sortã®ãã¨ãªã®ã§ãsort_byã§valueã§ä¸¦ã¹æ¿ããã°è¯ã
- ãããã®æ¤ç´¢ã®coreã®ã«ã¼ãã¯@deck.mapã§å
¨ãããã®ã¹ã³ã¢ãè¨ç®ãã¦ããã«ã¼ãã®éç¨ã§ãåããã¯ãã«ãé£ç¶ããéã¯ãµããããã«ããããããã§chunk_whileã§ã¾ã¨ãã¦å
é ãåãã°OK
ã§ãã
diff --git a/src/world.rb b/src/world.rb
index f2d9c86..005e918 100644
--- a/src/world.rb
+++ b/src/world.rb
@@ -42,7 +42,7 @@ class MasakiWorld
def _search_by_deck_core(all_deck, v, n)
norm = deck_norm(v)
return [] if norm <= 0
- all_deck.map do |b, deck_b|
+ all_deck.chunk_while{|pre, post| pre[1] == post[1]}.map(&:first).map do |b, deck_b|
c = dot(v, deck_b) / (norm * deck_norm(deck_b)) # cos
c = 0 if c + Float::EPSILON >= 1 # ignore same deck
[c, b]
@@ -143,8 +143,13 @@ class MasakiWorld
end
end
+ def sort_deck
+ @deck = @deck.sort_by {|k,v| v}.to_h
+ end
+
def make_index
make_idf
+ sort_deck
make_norm
make_name_i
end
github.com
ãã£ãã
ãããã¦ãã¿ãã
GitHub - seki/Masaki: Pokemon Card Game Util
Create my own search engine. - RubyKaigi 2022