init datamate

This commit is contained in:
Dallas98
2025-10-21 23:00:48 +08:00
commit 1c97afed7d
692 changed files with 135442 additions and 0 deletions

View File

@@ -0,0 +1,6 @@
# -*- coding: utf-8 -*-
from datamate.core.base_op import OPERATORS
OPERATORS.register_module(module_name='EmojiCleaner',
module_path="ops.mapper.emoji_cleaner.process")

View File

@@ -0,0 +1,16 @@
name: '文档表情去除'
name_en: 'Emoticon Removal'
description: '去除文档中表情字符或者emoji符号。'
description_en: 'Removes emoticons or emojis from documents.'
language: 'python'
vendor: 'huawei'
raw_id: 'EmojiCleaner'
version: '1.0.0'
types:
- 'cleanse'
modal: 'text'
effect:
before: '使用方式很简单,只需要将代码放入Markdown文本中即可,富文本格式可直接复制表情😀使用。'
after: '使用方式很简单,只需要将代码放入Markdown文本中即可,富文本格式可直接复制表情使用。'
inputs: 'text'
outputs: 'text'

View File

@@ -0,0 +1,27 @@
"""
Description: 文档表情去除
Create: 2023/12/7 15:43
"""
import time
from typing import Dict, Any
import emoji
from loguru import logger
from datamate.core.base_op import Mapper
class EmojiCleaner(Mapper):
@staticmethod
def _emoji_filter(input_data: str):
res = []
for input_s in input_data.split('\n'):
res.append(emoji.replace_emoji(input_s, replace=''))
return '\n'.join(res)
def execute(self, sample: Dict[str, Any]) -> Dict[str, Any]:
start = time.time()
sample[self.text_key] = self._emoji_filter(sample[self.text_key])
logger.info(f"fileName: {sample[self.filename_key]}, method: EmojiCleaner costs {time.time() - start:6f} s")
return sample