From fcda8437784c4b6734f2c54ea90bfa02c9d122ac Mon Sep 17 00:00:00 2001 From: Kirtan Purohit Date: Wed, 29 Jan 2020 04:50:52 -0800 Subject: [PATCH 1/2] All: Resolves #2279: Handle Thai language in search (#2387) * Update SearchEngine.js use basicSearch if thai string * Update string-utils.js added thai regex support * Update services_SearchEngine.js added thai language test * Update services_SearchEngine.js remove trailing spaces --- CliClient/tests/services_SearchEngine.js | 10 ++++++++++ ReactNativeClient/lib/services/SearchEngine.js | 2 +- ReactNativeClient/lib/string-utils.js | 2 ++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/CliClient/tests/services_SearchEngine.js b/CliClient/tests/services_SearchEngine.js index a798d65829..ec3da92221 100644 --- a/CliClient/tests/services_SearchEngine.js +++ b/CliClient/tests/services_SearchEngine.js @@ -258,6 +258,16 @@ describe('services_SearchEngine', function() { expect((await engine.search('말')).length).toBe(1); })); + it('should support queries with Thai characters', asyncTest(async () => { + let rows; + const n1 = await Note.save({ title: 'นี่คือคนไทย' }); + + await engine.syncTables(); + + expect((await engine.search('นี่คือค')).length).toBe(1); + expect((await engine.search('ไทย')).length).toBe(1); + })); + it('should support field restricted queries with Chinese characters', asyncTest(async () => { let rows; const n1 = await Note.save({ title: '你好', body: '我是法国人' }); diff --git a/ReactNativeClient/lib/services/SearchEngine.js b/ReactNativeClient/lib/services/SearchEngine.js index 9dfe5f5387..337c58db95 100644 --- a/ReactNativeClient/lib/services/SearchEngine.js +++ b/ReactNativeClient/lib/services/SearchEngine.js @@ -386,7 +386,7 @@ class SearchEngine { const st = scriptType(query); - if (!Setting.value('db.ftsEnabled') || ['ja', 'zh', 'ko'].indexOf(st) >= 0) { + if (!Setting.value('db.ftsEnabled') || ['ja', 'zh', 'ko', 'th'].indexOf(st) >= 0) { // Non-alphabetical languages aren't support by SQLite FTS (except with extensions which are not available in all platforms) return this.basicSearch(query); } else { diff --git a/ReactNativeClient/lib/string-utils.js b/ReactNativeClient/lib/string-utils.js index 67418df991..c5dcd08918 100644 --- a/ReactNativeClient/lib/string-utils.js +++ b/ReactNativeClient/lib/string-utils.js @@ -267,6 +267,7 @@ function substrWithEllipsis(s, start, length) { const REGEX_JAPANESE = /[\u3000-\u303f]|[\u3040-\u309f]|[\u30a0-\u30ff]|[\uff00-\uff9f]|[\u4e00-\u9faf]|[\u3400-\u4dbf]/; const REGEX_CHINESE = /[\u4e00-\u9fff]|[\u3400-\u4dbf]|[\u{20000}-\u{2a6df}]|[\u{2a700}-\u{2b73f}]|[\u{2b740}-\u{2b81f}]|[\u{2b820}-\u{2ceaf}]|[\uf900-\ufaff]|[\u3300-\u33ff]|[\ufe30-\ufe4f]|[\uf900-\ufaff]|[\u{2f800}-\u{2fa1f}]/u; const REGEX_KOREAN = /[\uac00-\ud7af]|[\u1100-\u11ff]|[\u3130-\u318f]|[\ua960-\ua97f]|[\ud7b0-\ud7ff]/; +const REGEX_THAI = /[\u0e00-\u0e7f]/; function scriptType(s) { // A string entirely with Chinese character will be detected as Japanese too @@ -274,6 +275,7 @@ function scriptType(s) { if (REGEX_CHINESE.test(s)) return 'zh'; if (REGEX_JAPANESE.test(s)) return 'ja'; if (REGEX_KOREAN.test(s)) return 'ko'; + if (REGEX_THAI.test(s)) return 'th'; return 'en'; } From 59c8a87047e61a2bc45fccf9a2fd62f5e73b3c28 Mon Sep 17 00:00:00 2001 From: Marton Paulo Date: Thu, 30 Jan 2020 17:55:23 -0300 Subject: [PATCH 2/2] Remove personal e-mail address eo.po pt_BR.po (#2414) * Remove personal e-mail address * Remove personal e-mail address * Remove personal e-mail address * Revert "Remove personal e-mail address" This reverts commit 7a66c4a5b63874f5233cdb1628917adf662cbbca. * Remove space * Remove space --- CliClient/locales/eo.po | 4 ++-- CliClient/locales/pt_BR.po | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CliClient/locales/eo.po b/CliClient/locales/eo.po index c399511e8e..c1ead7f95d 100644 --- a/CliClient/locales/eo.po +++ b/CliClient/locales/eo.po @@ -1,13 +1,13 @@ # SOME DESCRIPTIVE TITLE. # Copyright (C) YEAR Laurent Cozic # This file is distributed under the same license as the Joplin-CLI package. -# Marton Paulo , 2019. +# Marton Paulo, 2019. # msgid "" msgstr "" "Project-Id-Version: Joplin-CLI 1.0.0\n" "Report-Msgid-Bugs-To: \n" -"Last-Translator: Marton Paulo \n" +"Last-Translator: Marton Paulo\n" "Language-Team: \n" "Language: eo\n" "MIME-Version: 1.0\n" diff --git a/CliClient/locales/pt_BR.po b/CliClient/locales/pt_BR.po index d5f35b09c5..9d49ec7630 100644 --- a/CliClient/locales/pt_BR.po +++ b/CliClient/locales/pt_BR.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: Joplin-CLI 1.0.0\n" "Report-Msgid-Bugs-To: \n" -"Last-Translator: Marton Paulo \n" +"Last-Translator: Marton Paulo\n" "Language-Team: \n" "Language: pt_BR\n" "MIME-Version: 1.0\n"