|
1 | 1 | package org.unicode.tools.emoji; |
2 | 2 |
|
3 | 3 | import com.google.common.base.Splitter; |
4 | | -import com.google.common.collect.ImmutableMap; |
5 | 4 | import com.google.common.collect.ImmutableMultimap; |
6 | 5 | import com.google.common.collect.ImmutableSet; |
7 | 6 | import com.google.common.collect.Multimap; |
@@ -173,7 +172,7 @@ public String formatProposalsForHtml(Collection<String> proposals) { |
173 | 172 | static UnicodeMap<Set<String>> load(StringBuffer header) { |
174 | 173 | UnicodeMap<Set<String>> builder = new UnicodeMap<>(); |
175 | 174 | Set<String> skinProposals = ImmutableSet.<String>builder().add("L2/14-173").build(); |
176 | | - Set<String> genProposals = ImmutableSet.<String>builder().add("L2/16‑160").build(); |
| 175 | + Set<String> genProposals = ImmutableSet.<String>builder().add("L2/16-160").build(); |
177 | 176 |
|
178 | 177 | boolean haveData = false; |
179 | 178 | for (String line : FileUtilities.in(ProposalData.class, "proposalData.txt")) { |
@@ -313,32 +312,27 @@ public static Set<String> cleanProposalString(String proposalString) { |
313 | 312 | return ImmutableSet.copyOf(result); |
314 | 313 | } |
315 | 314 |
|
316 | | - static final Map<String, String> SHORTEST_SKELETON = |
317 | | - ImmutableMap.<String, String>builder() |
318 | | - .put("🧑🏿❤️💋🧑🏿", "💏🏿") |
319 | | - .put("🧑🏿❤️🧑🏿", "💑🏿") |
320 | | - .put("👨🏿🐰👨🏿", "👯🏿") |
321 | | - .put("👩🏿🐰👩🏿", "👯🏿") |
322 | | - .put("🧑🏿🐰🧑🏿", "👯🏿") |
323 | | - .put("👨🏿👨🏿", "🤼🏿") |
324 | | - .put("👩🏿👩🏿", "🤼🏿") |
325 | | - .put("🧑🏿🧑🏿", "🤼🏿") |
326 | | - .build(); |
327 | | - |
328 | | - // static { |
329 | | - // for (Entry<String, String> entry : SHORTEST_SKELETON.entrySet()) { |
330 | | - // System.out.println(".put(\"" + entry.getKey() + "\",\"" + entry.getValue() + "\")" |
331 | | - // + "\t// " + Utility.hex(entry.getKey()) + " => " + |
332 | | - // Utility.hex(entry.getValue())); |
333 | | - // } |
334 | | - // } |
335 | | - |
336 | 315 | private static String shortestForm(String s) { |
337 | | - String result = SHORTEST_SKELETON.get(s); |
338 | | - if (result == null) { |
339 | | - return s; |
| 316 | + if (EmojiData.EMOJI_DATA_BETA.isHandshake(s)) { |
| 317 | + // All handshake sequences have the same proposal. |
| 318 | + return EmojiData.HANDSHAKE_STRING; |
340 | 319 | } |
341 | | - return result; |
| 320 | + |
| 321 | + // Use the existing mapping maintained by EmojiData, |
| 322 | + // adding emoji variants for sequences containing ❤️. |
| 323 | + String withoutTone = EmojiData.SKIN_SPANNER.deleteFrom(s); |
| 324 | + String standardized = EmojiData.EMOJI_DATA_BETA.addEmojiVariants(withoutTone); |
| 325 | + String couple = EmojiData.MAP_TO_COUPLES.get(standardized); |
| 326 | + if (couple != null) { |
| 327 | + if (s.indexOf(SKIN_REPRESENTATIVE) >= 0) { |
| 328 | + // The provided string has normalized skin tone(s) and |
| 329 | + // the result is a single code point, re-add the tone. |
| 330 | + couple += SKIN_REPRESENTATIVE; |
| 331 | + } |
| 332 | + return couple; |
| 333 | + } |
| 334 | + |
| 335 | + return s; |
342 | 336 | } |
343 | 337 |
|
344 | 338 | public static String removeEmojiVariant(String s) { |
|
0 commit comments