I have a txt file that contain Japanese sentences. I would like to remove all non Japanese words. Such as numbers, English alphabets or any other non Japanese language, signs, symbols. Is there a quick way to do it? Thanks
Hi !こんにちは、私の給料は月額10000ドルです。 XO XO
私はあなたの料理が大好きです
私のフライトはAPX1999です。
私はサッカーの試合を見るのが大好きです。
Words to remove :
Hi !
XO XO
10000
APX1999
>Solution :
The simplest way is this:
s = "Hi !こんにちは、私の給料は月額10000ドルです。 XO XO 私はあなたの料理が大好きです私のフライトはAPX1999です。私はサッカーの試合を見るのが大好きです"
no_ascii = ''
for c in s:
ascii_code = ord(c)
if ascii_code > 127 or ascii_code == 0:
no_ascii += c
print(no_ascii)
こんにちは、私の給料は月額ドルです。私はあなたの料理が大好きです私のフライトはです。私はサッカーの試合を見るのが大好きです