Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update stats.py #10

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Update stats.py #10

wants to merge 1 commit into from

Conversation

alizare84
Copy link

better handling of odd character!

better handling of odd character!
@@ -30,14 +30,14 @@ def __init__(self, chat_json: Union[str, Path]):
"""
# load chat data
logger.info(f"Loading chat data from {chat_json}")
with open(chat_json) as f:
with open(chat_json, encoding='UTF8') as f:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello Ali and thanks for the PR.
Encoding of JSON files extracted from Telegram is UTF-8 and It is a good idea to identify the encoding of files when reading them. Thanks for this suggestion.

@@ -128,7 +128,29 @@ def de_emojify(self, text):

:param text: Text that contains emoji
"""
regrex_pattern = re.compile(pattern="[\u2069\u2066]+", flags=re.UNICODE)
regrex_pattern = re.compile(pattern="["
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since in the next line the demoji.replace(text, " ") is responsible for deleting all the emojis, we do not need to delete each emoji separately.

You can find the emojis that method demoji.replace() handles in the package document:
https://unicode.org/Public/emoji/14.0/emoji-sequences.txt

@siniorone
Copy link
Collaborator

siniorone commented Jan 30, 2022

It is better to make changes in a branch and then send PRs. alizare84:alizare84_encoding instead of alizare84:main in your personal forked repo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants