Skip to content

Commit

Permalink
#96 remove repeat nouns and keep capitalized/upper versions
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewtavis committed Apr 16, 2023
1 parent af553b4 commit d9e3cb0
Showing 1 changed file with 26 additions and 20 deletions.
46 changes: 26 additions & 20 deletions Keyboards/KeyboardsBase/LoadData.swift
Original file line number Diff line number Diff line change
Expand Up @@ -157,24 +157,7 @@ func createAutocompleteLexicon() {
let createLexiconQuery = """
INSERT INTO autocomplete_lexicon (word)
SELECT DISTINCT
-- Select an upper case or capitalized noun if it's available.
CASE
WHEN
UPPER(full_lexicon.word) = nouns.noun
THEN
nouns.noun
WHEN
UPPER(SUBSTR(full_lexicon.word, 1, 1)) || SUBSTR(full_lexicon.word, 2) = nouns.noun
THEN
nouns.noun
ELSE
full_lexicon.word
END
FROM (
WITH full_lexicon AS (
SELECT
noun AS word
FROM
Expand Down Expand Up @@ -206,9 +189,29 @@ func createAutocompleteLexicon() {
word AS word
FROM
emoji_keywords
) AS full_lexicon
)
SELECT DISTINCT
-- Select an upper case or capitalized noun if it's available.
CASE
WHEN
UPPER(full_lexicon.word) = nouns.noun
THEN
nouns.noun
WHEN
UPPER(SUBSTR(full_lexicon.word, 1, 1)) || SUBSTR(full_lexicon.word, 2) = nouns.noun
THEN
nouns.noun
ELSE
full_lexicon.word
END
FROM
full_lexicon
LEFT JOIN
JOIN
nouns
ON
Expand All @@ -217,6 +220,9 @@ func createAutocompleteLexicon() {
WHERE
LENGTH(full_lexicon.word) > 1
AND full_lexicon.word NOT LIKE '%-%'
AND full_lexicon.word NOT LIKE '%/%'
AND full_lexicon.word NOT LIKE '%(%'
AND full_lexicon.word NOT LIKE '%)%'
"""
do {
try languageDB.write { db in
Expand Down

0 comments on commit d9e3cb0

Please sign in to comment.