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

Support emoji for MTurk import / export #1773

Merged
merged 8 commits into from
Aug 11, 2023
Merged

Conversation

yifanmai
Copy link
Collaborator

@yifanmai yifanmai commented Aug 5, 2023

Escapes emoji for Mechanical Turk exporting and importing because Mechanical Turk does not support unescaped emoji. (Error message: "Unsupported characters found")

Also updates the layout to improve whitespace formatting.

@yifanmai yifanmai requested a review from YianZhang August 5, 2023 01:56
@yifanmai
Copy link
Collaborator Author

yifanmai commented Aug 7, 2023

Updated layout:

Screenshot 2023-08-07 103628

@yifanmai yifanmai marked this pull request as ready for review August 7, 2023 17:48
@yifanmai
Copy link
Collaborator Author

yifanmai commented Aug 7, 2023

@YianZhang This is ready for review; please take a look.

characters, e.g. 😀, and replaces each 4-byte character with an
HTML span with the 4 bytes encoded as a JSON array, e.g.:

<span class='emoji-bytes' data-emoji-bytes='[240, 159, 152, 128]'></span>
Copy link
Contributor

Choose a reason for hiding this comment

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

Use double quotes?

Copy link
Contributor

@percyliang percyliang left a comment

Choose a reason for hiding this comment

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

Is there not a way to represent the emoji directly as &#x00A3; or something?

@yifanmai
Copy link
Collaborator Author

yifanmai commented Aug 8, 2023

Actually, I have no idea why I didn't think of HTML entity escaping... it should work. I'll try it out.

@yifanmai
Copy link
Collaborator Author

It works! I swapped to using HTML entities. Can't believe I didn't think about that.



# Source: https://github.com/charman/mturk-emoji
def replace_emoji_characters(s):
Copy link
Contributor

Choose a reason for hiding this comment

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

Add type hints

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Added.

Comment on lines 10 to 14
This function takes a Unicode string containing 4-byte Unicode
characters, e.g. 😀, and replaces each 4-byte character with an
HTML span with the 4 bytes encoded as a JSON array, e.g.:

<span class='emoji-bytes' data-emoji-bytes='[240, 159, 152, 128]'></span>
Copy link
Contributor

Choose a reason for hiding this comment

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

This is out of date, right?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Updated.

s (Unicode string):
Returns:
Unicode string with all 4-byte Unicode characters in the source
string replaced with HTML spans
Copy link
Contributor

Choose a reason for hiding this comment

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

Give an example?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Added example.

Copy link
Contributor

@percyliang percyliang left a comment

Choose a reason for hiding this comment

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

Nice!

@yifanmai yifanmai merged commit 46547d7 into main Aug 11, 2023
3 checks passed
@yifanmai yifanmai deleted the yifanmai/fix-mturk-emoji branch August 11, 2023 20:26
danielz02 pushed a commit to danielz02/helm that referenced this pull request Sep 7, 2023
danielz02 pushed a commit to danielz02/helm that referenced this pull request Sep 7, 2023
danielz02 pushed a commit to danielz02/helm that referenced this pull request Sep 7, 2023
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