fix emoji_map.txt
This commit is contained in:
parent
802bff017c
commit
52aa1ee126
|
@ -217,14 +217,18 @@ class App {
|
||||||
|
|
||||||
val hrefList = ArrayList<Pair<String, CodepointList>>()
|
val hrefList = ArrayList<Pair<String, CodepointList>>()
|
||||||
|
|
||||||
for( cols in root.jsonArray("qualifiedCode")!!.filterIsInstance<JsonArray>()){
|
var countError = 0
|
||||||
|
|
||||||
|
for( cols in root.jsonArray("qualifiedCode")!!.filterIsInstance<JsonArray>()) {
|
||||||
val spanText = cols[0] as String
|
val spanText = cols[0] as String
|
||||||
var href = cols[1] as String
|
var href = cols[1] as String
|
||||||
|
|
||||||
val code = spanText.listCodePoints().toCodepointList(cameFrom)
|
var code = spanText.listCodePoints().toCodepointList(cameFrom)
|
||||||
?: error("can't get code from $spanText $href")
|
?: error("can't get code from $spanText $href")
|
||||||
|
|
||||||
if( hrefList.any{ it.first == href})
|
|
||||||
|
|
||||||
|
if (hrefList.any { it.first == href })
|
||||||
error("duplicate href: $href")
|
error("duplicate href: $href")
|
||||||
|
|
||||||
hrefList.add(Pair(href, code))
|
hrefList.add(Pair(href, code))
|
||||||
|
@ -244,7 +248,14 @@ class App {
|
||||||
val key = code.toKey(cameFrom)
|
val key = code.toKey(cameFrom)
|
||||||
?: error("can't get key from ${code.toHex()} ${shortName.name}")
|
?: error("can't get key from ${code.toHex()} ${shortName.name}")
|
||||||
|
|
||||||
fixUnified[key] = code
|
if (!fixUnified.containsKey(key)) {
|
||||||
|
if (code.list.size == 1 && code.list.first() < 256) {
|
||||||
|
++countError
|
||||||
|
log.e("bad unified code: $code")
|
||||||
|
} else {
|
||||||
|
fixUnified[key] = code
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (ignoreShortName.any { it == shortName.name }) {
|
if (ignoreShortName.any { it == shortName.name }) {
|
||||||
log.w("skip shortname $shortName $code")
|
log.w("skip shortname $shortName $code")
|
||||||
|
@ -255,6 +266,8 @@ class App {
|
||||||
}
|
}
|
||||||
|
|
||||||
// hrefList.sortedBy{ it.first }.forEach { log.d("href=${it.first} ${it.second}") }
|
// hrefList.sortedBy{ it.first }.forEach { log.d("href=${it.first} ${it.second}") }
|
||||||
|
|
||||||
|
if(countError>0) error("please fix unified codes. countError=$countError")
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun addEmojipediaShortnames() {
|
private fun addEmojipediaShortnames() {
|
||||||
|
@ -299,6 +312,7 @@ class App {
|
||||||
val reCodeSpec = codeSpec.toRegex()
|
val reCodeSpec = codeSpec.toRegex()
|
||||||
var countFound = 0
|
var countFound = 0
|
||||||
var countCreate = 0
|
var countCreate = 0
|
||||||
|
var countError = 0
|
||||||
for( imageFile in dir.listFiles()!!){
|
for( imageFile in dir.listFiles()!!){
|
||||||
if (!imageFile.isFile) continue
|
if (!imageFile.isFile) continue
|
||||||
val unixPath = imageFile.path.replace("\\", "/")
|
val unixPath = imageFile.path.replace("\\", "/")
|
||||||
|
@ -318,8 +332,13 @@ class App {
|
||||||
|
|
||||||
var emoji = emojiMap[key]
|
var emoji = emojiMap[key]
|
||||||
if (emoji == null) {
|
if (emoji == null) {
|
||||||
val unified2 = fixUnified[key]
|
val unified2 = fixUnified[key] ?: unifiedQualifier(code)
|
||||||
emoji = Emoji(key, unified2 ?: unifiedQualifier(code))
|
if( unified2.list.size==1 && unified2.list.first()<256){
|
||||||
|
++countError
|
||||||
|
log.e("bad unified code: $unified2")
|
||||||
|
}
|
||||||
|
emoji = Emoji(key, unified2)
|
||||||
|
|
||||||
emojiMap[key] = emoji
|
emojiMap[key] = emoji
|
||||||
++countCreate
|
++countCreate
|
||||||
}
|
}
|
||||||
|
@ -327,7 +346,9 @@ class App {
|
||||||
emoji.imageFiles.add(Pair(imageFile, cameFrom))
|
emoji.imageFiles.add(Pair(imageFile, cameFrom))
|
||||||
emoji.addCode(code)
|
emoji.addCode(code)
|
||||||
}
|
}
|
||||||
|
|
||||||
log.d("scanImageDir: found=$countFound,create=$countCreate, dir=$dir")
|
log.d("scanImageDir: found=$countFound,create=$countCreate, dir=$dir")
|
||||||
|
if(countError>0) error("please fix unified codes. countError=$countError")
|
||||||
}
|
}
|
||||||
|
|
||||||
// サブフォルダをスキャンして絵文字別に画像データを確定する
|
// サブフォルダをスキャンして絵文字別に画像データを確定する
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -41,7 +41,7 @@ object EmojiMap {
|
||||||
fun addCode(emoji: UnicodeEmoji, code: String) {
|
fun addCode(emoji: UnicodeEmoji, code: String) {
|
||||||
if (isIgnored(code)) return
|
if (isIgnored(code)) return
|
||||||
unicodeMap[code] = emoji
|
unicodeMap[code] = emoji
|
||||||
unicodeTrie.append(code,0,emoji)
|
unicodeTrie.append(code, 0, emoji)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -112,13 +112,17 @@ object EmojiMap {
|
||||||
val category = lastCategory
|
val category = lastCategory
|
||||||
?: error("missing lastCategory.")
|
?: error("missing lastCategory.")
|
||||||
val emoji = unicodeMap[line] ?: error("missing emoji.")
|
val emoji = unicodeMap[line] ?: error("missing emoji.")
|
||||||
if (!category.emoji_list.contains(emoji))
|
// if (emoji == null) {
|
||||||
|
// Log.w("SubwayTooter", "missing emoji. lno=$lno line=$rawLine")
|
||||||
|
// } else
|
||||||
|
if (!category.emoji_list.contains(emoji)) {
|
||||||
category.emoji_list.add(emoji)
|
category.emoji_list.add(emoji)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else -> error("unknown header $head")
|
else -> error("unknown header $head")
|
||||||
}
|
}
|
||||||
} catch (ex: Throwable) {
|
} catch (ex: Throwable) {
|
||||||
Log.e("SubwayTooter","EmojiMap load error.",ex)
|
Log.e("SubwayTooter", "EmojiMap load error.", ex)
|
||||||
error("EmojiMap load error: ${ex.javaClass.simpleName} ${ex.message} lno=$lno line=$rawLine")
|
error("EmojiMap load error: ${ex.javaClass.simpleName} ${ex.message} lno=$lno line=$rawLine")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -156,9 +160,9 @@ object EmojiMap {
|
||||||
readStream(appContext, it)
|
readStream(appContext, it)
|
||||||
}
|
}
|
||||||
shortNameList.sort()
|
shortNameList.sort()
|
||||||
for( emoji in unicodeMap.values){
|
for (emoji in unicodeMap.values) {
|
||||||
if( emoji.unifiedCode.isEmpty()) error("missing unifiedCode. ${emoji.assetsName ?: emoji.drawableId.toString()}")
|
if (emoji.unifiedCode.isEmpty()) error("missing unifiedCode. ${emoji.assetsName ?: emoji.drawableId.toString()}")
|
||||||
if( emoji.unifiedName.isEmpty()) error("missing unifiedName. ${emoji.assetsName ?: emoji.drawableId.toString()}")
|
if (emoji.unifiedName.isEmpty()) error("missing unifiedName. ${emoji.assetsName ?: emoji.drawableId.toString()}")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue