karmapa / AdarshaIos

📱 Tibetan sutra reader iOS app
GNU General Public License v3.0
5 stars 2 forks source link

全文檢索 wildcard ? 規則有誤差 #25

Closed chiehan1 closed 8 years ago

chiehan1 commented 8 years ago

如下列影片 https://www.youtube.com/watch?v=81R3j2CdoD0&feature=youtu.be

可以在 1.2a 找到 byed བྱེད་ 可在1.2a 找到 bcug བཅུག་ 但輸入byed ? bcug 之後並沒有標紅 1.2a的 བྱེད་དུ་བཅུག་

chiehan1 commented 8 years ago

輸入 byed ? ? bcug 才找到 1.2a的 བྱེད་དུ་བཅུག་

kmsheng commented 8 years ago

@yapcheahshen 請葉老師看看這個 issue 是怎麼回事 ? 我都是依照 realHits 標記的

yapcheahshen commented 8 years ago

這個問題可以在node.js +react.js 環境重現嗎?

2015-12-22 16:00 GMT+08:00 kmsheng notifications@github.com:

@yapcheahshen https://github.com/yapcheahshen 請葉老師看看這個 issue 是怎麼回事 ? 我都是依照 realHits 標記的

— Reply to this email directly or view it on GitHub https://github.com/karmapa/AdarshaIos/issues/25#issuecomment-166548301.

kmsheng commented 8 years ago

@yapcheahshen 舊版 web adarsha 就有此問題了, 我剛試過輸入 byed ? bcug 沒有 1.2a 這個結果

yapcheahshen commented 8 years ago

https://github.com/karmapa17/jiangkangyur/blob/master/test/testwildcard.js

塗紅的位置是正確的。 但wildcard ? 被吃掉一個,我再看看

regards, yap

2015-12-22 16:47 GMT+08:00 kmsheng notifications@github.com:

@yapcheahshen https://github.com/yapcheahshen 舊版 web adarsha 就有此問題了, 我剛試過輸入 byed?bcug 不能標

— Reply to this email directly or view it on GitHub https://github.com/karmapa/AdarshaIos/issues/25#issuecomment-166556381.

yapcheahshen commented 8 years ago

ksana-search @ 1.3.0 改進 wildcard 的處理,及修正wylie 轉換後第一個 ? 被吃掉的問題。

範例見: https://github.com/karmapa17/jiangkangyur/blob/master/test/testwildcard.js 請利用 裡頭的 fromWylieWithWildcard() 處理萬用字元以及萬用字元+數字。

為配合wylie, ? 改為 . (半形句點) 前後不必有空格

數字移到 wildcard 之後。

以下為測試的輸入,以及回應的筆數。

var q="byed.bcug"; //388 hits , with 1 unknown syllable in between var q="byed.2bcug"; //19 hits , with 2 unknown syllable in between var q="byed_bcug"; // 396 hits, with 0 or 1 unknown syllable in between var q="byed_3bcug"; // 413 hits, with 0, 1, 2, or 3 unknown syllable in between var q="byed *3 bcug"; // same as above, extra space is not required

Yap yapcheahshen@gmail.com 於 2015年12月22日 下午4:52 寫道:

https://github.com/karmapa17/jiangkangyur/blob/master/test/testwildcard.js

塗紅的位置是正確的。 但wildcard ? 被吃掉一個,我再看看

regards, yap

2015-12-22 16:47 GMT+08:00 kmsheng notifications@github.com:

@yapcheahshen https://github.com/yapcheahshen 舊版 web adarsha 就有此問題了, 我剛試過輸入 byed?bcug 不能標

— Reply to this email directly or view it on GitHub https://github.com/karmapa/AdarshaIos/issues/25#issuecomment-166556381.

kmsheng commented 8 years ago

已套用到 v1.0.27

yapcheahshen commented 8 years ago

Good, search for པ return in 3~4 seconds on iPad mini 2.

從我的 iPad 傳送

kmsheng notifications@github.com 於 2015年12月22日 下午11:13 寫道:

已套用到 v1.0.27

— Reply to this email directly or view it on GitHub.

kmsheng commented 8 years ago

@yapcheahshen 捷安說輸入 byed.bcug ( བྱེདབཅུག ) 會無法顯示結果

yapcheahshen commented 8 years ago

請參考 https://github.com/karmapa17/jiangkangyur/blob/master/test/testwildcard.js https://github.com/karmapa17/jiangkangyur/blob/master/test/testwildcard.js ksana-search@1.3.0 ksana-simple-api@1.3.3 ksana-database@1.2.9

node.js 找到

q= བྱེད?བཅུག //wylie 轉換結果

match count 190 [ '1.2a)དགག་ད...གང་བ་【བྱེད་དུ་བཅུག་】གོ། །...གང་བ་【བྱེད་དུ་བཅུག་】གོ། \n...་པའི་', '1.97a)རྒན་པ...ས་ལས་【བྱེད་དུ་བཅུག་】པར་འག...ྲག །', '1.131b)ཞིག་ན...གས་པ་【བྱེད་དུ་བཅུག་】སྟེ། ...གས་པ་【བྱེད་དུ་བཅུག་】སྟེ། ...མཐུན་', '1.240a)པ་བྱུ...ྡམ་པ་【བྱེད་དུ་བཅུག་】ནས་དག...་མདོ་', '1.272a)རྟེན་...་ཞིག་【བྱེད་དུ་བཅུག་】ནས། ད...ས་ཏེ་', '2.14b)དྷར་བ...ས་པར་【བྱེད་དུ་བཅུག་】གོ། །', '2.52b)གྱིས་...་དབང་【བྱེད་དུ་བཅུག་】ལ་རྒྱ...རྒྱལ་', '2.126a)ཁོ་བོ...འ་བར་【བྱེད་དུ་བཅུག་】ནས་ནག...་ཞིང་',

2015-12-23 14:14 GMT+08:00 kmsheng notifications@github.com:

@yapcheahshen https://github.com/yapcheahshen 捷安說輸入 byed.bcug ( བྱེདབཅུག ) 會無法顯示結果

— Reply to this email directly or view it on GitHub https://github.com/karmapa/AdarshaIos/issues/25#issuecomment-166812424.

kmsheng commented 8 years ago

@yapcheahshen 問題在於 https://github.com/ksanaforge/tibetan 沒有把 . 轉成 ? , 另一個問題是, 隨便亂輸入一些文字, kdb.filter + kdb.fetch 都會有結果 screen shot 2015-12-23 at 3 35 42 pm

yapcheahshen commented 8 years ago

因為 「?」 會被wylie 轉成下加字,所以改用 「.」 ,然後再轉成 「?」 ,ksa 才會認。

要用 https://github.com/karmapa17/jiangkangyur/blob/master/test/testwildcard.js 中的 fromWylieWithWildcard () var fromWylieWithWildcard=function(wy) { wy=wy.replace(/./g,"."); wy=wy. replace(/*/g,"※"); var r=wylie.fromWylie(wy); r=r.replace(/※/g,""); r=r. replace(/./g,"?"); r=r.replace(/([\\?])([༠༡༢༣༤༥༦༧༨༩])/g,function(m,m1,m2){ return m1+String.fromCharCode(m2.charCodeAt(0)-0x0EF0); }); return r;}

2015-12-23 15:36 GMT+08:00 kmsheng notifications@github.com:

@yapcheahshen https://github.com/yapcheahshen 問題在於 https://github.com/ksanaforge/tibetan 沒有把 . 轉成 ? , 另一個問題是, 隨便亂輸入一些文字, kdb.filter + kdb.fetch 都會有結果 [image: screen shot 2015-12-23 at 3 35 42 pm] https://cloud.githubusercontent.com/assets/880569/11972685/ddcb2890-a98a-11e5-8aa5-4c0127a33830.png

— Reply to this email directly or view it on GitHub https://github.com/karmapa/AdarshaIos/issues/25#issuecomment-166825015.

yapcheahshen commented 8 years ago

ksa.filter({db:"jiangkangyur",q:"bcudsdsdsd",phrase_sep:"།",field:"head"}) 返回 空陣列,所以不應該列「律部」。

2015-12-23 15:45 GMT+08:00 Yap yapcheahshen@gmail.com:

因為 「?」 會被wylie 轉成下加字,所以改用 「.」 ,然後再轉成 「?」 ,ksa 才會認。

要用 https://github.com/karmapa17/jiangkangyur/blob/master/test/testwildcard.js 中的 fromWylieWithWildcard () var fromWylieWithWildcard=function(wy) { wy=wy.replace(/./g,"."); wy=wy. replace(/*/g,"※"); var r=wylie.fromWylie(wy); r=r.replace(/※/g,""); r=r. replace(/./g,"?"); r=r.replace(/([\\?])([༠༡༢༣༤༥༦༧༨༩])/g,function(m,m1,m2 ){ return m1+String.fromCharCode(m2.charCodeAt(0)-0x0EF0); }); return r;}

2015-12-23 15:36 GMT+08:00 kmsheng notifications@github.com:

@yapcheahshen https://github.com/yapcheahshen 問題在於 https://github.com/ksanaforge/tibetan 沒有把 . 轉成 ? , 另一個問題是, 隨便亂輸入一些文字, kdb.filter + kdb.fetch 都會有結果 [image: screen shot 2015-12-23 at 3 35 42 pm] https://cloud.githubusercontent.com/assets/880569/11972685/ddcb2890-a98a-11e5-8aa5-4c0127a33830.png

— Reply to this email directly or view it on GitHub https://github.com/karmapa/AdarshaIos/issues/25#issuecomment-166825015.

kmsheng commented 8 years ago

@yapcheahshen fromWylieWithWildcard 是可以重複被使用的 function, 可以寫到能夠被 npm install 的模組裡面嗎? 例如 https://github.com/ksanaforge/tibetan

yapcheahshen commented 8 years ago

add fromWylieWithWildcard to ksanaforge/tibetan@1.0.5

yap

2015-12-23 15:52 GMT+08:00 kmsheng notifications@github.com:

@yapcheahshen https://github.com/yapcheahshen fromWylieWithWildcard 是可以重複被使用的 function, 可以寫到能夠被 npm install 的模組裡面嗎? 例如 https://github.com/ksanaforge/tibetan

— Reply to this email directly or view it on GitHub https://github.com/karmapa/AdarshaIos/issues/25#issuecomment-166829400.

kmsheng commented 8 years ago

因為 「?」 會被wylie 轉成下加字,所以改用 「.」 ,然後再轉成 「?」 ,ksa 才會認。 @yapcheahshen 沒有吧, 現在一個「.」就會被 fromWylie() 吃掉了

yapcheahshen commented 8 years ago

所以要用 fromWylieWithWildcard 我會先轉為全形.

kmsheng notifications@github.com 於 2015年12月23日 下午4:23 寫道:

因為 「?」 會被wylie 轉成下加字,所以改用 「.」 ,然後再轉成 「?」 ,ksa 才會認。 @yapcheahshen https://github.com/yapcheahshen 沒有吧, 現在一個「.」就會被 fromWylie() 吃掉了

— Reply to this email directly or view it on GitHub https://github.com/karmapa/AdarshaIos/issues/25#issuecomment-166832396.

yapcheahshen commented 8 years ago

先將 . 和 * 轉為全形 這樣fromWylie 就會不會破壞 wildcard。 轉成藏文後,再將 全形轉回半形,以及將 *後的藏文數字轉回ascii 數字。送給ksa.filter。

var fromWylieWithWildcard=function (wy) {wy=wy.replace(/./g,".");wy=wy. replace(/*/g,"※");var r=wylie.fromWylie(wy);r=r.replace(/※/g,"");r=r. replace(/./g,"?");r=r.replace(/([\\?])([༠༡༢༣༤༥༦༧༨༩])/g,function(m,m1,m2){ return m1+String.fromCharCode(m2.charCodeAt(0)-0x0EF0);});return r; }

Yap yapcheahshen@gmail.com 於 2015年12月23日 下午4:57 寫道:

所以要用 fromWylieWithWildcard 我會先轉為全形.

kmsheng notifications@github.com 於 2015年12月23日 下午4:23 寫道:

因為 「?」 會被wylie 轉成下加字,所以改用 「.」 ,然後再轉成 「?」 ,ksa 才會認。 @yapcheahshen https://github.com/yapcheahshen 沒有吧, 現在一個「.」就會被 fromWylie() 吃掉了

— Reply to this email directly or view it on GitHub https://github.com/karmapa/AdarshaIos/issues/25#issuecomment-166832396.

kmsheng commented 8 years ago

@yapcheahshen 光看 function 名稱, 我還以為是全新的一隻 fromWylie。原來還要墊在舊的 fromWylie 前面使用。那為什麼不直接修改 fromWylie() 就好了 ? 這樣外部使用者還要寫兩行

yapcheahshen commented 8 years ago

因為 wildcard 語法是adarsha 專用的。 我們還有其他程式呼叫 fromWylie ,所以盡量不改。 adarasha 只要改call fromWylieWithWildcard ,不必call fromWylie ,並不會增加程式行數。

kmsheng notifications@github.com 於 2015年12月23日 下午5:17 寫道:

@yapcheahshen https://github.com/yapcheahshen 光看 function 名稱, 我還以為是全新的一隻 fromWylie。原來還要墊在舊的 fromWylie 前面使用。那為什麼不直接修改 fromWylie() 就好了 ? 這樣外部使用者還要寫兩行

— Reply to this email directly or view it on GitHub https://github.com/karmapa/AdarshaIos/issues/25#issuecomment-166839959.

kmsheng commented 8 years ago

@yapcheahshen 了解, 剛剛看了 fromWylieWithWildcard 發現裡面的確有 call fromWylie。 其實就算真的要改同一隻 function, 有打 git tag 搭配 npm version 也是可以解決此問題(可以選擇性的讓想升級的專案升級, 不會被綁著什麼都不能改)。 另外, github 支援 js 的 syntax highlight, 底下為測試。

var fromWylieWithWildcard = function(wy) {

  wy = wy.replace(/\./g,".");
  wy = wy.replace(/\*/g,"※");

  var r = wylie.fromWylie(wy);

  r = r.replace(/※/g,"*");
  r = r.replace(/./g,"?");
  r = r.replace(/([\*\?])([༠༡༢༣༤༥༦༧༨༩])/g, function(m, m1, m2) {
    return m1 + String.fromCharCode(m2.charCodeAt(0) - 0x0EF0);
  });

  return r;
};
yapcheahshen commented 8 years ago

fromWylie 和 toWylie互為反函式。 fromWylie(toWylie(s))==s toWylie(fromWylie(s))==s

而 fromWylieWithWildcard 修改了 wylie transliteration 對 . 和 * 的對待方式。

kmsheng notifications@github.com 於 2015年12月23日 下午7:26 寫道:

@yapcheahshen https://github.com/yapcheahshen 了解, 剛剛看了 fromWylieWithWildcard 發現裡面的確有 call fromWylie。 其實就算真的要改同一隻 function, 有打 git tag 搭配 npm version 也是可以解決此問題(可以選擇性的讓想升級的專案升級, 不會被綁著什麼都不能改)。 另外, github 支援 js 的 syntax highlight, 底下為測試。

var fromWylieWithWildcard = function(wy) {

wy = wy.replace(/./g,"."); wy = wy.replace(/*/g,"※");

var r = wylie.fromWylie(wy);

r = r.replace(/※/g,""); r = r.replace(/./g,"?"); r = r.replace(/([\\?])([༠༡༢༣༤༥༦༧༨༩])/g, function(m, m1, m2) { return m1 + String.fromCharCode(m2.charCodeAt(0) - 0x0EF0); });

return r; };

— Reply to this email directly or view it on GitHub https://github.com/karmapa/AdarshaIos/issues/25#issuecomment-166866649.

kmsheng commented 8 years ago

fixed in v1.0.35, please reopen if issue persists