(text, stickerCatalog)
| 1968 | } |
| 1969 | |
| 1970 | function rankStickerNamesByText(text, stickerCatalog) { |
| 1971 | const normalizedText = normalizeSemanticText(text); |
| 1972 | return (stickerCatalog || []) |
| 1973 | .map((item) => ({ |
| 1974 | name: item.name, |
| 1975 | score: scoreStickerNameAgainstText(item.name, normalizedText) |
| 1976 | })) |
| 1977 | .filter((item) => item.score > 0) |
| 1978 | .sort((a, b) => b.score - a.score || a.name.localeCompare(b.name, "zh-Hans-CN")); |
| 1979 | } |
| 1980 | |
| 1981 | function scoreStickerNameAgainstText(name, normalizedText) { |
| 1982 | const normalizedName = normalizeSemanticText(name); |
no test coverage detected