Better support for Armenian language

This commit is contained in:
Yeghishe Piruzyan 2022-04-17 22:30:31 -07:00 committed by amcoder36
parent 9da38ca9e4
commit e46783fd9d
7 changed files with 77 additions and 40 deletions

View file

@ -2169,18 +2169,25 @@ public final class KeyboardTextsTable {
/* morekeys_nordic_row2_11 ~ */ /* morekeys_nordic_row2_11 ~ */
null, null, null, null, null, null, null, null, null, null, null, null, null, null,
/* ~ morekeys_swiss_row2_11 */ /* ~ morekeys_swiss_row2_11 */
// U+055E: "՞" ARMENIAN QUESTION MARK //
// U+055C: "՜" ARMENIAN EXCLAMATION MARK // ( U+0028 "(" Բացվող փակագիծ - OPENING PARENTHESES
// U+055A: "՚" ARMENIAN APOSTROPHE // ) U+0029 ")" Փակվող փակագիծ - CLOSING PARENTHESES
// U+0559: "ՙ" ARMENIAN MODIFIER LETTER LEFT HALF RING // ' U+0027 "'" Ապաթարց - APOSTROPHE
// U+055D: "՝" ARMENIAN COMMA // … U+2026 "" Կախման կետեր
// U+055B: "՛" ARMENIAN EMPHASIS MARK // ՞ U+055E "՞" Հարցական - ARMENIAN QUESTION MARK
// U+058A: "֊" ARMENIAN HYPHEN // ՜ U+055C "՜" Բացականչական - ARMENIAN EXCLAMATION MARK
// U+00BB: "»" RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK // ՛ U+055B "՛" Շեշտ
// U+00AB: "«" LEFT-POINTING DOUBLE ANGLE QUOTATION MARK // ՝ U+055D "՝" Բութ
// U+055F: "՟" ARMENIAN ABBREVIATION MARK // ֊ U+058A "֊" Միության գծիկ - ARMENIAN HYPHEN
/* morekeys_punctuation */ "!autoColumnOrder!8,\\,,\u055E,\u055C,.,\u055A,\u0559,?,!,\u055D,\u055B,\u058A,\u00BB,\u00AB,\u055F,;,:", // ― U+2015 "" Անջատման գժիկ - ARMENIAN SEPARATION MARK
/* keyspec_tablet_comma */ "\u055D", // « U+00AB "«" Բացվող չակերտ - LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
// » U+00BB "»" Փակվող չակերտ - RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
// , U+002C "," Ստօրակետ - ARMENIAN COMMA
// ։ U+0589 "։" Վերջակետ - ARMENIAN COLON
// ․ U+2024 "" Միջակետ
//
/* morekeys_punctuation */ "!autoColumnOrder!8,\\,,\u055E,\u055C,\u2024,\u2026,',=,/,\u055D,\u055B,\u058A,\u00BB,\u00AB,\u2015,),(",
/* keyspec_tablet_comma */ ",",
/* morekeys_star ~ */ /* morekeys_star ~ */
null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null,
/* ~ keyspec_right_single_angle_quote */ /* ~ keyspec_right_single_angle_quote */
@ -2188,13 +2195,12 @@ public final class KeyboardTextsTable {
// TODO: Enable this when we have glyph for the following letter // TODO: Enable this when we have glyph for the following letter
// <string name="keyspec_currency">&#x058F;</string> // <string name="keyspec_currency">&#x058F;</string>
// //
// U+055D: "՝" ARMENIAN COMMA // U+002C: "," ARMENIAN COMMA
/* keyspec_comma */ "\u055D", /* keyspec_comma */ ",",
/* morekeys_tablet_comma */ null, /* morekeys_tablet_comma */ null,
/* keyhintlabel_period */ null, /* keyhintlabel_period */ null,
// U+055E: "՞" ARMENIAN QUESTION MARK // U+055E: "՞" ARMENIAN QUESTION MARK
// U+00BF: "¿" INVERTED QUESTION MARK /* morekeys_question */ "\u055E",
/* morekeys_question */ "\u055E,\u00BF",
/* morekeys_h ~ */ /* morekeys_h ~ */
null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null,
null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null,
@ -2202,8 +2208,7 @@ public final class KeyboardTextsTable {
null, null, null, null, null, null,
/* ~ morekeys_greater_than */ /* ~ morekeys_greater_than */
// U+055C: "՜" ARMENIAN EXCLAMATION MARK // U+055C: "՜" ARMENIAN EXCLAMATION MARK
// U+00A1: "¡" INVERTED EXCLAMATION MARK /* morekeys_exclamation */ "\u055C",
/* morekeys_exclamation */ "\u055C,\u00A1",
}; };
/* Locale is: Icelandic */ /* Locale is: Icelandic */

View file

@ -113,6 +113,8 @@ public final class AndroidSpellCheckerService extends SpellCheckerService
switch (script) { switch (script) {
case ScriptUtils.SCRIPT_LATIN: case ScriptUtils.SCRIPT_LATIN:
return "qwerty"; return "qwerty";
case ScriptUtils.SCRIPT_ARMENIAN:
return "armenian_phonetic";
case ScriptUtils.SCRIPT_CYRILLIC: case ScriptUtils.SCRIPT_CYRILLIC:
return "east_slavic"; return "east_slavic";
case ScriptUtils.SCRIPT_GREEK: case ScriptUtils.SCRIPT_GREEK:

View file

@ -45,6 +45,8 @@ import org.dslul.openboard.inputmethod.latin.utils.SuggestionResults;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Locale; import java.util.Locale;
import java.util.Map;
import java.util.TreeMap;
public abstract class AndroidWordLevelSpellCheckerSession extends Session { public abstract class AndroidWordLevelSpellCheckerSession extends Session {
private static final String TAG = AndroidWordLevelSpellCheckerSession.class.getSimpleName(); private static final String TAG = AndroidWordLevelSpellCheckerSession.class.getSimpleName();
@ -62,6 +64,15 @@ public abstract class AndroidWordLevelSpellCheckerSession extends Session {
private static final String quotesRegexp = private static final String quotesRegexp =
"(\\u0022|\\u0027|\\u0060|\\u00B4|\\u2018|\\u2018|\\u201C|\\u201D)"; "(\\u0022|\\u0027|\\u0060|\\u00B4|\\u2018|\\u2018|\\u201C|\\u201D)";
private static final Map<Integer, String> scriptToPunctuationRegexMap = new TreeMap<>();
static {
scriptToPunctuationRegexMap.put(
ScriptUtils.SCRIPT_ARMENIAN,
"(\\u0028|\\u0029|\\u0027|\\u2026|\\u055E|\\u055C|\\u055B|\\u055D|\\u058A|\\u2015|\\u00AB|\\u00BB|\\u002C|\\u0589|\\u2024)"
);
}
private static final class SuggestionsParams { private static final class SuggestionsParams {
public final String[] mSuggestions; public final String[] mSuggestions;
public final int mFlags; public final int mFlags;
@ -260,12 +271,22 @@ public abstract class AndroidWordLevelSpellCheckerSession extends Session {
final TextInfo textInfo, final NgramContext ngramContext, final int suggestionsLimit) { final TextInfo textInfo, final NgramContext ngramContext, final int suggestionsLimit) {
try { try {
updateLocale(); updateLocale();
final String text = textInfo.getText(). // It's good to keep this not local specific since the standard
// ones may show up in other languages also.
String text = textInfo.getText().
replaceAll(AndroidSpellCheckerService.APOSTROPHE, replaceAll(AndroidSpellCheckerService.APOSTROPHE,
AndroidSpellCheckerService.SINGLE_QUOTE). AndroidSpellCheckerService.SINGLE_QUOTE).
replaceAll("^" + quotesRegexp, ""). replaceAll("^" + quotesRegexp, "").
replaceAll(quotesRegexp + "$", ""); replaceAll(quotesRegexp + "$", "");
final String localeRegex = scriptToPunctuationRegexMap.get(
ScriptUtils.getScriptFromSpellCheckerLocale(mLocale)
);
if (localeRegex != null) {
text = text.replaceAll(localeRegex, "");
}
if (!mService.hasMainDictionaryForLocale(mLocale)) { if (!mService.hasMainDictionaryForLocale(mLocale)) {
return AndroidSpellCheckerService.getNotInDictEmptySuggestions( return AndroidSpellCheckerService.getNotInDictEmptySuggestions(
false /* reportAsTypo */); false /* reportAsTypo */);

Binary file not shown.

View file

@ -55,6 +55,10 @@
android:label="@string/subtype_generic" android:label="@string/subtype_generic"
android:subtypeLocale="ru" android:subtypeLocale="ru"
/> />
<subtype
android:label="@string/subtype_generic"
android:subtypeLocale="hy"
/>
<subtype <subtype
android:label="@string/subtype_generic" android:label="@string/subtype_generic"
android:subtypeLocale="pt_BR" android:subtypeLocale="pt_BR"

Binary file not shown.

View file

@ -23,30 +23,35 @@
U+0532: "Բ" ARMENIAN CAPITAL LETTER BEN U+0532: "Բ" ARMENIAN CAPITAL LETTER BEN
U+0533: "Գ" ARMENIAN CAPITAL LETTER GIM --> U+0533: "Գ" ARMENIAN CAPITAL LETTER GIM -->
<string name="keylabel_to_alpha">&#x0531;&#x0532;&#x0533;</string> <string name="keylabel_to_alpha">&#x0531;&#x0532;&#x0533;</string>
<!-- U+055E: "՞" ARMENIAN QUESTION MARK <!--
U+055C: "՜" ARMENIAN EXCLAMATION MARK &#x0028; U+0028 "(" Բացվող փակագիծ - OPENING PARENTHESES
U+055A: "՚" ARMENIAN APOSTROPHE &#x0029; U+0029 ")" Փակվող փակագիծ - CLOSING PARENTHESES
U+0559: "ՙ" ARMENIAN MODIFIER LETTER LEFT HALF RING &#x0027; U+0027 "'" Ապաթարց - APOSTROPHE
U+055D: "՝" ARMENIAN COMMA &#x2026; U+2026 "…" Կախման կետեր
U+055B: "՛" ARMENIAN EMPHASIS MARK &#x055E; U+055E "՞" Հարցական - ARMENIAN QUESTION MARK
U+058A: "֊" ARMENIAN HYPHEN &#x055C; U+055C "՜" Բացականչական - ARMENIAN EXCLAMATION MARK
U+00BB: "»" RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK &#x055B; U+055B "՛" Շեշտ
U+00AB: "«" LEFT-POINTING DOUBLE ANGLE QUOTATION MARK &#x055D; U+055D "՝" Բութ
U+055F: "՟" ARMENIAN ABBREVIATION MARK --> &#x058A; U+058A "֊" Միության գծիկ - ARMENIAN HYPHEN
<string name="morekeys_punctuation">"!autoColumnOrder!8,\\,,&#x055E;,&#x055C;,.,&#x055A;,&#x0559;,?,!,&#x055D;,&#x055B;,&#x058A;,&#x00BB;,&#x00AB;,&#x055F;,;,:"</string> &#x2015; U+2015 "―" Անջատման գժիկ - ARMENIAN SEPARATION MARK
<!-- U+055E: "՞" ARMENIAN QUESTION MARK &#x00AB; U+00AB "«" Բացվող չակերտ - LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
U+00BF: "¿" INVERTED QUESTION MARK --> &#x00BB; U+00BB "»" Փակվող չակերտ - RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
<string name="morekeys_question">&#x055E;,&#x00BF;</string> &#x002C; U+002C "," Ստօրակետ - ARMENIAN COMMA
<!-- U+055C: "՜" ARMENIAN EXCLAMATION MARK &#x0589; U+0589 "։" Վերջակետ - ARMENIAN COLON
U+00A1: "¡" INVERTED EXCLAMATION MARK --> &#x2024; U+2024 "" Միջակետ
<string name="morekeys_exclamation">&#x055C;,&#x00A1;</string> -->
<string name="morekeys_punctuation">"!autoColumnOrder!8,\\,,&#x055E;,&#x055C;,&#x2024;,&#x2026;,&#x0027;,&#x003D;,&#x002F;,&#x055D;,&#x055B;,&#x058A;,&#x00BB;,&#x00AB;,&#x2015;,&#x0029;,&#x0028;"</string>
<!-- U+055E: "՞" ARMENIAN QUESTION MARK -->
<string name="morekeys_question">&#x055E;</string>
<!-- U+055C: "՜" ARMENIAN EXCLAMATION MARK -->
<string name="morekeys_exclamation">&#x055C;</string>
<!-- U+058F: "֏" ARMENIAN DRAM SIGN --> <!-- U+058F: "֏" ARMENIAN DRAM SIGN -->
<!-- TODO: Enable this when we have glyph for the following letter <!-- TODO: Enable this when we have glyph for the following letter
<string name="keyspec_currency">&#x058F;</string> <string name="keyspec_currency">&#x058F;</string>
--> -->
<!-- U+055D: "՝" ARMENIAN COMMA --> <!-- U+002C: "," ARMENIAN COMMA -->
<string name="keyspec_comma">&#x055D;</string> <string name="keyspec_comma">&#x002C;</string>
<string name="keyspec_tablet_comma">&#x055D;</string> <string name="keyspec_tablet_comma">&#x002C;</string>
<!-- U+0589: "։" ARMENIAN FULL STOP --> <!-- U+0589: "։" ARMENIAN FULL STOP -->
<string name="keyspec_period">&#x0589;</string> <string name="keyspec_period">&#x0589;</string>
<string name="keyspec_tablet_period">&#x0589;</string> <string name="keyspec_tablet_period">&#x0589;</string>