J'ai pris l'expression rationnelle suivante pour extraire le texte de l'émoticône du twitter japonais avec python.python: extraire le texte de l'émoticône du texte twitter japonais avec regex
// this is for extracting number, character, Japanese
text2 = r'[0-9A-Za-zぁ-んァ-ン一-龥]'
non_text = r'[^0-9A-Za-zぁ-んァ-ン一-龥]'
// this is for extracting text that are allowed in Japanese emoticons
allow_text = r'[ovっつ゜ニノ三二]'
hw_kana = r'[ヲ-゚]'
open_branket = r'[\(∩ (]'
close_branket = r'[\)∩ )]'
arround_face = r'(?:' + non_text + '|' + allow_text + ')*'
face = r'(?!(?:' + text2 + '|' + hw_kana + '){3,}).{3,}'
face_string = arround_face + open_branket + face + close_branket +
arround_face
p_face = re.compile(face_string)
string1 = 'ふう。お腹いっぱい(´•౪•`), 試験頑張るぞ\\\\ ٩(‘ω’)و ////'
string2 = '心の相談は メール [email protected] までご連絡ください'
string3 = 'ドーピング系浪人生(n=1)'
string4 = '横浜は関内にある「 BAY らっきょ 」に初訪問してまいりました関東スープカレーブームの火付け役となったお店の「 人気NO.1 チキンカレー 」をいただきました(´∀`人)'
string5 = '鳥取県倉吉市 倉吉農業高校 3年食品科 (音楽部・茶道部) AKB48大ファン高校生!まゆゆ、中野郁海ちゃん神推し m0326w。♥。・゚♡゚・。♥。i0820n~現在♥大好きだよ♥ AKBファンの方はフォローお願いします^-^ \n\n来春から新社会人・・・の予定(´・ω・`) '
string6 = 'うわ。。(-_-;)授業。運動会はなくなると?'
string7 = '毎月泊まっちゃえ♡親孝行*\(^o^)/*でも出来る時しとかないとだよ(o^^o)'
emoj1 = p_face.findall(string1)
emoj2 = p_face.findall(string2)
emoj3 = p_face.findall(string3)
emoj4 = p_face.findall(string4)
emoj5 = p_face.findall(string5)
emoj6 = p_face.findall(string6)
emoj7 = p_face.findall(string6)
print(emoj1)
print(emoj2)
print(emoj3)
print(emoj4)
print(emoj5)
print(emoj6)
print(emoj7)
mais le résultat est le suivant:
1. ['(´•౪•`), 試験頑張るぞ\\\\ ٩(‘ω’)و']
2. ['\u3000メール\u3000']
3. ['(n=1)']
4. ['「\u3000BAY\u3000']
5. ['(´・ω・`) ']
6. ['。。(-_-;)']
Mais il y a quelques problèmes: Le chaine1, en fait il y a deux émoticônes:
(´•౪•`) and \\\\ ٩(‘ω’)و ////
mais le résultat montre seulement un émoticône dont deux émoticônes avec d'autres textes japonais. Je veux juste la liste suivante inclus deux émoticônes:
[ '(´•౪•`)',' \\\\ ٩(‘ω’)و ////']
d'autre part, le fait string5 la ♥ · ゚ ♡ ゚ · ♥ et^-^sont aussi émoticône, mais ces émotions ne peuvent être extraites... par le regex répondu. En outre, il n'y a pas de texte d'émoticône (メ ー ル et (n = 1) ['「BAY'] ne sont pas des émoticônes) dans les chaînes string2, string3 et string 4. mais le motif regex a extrait ces textes. Pourriez-vous me donner la main pour résoudre ce problème, merci! s'il vous plaît vérifier l'émoticône japonaise: http://kaomojiya.com/kao/?other/line
Je vous remercie vraiment pour vos commentaires @ Thomas Wilmotte. Je le confirme, et je rapporterai le résultat. – tktktk0711
il y a quelques problèmes après que je l'ai confirmé. – tktktk0711
1. J'ai mis à jour la question qui a ajouté une nouvelle chaîne4, s'il vous plaît lisez-la, et j'ai trouvé s'il y a deux ou trois espaces après '.' Ou les émoticônes (l'espace sera \ u3000). et il sera faux de penser que c'est une émoticône. – tktktk0711