Tìm hoặc xóa chính xác biểu tượng cảm xúc khỏi một đốm văn bản bằng cách sử dụng dữ liệu từ kho lưu trữ mã biểu tượng cảm xúc của Unicode Consortium
Những thay đổi chính trong phiên bản 1. x
Phiên bản 1. x của
$ cat out.txt All done! ✨ 🍰 ✨ $ demoji out.txt All done! :sparkles: :shortcake: :sparkles: $ echo 'All done! ✨ 🍰 ✨' | demoji All done! :sparkles: :shortcake: :sparkles: $ demoji - we didnt start the 🔥 we didnt start the :fire:4 hiện gói dữ liệu Unicode trong gói khi cài đặt thay vì yêu cầu tải xuống mã từ unicode. org trong thời gian chạy. Vui lòng xem THAY ĐỔI. md để biết chi tiết và làm quen với các thay đổi trước khi cập nhật từ 0. x đến 1. x
Để báo cáo bất kỳ hồi quy nào, vui lòng mở vấn đề GitHub
Sử dụng cơ bản
$ cat out.txt All done! ✨ 🍰 ✨ $ demoji out.txt All done! :sparkles: :shortcake: :sparkles: $ echo 'All done! ✨ 🍰 ✨' | demoji All done! :sparkles: :shortcake: :sparkles: $ demoji - we didnt start the 🔥 we didnt start the :fire:4 xuất một số chức năng liên quan đến văn bản cho chức năng tìm và thay thế bằng biểu tượng cảm xúc
>>> tweet = """\ .. #startspreadingthenews yankees win great start by 🎅🏾 going 5strong innings with 5k’s🔥 🐂 .. solo homerun 🌋🌋 with 2 solo homeruns and👹 3run homerun… 🤡 🚣🏼 👨🏽⚖️ with rbi’s … 🔥🔥 .. 🇲🇽 and 🇳🇮 to close the game🔥🔥!!!…. .. WHAT A GAME!!.. .. """ >>> demoji.findall[tweet] { "🔥": "fire", "🌋": "volcano", "👨🏽\u200d⚖️": "man judge: medium skin tone", "🎅🏾": "Santa Claus: medium-dark skin tone", "🇲🇽": "flag: Mexico", "👹": "ogre", "🤡": "clown face", "🇳🇮": "flag: Nicaragua", "🚣🏼": "person rowing boat: medium-light skin tone", "🐂": "ox", }
Xem bên dưới để biết API chức năng
Sử dụng dòng lệnh
Bạn có thể sử dụng
$ cat out.txt All done! ✨ 🍰 ✨ $ demoji out.txt All done! :sparkles: :shortcake: :sparkles: $ echo 'All done! ✨ 🍰 ✨' | demoji All done! :sparkles: :shortcake: :sparkles: $ demoji - we didnt start the 🔥 we didnt start the :fire:4 hoặc
$ cat out.txt All done! ✨ 🍰 ✨ $ demoji out.txt All done! :sparkles: :shortcake: :sparkles: $ echo 'All done! ✨ 🍰 ✨' | demoji All done! :sparkles: :shortcake: :sparkles: $ demoji - we didnt start the 🔥 we didnt start the :fire:1 để thay thế các biểu tượng cảm xúc trong [các] tệp hoặc stdin bằng các biểu tượng tương đương với
$ cat out.txt All done! ✨ 🍰 ✨ $ demoji out.txt All done! :sparkles: :shortcake: :sparkles: $ echo 'All done! ✨ 🍰 ✨' | demoji All done! :sparkles: :shortcake: :sparkles: $ demoji - we didnt start the 🔥 we didnt start the :fire:2 của chúng
$ cat out.txt All done! ✨ 🍰 ✨ $ demoji out.txt All done! :sparkles: :shortcake: :sparkles: $ echo 'All done! ✨ 🍰 ✨' | demoji All done! :sparkles: :shortcake: :sparkles: $ demoji - we didnt start the 🔥 we didnt start the :fire:
Thẩm quyền giải quyết
findall[string: str] -> Dict[str, str]
Tìm biểu tượng cảm xúc trong
$ cat out.txt All done! ✨ 🍰 ✨ $ demoji out.txt All done! :sparkles: :shortcake: :sparkles: $ echo 'All done! ✨ 🍰 ✨' | demoji All done! :sparkles: :shortcake: :sparkles: $ demoji - we didnt start the 🔥 we didnt start the :fire:3. Trả về ánh xạ của
$ cat out.txt All done! ✨ 🍰 ✨ $ demoji out.txt All done! :sparkles: :shortcake: :sparkles: $ echo 'All done! ✨ 🍰 ✨' | demoji All done! :sparkles: :shortcake: :sparkles: $ demoji - we didnt start the 🔥 we didnt start the :fire:4
findall_list[string: str, desc: bool = True] -> List[str]
Tìm biểu tượng cảm xúc trong
$ cat out.txt All done! ✨ 🍰 ✨ $ demoji out.txt All done! :sparkles: :shortcake: :sparkles: $ echo 'All done! ✨ 🍰 ✨' | demoji All done! :sparkles: :shortcake: :sparkles: $ demoji - we didnt start the 🔥 we didnt start the :fire:3. Trả về một danh sách [có thể trùng lặp]
Nếu
$ cat out.txt All done! ✨ 🍰 ✨ $ demoji out.txt All done! :sparkles: :shortcake: :sparkles: $ echo 'All done! ✨ 🍰 ✨' | demoji All done! :sparkles: :shortcake: :sparkles: $ demoji - we didnt start the 🔥 we didnt start the :fire:6 là True, danh sách chứa mã mô tả. Nếu
$ cat out.txt All done! ✨ 🍰 ✨ $ demoji out.txt All done! :sparkles: :shortcake: :sparkles: $ echo 'All done! ✨ 🍰 ✨' | demoji All done! :sparkles: :shortcake: :sparkles: $ demoji - we didnt start the 🔥 we didnt start the :fire:6 là Sai, danh sách chứa biểu tượng cảm xúc
$ cat out.txt All done! ✨ 🍰 ✨ $ demoji out.txt All done! :sparkles: :shortcake: :sparkles: $ echo 'All done! ✨ 🍰 ✨' | demoji All done! :sparkles: :shortcake: :sparkles: $ demoji - we didnt start the 🔥 we didnt start the :fire:1
Thay thế biểu tượng cảm xúc trong
$ cat out.txt All done! ✨ 🍰 ✨ $ demoji out.txt All done! :sparkles: :shortcake: :sparkles: $ echo 'All done! ✨ 🍰 ✨' | demoji All done! :sparkles: :shortcake: :sparkles: $ demoji - we didnt start the 🔥 we didnt start the :fire:3 bằng
$ cat out.txt All done! ✨ 🍰 ✨ $ demoji out.txt All done! :sparkles: :shortcake: :sparkles: $ echo 'All done! ✨ 🍰 ✨' | demoji All done! :sparkles: :shortcake: :sparkles: $ demoji - we didnt start the 🔥 we didnt start the :fire:9
$ cat out.txt All done! ✨ 🍰 ✨ $ demoji out.txt All done! :sparkles: :shortcake: :sparkles: $ echo 'All done! ✨ 🍰 ✨' | demoji All done! :sparkles: :shortcake: :sparkles: $ demoji - we didnt start the 🔥 we didnt start the :fire:4
Thay thế biểu tượng cảm xúc trong
$ cat out.txt All done! ✨ 🍰 ✨ $ demoji out.txt All done! :sparkles: :shortcake: :sparkles: $ echo 'All done! ✨ 🍰 ✨' | demoji All done! :sparkles: :shortcake: :sparkles: $ demoji - we didnt start the 🔥 we didnt start the :fire:3 bằng mã mô tả của chúng. Các mã được bao quanh bởi
findall[string: str] -> Dict[str, str]1
$ cat out.txt All done! ✨ 🍰 ✨ $ demoji out.txt All done! :sparkles: :shortcake: :sparkles: $ echo 'All done! ✨ 🍰 ✨' | demoji All done! :sparkles: :shortcake: :sparkles: $ demoji - we didnt start the 🔥 we didnt start the :fire:7
Hiển thị dấu thời gian của lần tải xuống cuối cùng cho dữ liệu biểu tượng cảm xúc đi kèm với gói
chú thích cuối trang. chuỗi biểu tượng cảm xúc
Nhiều biểu tượng cảm xúc trông giống như các ký tự Unicode đơn lẻ thực sự là các chuỗi nhiều ký tự. ví dụ
- Keycap 2️⃣ thực tế là 3 ký tự, U+0032 [chữ số ASCII 2], U+FE0F [bộ chọn biến thể] và U+20E3 [kết hợp keycap kèm theo]
- Quốc kỳ Scotland 7 ký tự thành phần, ký hiệu hoàn toàn bỏ qua là
findall[string: str] -> Dict[str, str]
2
[Bạn có thể thấy bất kỳ thứ nào trong số này thông qua
findall[string: str] -> Dict[str, str]3. ]
$ cat out.txt All done! ✨ 🍰 ✨ $ demoji out.txt All done! :sparkles: :shortcake: :sparkles: $ echo 'All done! ✨ 🍰 ✨' | demoji All done! :sparkles: :shortcake: :sparkles: $ demoji - we didnt start the 🔥 we didnt start the :fire:4 cẩn thận xử lý việc này và nên tìm các chuỗi đầy đủ thay vì các thành phần phụ không đầy đủ của chúng
Cách nó thực hiện điều này là sắp xếp các mã biểu tượng cảm xúc theo độ dài của chúng, sau đó biên dịch một biểu thức chính quy được nối sẽ tham lam tìm kiếm các biểu tượng cảm xúc dài hơn trước, sau đó quay lại các biểu tượng cảm xúc ngắn hơn nếu không tìm thấy. Đây hoàn toàn không phải là một cách tìm kiếm siêu tối ưu vì nó có thuộc tính O[N2], mà trọng tâm là tính chính xác và đầy đủ
$ cat out.txt All done! ✨ 🍰 ✨ $ demoji out.txt All done! :sparkles: :shortcake: :sparkles: $ echo 'All done! ✨ 🍰 ✨' | demoji All done! :sparkles: :shortcake: :sparkles: $ demoji - we didnt start the 🔥 we didnt start the :fire:0
1. 1. 0
- Thêm một
findall[string: str] -> Dict[str, str]
5 để cho phép chạy$ cat out.txt All done! ✨ 🍰 ✨ $ demoji out.txt All done! :sparkles: :shortcake: :sparkles: $ echo 'All done! ✨ 🍰 ✨' | demoji All done! :sparkles: :shortcake: :sparkles: $ demoji - we didnt start the 🔥 we didnt start the :fire:
1; . Đóng góp của @jap
1. 0. 0
Đây là bản phát hành không tương thích ngược với một số thay đổi đáng kể
Thay đổi lớn nhất là
$ cat out.txt All done! ✨ 🍰 ✨ $ demoji out.txt All done! :sparkles: :shortcake: :sparkles: $ echo 'All done! ✨ 🍰 ✨' | demoji All done! :sparkles: :shortcake: :sparkles: $ demoji - we didnt start the 🔥 we didnt start the :fire:4 giờ đây gói một bản sao tĩnh của dữ liệu biểu tượng cảm xúc Unicode với gói khi cài đặt, thay vì yêu cầu tải xuống mã trong thời gian chạy từ unicode. tổ chức