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

View file

@ -113,6 +113,8 @@ public final class AndroidSpellCheckerService extends SpellCheckerService
switch (script) {
case ScriptUtils.SCRIPT_LATIN:
return "qwerty";
case ScriptUtils.SCRIPT_ARMENIAN:
return "armenian_phonetic";
case ScriptUtils.SCRIPT_CYRILLIC:
return "east_slavic";
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.List;
import java.util.Locale;
import java.util.Map;
import java.util.TreeMap;
public abstract class AndroidWordLevelSpellCheckerSession extends Session {
private static final String TAG = AndroidWordLevelSpellCheckerSession.class.getSimpleName();
@ -62,6 +64,15 @@ public abstract class AndroidWordLevelSpellCheckerSession extends Session {
private static final String quotesRegexp =
"(\\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 {
public final String[] mSuggestions;
public final int mFlags;
@ -260,12 +271,22 @@ public abstract class AndroidWordLevelSpellCheckerSession extends Session {
final TextInfo textInfo, final NgramContext ngramContext, final int suggestionsLimit) {
try {
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,
AndroidSpellCheckerService.SINGLE_QUOTE).
replaceAll("^" + quotesRegexp, "").
replaceAll(quotesRegexp + "$", "");
final String localeRegex = scriptToPunctuationRegexMap.get(
ScriptUtils.getScriptFromSpellCheckerLocale(mLocale)
);
if (localeRegex != null) {
text = text.replaceAll(localeRegex, "");
}
if (!mService.hasMainDictionaryForLocale(mLocale)) {
return AndroidSpellCheckerService.getNotInDictEmptySuggestions(
false /* reportAsTypo */);

Binary file not shown.

View file

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

Binary file not shown.

View file

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