입니다 그들은 모두 다음 간결체 한자를 달성 할 수있다 찾고있는 공백으로 구분하는 경우
>>> line=" John 32 Smith [email protected] ddfdwww.google.com fdfdhttp://google.com/index/agroup.html peter murphy alexis xronis 54^ &^&^& % % $ % %^^ ! 68! @ @ # https://facebook.com.edu [email protected] ! @^"
>>> from nltk import word_tokenize
>>> word_tokenize(line)
['John', '32', 'Smith', 'global', '@', 'hotmail.com.gr', 'ddfdwww.google.com', 'fdfdhttp', ':', '//google.com/index/agroup.html', 'peter', 'murphy', 'alexis', 'xronis', '54^', '&', '^', '&', '^', '&', '%', '%', '$', '%', '%', '^', '^', '!', '68', '!', '@', '@', '#', 'https', ':', '//facebook.com.edu', 're', '@', 'dfdffe.gov.gr', '!', '@', '^']
: 잘못 모든 이메일을 받고 있기 때문에 word_tokenze
를 사용 str.split()
와 Y :
['John', '32', 'Smith', '[email protected]', 'ddfdwww.google.com', 'fdfdhttp://google.com/index/agroup.html', 'peter', 'murphy', 'alexis', 'xronis', '54^', '&', '^', '&', '^', '&', '%', '%', '$', '%', '%', '^', '^', '!', '68!', '@', '@', '#', 'https://facebook.com.edu', '[email protected]', '!', '@', '^']
그러나 함께 단어 관절을 식별하는 것은 쉬운 일이 아니다 ...
당신은 http
, www
및 [email protected]
을 물고기 다음과 같은 트릭을 시도하지만,이 점에 유의하시기 바랍니다 수 있습니다 순전히 귀하의 데이터에 맞게 정규식을 수정해야합니다.
re.findall(r'www\.[a-z].*.com', i) # www
re.findall(r'http:[a-z\/].*.html', i) # http
re.findall(r'https:[a-z\/].*', i) # https
re.findall(r'[a-z].*@[a-z].*.gov.[a-z].*', # [email protected]
원하는 출력은 무엇입니까? – alvas
나는 그것을 마치 같은 모양으로하고 싶습니다. 'John'32 'Smith' '[email protected]' 'ddfd' 'www.google.com' 'fdfd' 'http://google.com/index /agroup.html '피터' '머피' '알렉시스' '크로네'54 '' '' '' '' '' '' '' ''% '등 –