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

Add Support to Chinese, Korean, Spanish and Czech. #18

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@ Currently supported languages are:
* German (`de`) 🇩🇪
* Italian (`it`) 🇮🇹
* Japanese (`ja`) 🇯🇵
* Polish (`pl`) 🇵🇱
* Polish (`pl`) 🇵🇱
* Korean (`ko`) 🇰🇷
* Chinese (`zh`) 🇨🇳
* Spanish (`es`) 🇪🇸
* Czech (`cs`) 🇨🇿


🏳️‍🌈 **Adding more languages is quite easy!**
Expand Down
91 changes: 85 additions & 6 deletions mailparser_reply/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,11 +163,90 @@
],
'sent_from': 'Wysłano z'
},
'david': {
# Custom Software Headers – also kind of like a language, right?
'from_header': r'((?:^ *' + QUOTED_MATCH_INCLUDE + r'\[?Original Message processed by david.+?$\n{,4})'
+ r'(?:.*\n?){,2}' # david's non-subject line + date wildcard identification
+ r'(?:(?:^|\n|\n'
+ QUOTED_MATCH_INCLUDE + r')[* ]*(?:Von|An|Cc)(?:\s{,2}).*){2,})'
'zh': {
'wrote_header': r'^(?!.*\d{4}年\d{1,2}月\d{1,2}日.*?写道:)('
+ QUOTED_MATCH_INCLUDE
+ r'\d{4}年\d{1,2}月\d{1,2}日.*?写道:)$',
'from_header': r'((?:(?:^|\n|\n'
+ QUOTED_MATCH_INCLUDE
+ r')[* ]*(?:发件人|发送时间|收件人|主题|抄送|组织):[ *]*(?:\s{,2}).*){2,}(?:\n.*){,1})',
'disclaimers': [
'免责声明:',
'注意:',
'重要信息:',
],
'signatures': [
'此致,',
'敬礼,',
'谢谢,',
'谢谢您的关注,',
'祝好,',
],
'sent_from': r'从我的.*发送',
},
'ko': {
'wrote_header': r'^(?!.*\d{4}년 \d{1,2}월 \d{1,2}일.*?님이 작성하였습니다:)('
+ QUOTED_MATCH_INCLUDE
+ r'\d{4}년 \d{1,2}월 \d{1,2}일 .*님이 작성하였습니다:)$',
'from_header': r'((?:(?:^|\n|\n'
+ QUOTED_MATCH_INCLUDE
+ r')[* ]*(?:보낸\s?사람|보낸\s?날짜|받는\s?사람|제목|참조):[ *]*(?:\s{,2}).*){2,}(?:\n.*){,1})',
'disclaimers': [
'주의:',
'면책 조항:',
'비밀정보:',
],
'signatures': [
'감사합니다,',
'안부 전합니다,',
'좋은 하루 되세요,',
'고맙습니다,',
'감사합니다.',
],
'sent_from': r'내 .*에서 보냄',
},
'es': {
'wrote_header': r'^(?!El\s.+\s escribió:)('
+ QUOTED_MATCH_INCLUDE
+ r'El\s.+\s escribió:)$',
'from_header': r'((?:(?:^|\n|\n'
+ QUOTED_MATCH_INCLUDE
+ r')[* ]*(?:De|Enviado|Para|Asunto|Fecha|CC|Organización):[ *]*(?:\s{,2}).*){2,}(?:\n.*){,1})',
'disclaimers': [
'Aviso:',
'Confidencialidad:',
'Advertencia:',
'Descargo de responsabilidad:',
],
'signatures': [
'Saludos,',
'Atentamente,',
'Gracias,',
'Un saludo,',
'Cordialmente,',
'Muchas gracias,',
],
'sent_from': r'Enviado desde mi.*',
},
'cs': {
'wrote_header': r'^(?!Dne[.\s]*Dne\s(.+?\s?.+?)\snapsal\(a\):)('
+ QUOTED_MATCH_INCLUDE
+ r'Dne\s(?:.+?\s?.+?)\s?napsal\(a\):)$',
'from_header': r'((?:(?:^|\n|\n'
+ QUOTED_MATCH_INCLUDE
+ r')[* ]*(?:Od|Odesláno|Komu|Předmět|Datum|Kopie):[ *]*(?:\s{,2}).*){2,}(?:\n.*){,1})',
'disclaimers': [
'Upozornění:',
'Důvěrné:',
'Varování:',
],
'signatures': [
'S pozdravem,',
'S úctou,',
'Děkuji,',
'Děkujeme,',
'S přáním hezkého dne,',
],
'sent_from': r'Odesláno z mého.*',
},
}