[string.translate(punctuation)for string in text_data]
['Hi I Love This Song', '10000 Agree LoveIT', 'Right']
설명
translate
는 속도가 빨라 인기 있는 파이썬 함수입니다. 이 해결은 모든 유니코드 구
두점
3
을 키로 하고 값은
None
인
punctuation
딕셔너리를 만들었습니다. 그다음 문자열에서
punctuation
에 있는 모든 문자를
None
으로 바꾸어 구두점을 삭제하는 효과를 냅니다. 조금
더 읽기 좋은 코드를 사용하는 방법도 있지만 이 방식이 다른 것보다 훨씬 더 빠르다는 장점이
있습니다.
구두점도 정보가 있다는 사실을 유념하세요(예를 들어 “맞아?”와 “맞아!”). 구두점을 삭제하는
것은 수동으로 특성을 만들 때 필요악일 수 있습니다. 하지만 구두점이 중요한 역할을 한다면
이를 고려해야만 합니다. 달성해야 할 후속 작업에 따라 구두점에 중요한 정보가 담겨 있을 수
있습니다(예를 들어,
'?'
를 사용해 텍스트에 질문이 포함되어 있는지 구분합니다).
6.4
텍스트 토큰화하기
과제
텍스트를 개별 단어로 나누고 싶습니다.
해결
파이썬의 자연어 처리 툴킷인
NLTK
natural ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month, and much more.
O’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
I wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
I’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
I'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.