diff --git a/emoji/core.py b/emoji/core.py index d9967a31..23849598 100644 --- a/emoji/core.py +++ b/emoji/core.py @@ -293,8 +293,13 @@ def distinct_emoji_lis(string, language=None): return distinct_list -def emoji_count(string): - """Returns the count of emojis in a string.""" +def emoji_count(string, unique=False): + """Returns the count of emojis in a string. + + :param unique: (optional) True if count only unique emojis + """ + if unique: + return len(distinct_emoji_lis(string)) return len(emoji_lis(string)) diff --git a/tests/test_core.py b/tests/test_core.py index b3386d16..e5bb7a10 100644 --- a/tests/test_core.py +++ b/tests/test_core.py @@ -256,6 +256,7 @@ def test_emoji_count(): assert emoji.emoji_count('Hi, I am fine. 😁') == 1 assert emoji.emoji_count('Hi') == 0 assert emoji.emoji_count('Hello πŸ‡«πŸ‡·πŸ‘Œ') == 2 + assert emoji.emoji_count('Hello πŸ‡΅πŸ‡±πŸΊπŸ‡΅πŸ‡±', unique=True) == 2 def test_replace_emoji():