emoji: repair one-shot candidate selection
This commit is contained in:
@@ -14,7 +14,7 @@
|
||||
: ☹ ☺
|
||||
:( ☹
|
||||
:) ☺
|
||||
< ← ≤ ≠ ♥
|
||||
< ← ≤ ♥ ≠
|
||||
<- ←
|
||||
<3 ♥
|
||||
<= ≤
|
||||
@@ -24,7 +24,7 @@
|
||||
=> ⇒
|
||||
> ≥
|
||||
>= ≥
|
||||
^ ⁽ ⁾ ⁺ ⁻ ⁼ ⁰ ¹ ² ³ ⁴ ⁵ ⁶ ⁷ ⁸ ⁹ ⁱ ⁿ
|
||||
^ ¹ ² ³ ⁴ ⁵ ⁶ ⁷ ⁸ ⁹ ⁽ ⁾ ⁺ ⁻ ⁼ ⁰ ⁱ ⁿ
|
||||
^( ⁽
|
||||
^) ⁾
|
||||
^+ ⁺
|
||||
@@ -42,7 +42,7 @@
|
||||
^= ⁼
|
||||
^i ⁱ
|
||||
^n ⁿ
|
||||
_ ₍ ₎ ₊ ₋ ₌ ₀ ₁ ₂ ₃ ₄ ₅ ₆ ₇ ₈ ₉ ₐ ₑ ₒ ₓ
|
||||
_ ₁ ₂ ₃ ₄ ₅ ₆ ₇ ₈ ₉ ₍ ₎ ₊ ₋ ₌ ₀ ₐ ₑ ₒ ₓ
|
||||
_( ₍
|
||||
_) ₎
|
||||
_+ ₊
|
||||
|
||||
@@ -8,12 +8,34 @@
|
||||
÷ ./
|
||||
☹ :(
|
||||
☺ :)
|
||||
|
||||
# Bare 1-9 choose prefix candidates; keep digit aliases in matching slots.
|
||||
← <-
|
||||
≤ <=
|
||||
♥ <3
|
||||
≠ <> !=
|
||||
≡ ==
|
||||
⇒ =>
|
||||
≥ >=
|
||||
¹ ^1
|
||||
² ^2
|
||||
³ ^3
|
||||
⁴ ^4
|
||||
⁵ ^5
|
||||
⁶ ^6
|
||||
⁷ ^7
|
||||
⁸ ^8
|
||||
⁹ ^9
|
||||
₁ _1
|
||||
₂ _2
|
||||
₃ _3
|
||||
₄ _4
|
||||
₅ _5
|
||||
₆ _6
|
||||
₇ _7
|
||||
₈ _8
|
||||
₉ _9
|
||||
|
||||
⁽ ^(
|
||||
⁾ ^)
|
||||
⁺ ^+
|
||||
@@ -27,25 +49,6 @@
|
||||
≈ ~=
|
||||
⁰ ^0
|
||||
₀ _0
|
||||
¹ ^1
|
||||
₁ _1
|
||||
² ^2
|
||||
₂ _2
|
||||
♥ <3
|
||||
³ ^3
|
||||
₃ _3
|
||||
⁴ ^4
|
||||
₄ _4
|
||||
⁵ ^5
|
||||
₅ _5
|
||||
⁶ ^6
|
||||
₆ _6
|
||||
⁷ ^7
|
||||
₇ _7
|
||||
⁸ ^8
|
||||
₈ _8
|
||||
⁹ ^9
|
||||
₉ _9
|
||||
ₐ _a
|
||||
α alpha
|
||||
β beta
|
||||
|
||||
15
map/mkemoji
15
map/mkemoji
@@ -7,6 +7,7 @@ from pathlib import Path
|
||||
|
||||
|
||||
SOURCE = Path(__file__).with_name("emoji.src")
|
||||
MAXRUNES = 64
|
||||
|
||||
|
||||
def fold(s):
|
||||
@@ -14,22 +15,30 @@ def fold(s):
|
||||
return unicodedata.normalize("NFC", s)
|
||||
|
||||
|
||||
def hascontrol(s):
|
||||
return any(unicodedata.category(c) == "Cc" for c in s)
|
||||
|
||||
|
||||
def read(path):
|
||||
entries = []
|
||||
with path.open(encoding="utf-8") as src:
|
||||
for lineno, raw in enumerate(src, 1):
|
||||
line = raw.rstrip("\r\n")
|
||||
if not line.strip() or line.lstrip().startswith("#"):
|
||||
if not line.strip():
|
||||
continue
|
||||
if "\t" not in line and line.lstrip().startswith("#"):
|
||||
continue
|
||||
fields = line.split("\t")
|
||||
if len(fields) < 2:
|
||||
raise ValueError(f"{path}:{lineno}: need a result and an alias")
|
||||
result = unicodedata.normalize("NFC", fields[0])
|
||||
if not result or any(c.isspace() for c in result):
|
||||
if (not result or len(result) > MAXRUNES or hascontrol(result)
|
||||
or any(c.isspace() for c in result)):
|
||||
raise ValueError(f"{path}:{lineno}: bad result")
|
||||
for field in fields[1:]:
|
||||
alias = fold(field)
|
||||
if not alias or alias != alias.strip():
|
||||
if (not alias or len(alias) > MAXRUNES or hascontrol(alias)
|
||||
or alias != alias.strip()):
|
||||
raise ValueError(f"{path}:{lineno}: bad alias")
|
||||
entries.append((result, alias))
|
||||
return entries
|
||||
|
||||
Reference in New Issue
Block a user