Skip to content

Commit

Permalink
Merge pull request #199 from tomwojcik/add-count-unique-emojis
Browse files Browse the repository at this point in the history
add support for count unique
  • Loading branch information
TahirJalilov committed Jan 13, 2022
2 parents e35fc45 + 5aebf67 commit efbb3e1
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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 efbb3e1

Please sign in to comment.