Further tweaks to the emoji segmentation
* lisp/international/emoji.el (emoji--parse-emoji-test): Ensure that we key off of the "person" variants, even if they come after the gendered variations (which is the case for a handful of glyphs).
This commit is contained in:
parent
df3fde6fa5
commit
6aac4caaff
1 changed files with 35 additions and 16 deletions
|
@ -305,6 +305,7 @@ the name is not known."
|
|||
(setq emoji--names (make-hash-table :test #'equal))
|
||||
(let ((derivations (make-hash-table :test #'equal))
|
||||
(case-fold-search t)
|
||||
(glyphs nil)
|
||||
group subgroup)
|
||||
(while (not (eobp))
|
||||
(cond
|
||||
|
@ -318,27 +319,40 @@ the name is not known."
|
|||
(let* ((codes (match-string 1))
|
||||
(qualification (match-string 2))
|
||||
(name (match-string 3))
|
||||
(base (emoji--base-name name derivations))
|
||||
(glyph (mapconcat
|
||||
(lambda (code)
|
||||
(string (string-to-number code 16)))
|
||||
(split-string codes))))
|
||||
;; Special-case flags.
|
||||
(when (equal base "flag")
|
||||
(setq base name))
|
||||
;; Register all glyphs to that we can look up their names
|
||||
;; later.
|
||||
(setf (gethash glyph emoji--names) name)
|
||||
;; For the interface, we only care about the fully qualified
|
||||
;; emojis.
|
||||
(when (equal qualification "fully-qualified")
|
||||
(when (equal base name)
|
||||
(emoji--add-to-group group subgroup glyph))
|
||||
;; Create mapping from base glyph name to name of
|
||||
;; derived glyphs.
|
||||
(setf (gethash base derivations)
|
||||
(nconc (gethash base derivations) (list glyph)))))))
|
||||
(push (list name qualification group subgroup glyph) glyphs))))
|
||||
(forward-line 1))
|
||||
;; We sort the data so that the "person foo" variant comes
|
||||
;; first, so that that becomes the key.
|
||||
(setq glyphs
|
||||
(sort (nreverse glyphs)
|
||||
(lambda (g1 g2)
|
||||
(and (equal (nth 2 g1) (nth 2 g2))
|
||||
(equal (nth 3 g1) (nth 3 g2))
|
||||
(< (emoji--score (car g1))
|
||||
(emoji--score (car g2)))))))
|
||||
;; Get the derivations.
|
||||
(cl-loop for (name qualification group subgroup glyph) in glyphs
|
||||
for base = (emoji--base-name name derivations)
|
||||
do
|
||||
;; Special-case flags.
|
||||
(when (equal base "flag")
|
||||
(setq base name))
|
||||
;; Register all glyphs to that we can look up their names
|
||||
;; later.
|
||||
(setf (gethash glyph emoji--names) name)
|
||||
;; For the interface, we only care about the fully qualified
|
||||
;; emojis.
|
||||
(when (equal qualification "fully-qualified")
|
||||
(when (equal base name)
|
||||
(emoji--add-to-group group subgroup glyph))
|
||||
;; Create mapping from base glyph name to name of
|
||||
;; derived glyphs.
|
||||
(setf (gethash base derivations)
|
||||
(nconc (gethash base derivations) (list glyph)))))
|
||||
;; Finally create the mapping from the base glyphs to derived ones.
|
||||
(setq emoji--derived (make-hash-table :test #'equal))
|
||||
(maphash (lambda (_k v)
|
||||
|
@ -346,6 +360,11 @@ the name is not known."
|
|||
(cdr v)))
|
||||
derivations))))
|
||||
|
||||
(defun emoji--score (string)
|
||||
(if (string-match-p "person\\|people" string)
|
||||
0
|
||||
1))
|
||||
|
||||
(defun emoji--add-to-group (group subgroup glyph)
|
||||
;; "People & Body" is very large; split it up.
|
||||
(cond
|
||||
|
|
Loading…
Add table
Reference in a new issue