Skip to content

Commit

Permalink
add support for count unique
Browse files Browse the repository at this point in the history
  • Loading branch information
tomwojcik committed Jan 5, 2022
1 parent e35fc45 commit 5aebf67
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
9 changes: 7 additions & 2 deletions emoji/core.py
Expand Up @@ -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))


Expand Down
1 change: 1 addition & 0 deletions tests/test_core.py
Expand Up @@ -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():
Expand Down

0 comments on commit 5aebf67

Please sign in to comment.