ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • nltk 패키지로 불용어(stopwords) 제거하기
    프로그래밍/자연어처리 2017. 7. 6. 15:57
    반응형



    불용어(stopwords)는 관사(a, an, the), 전치사(of, on, for), 대명사(it, he, her)와 같이 

    자연어 처리를 하면서 개별 단어 단위로 처리되지 않는 일반적인 단어입니다. 


    nltk는 이런 불용어(stopwords)를 간단히 제거할 수 있는 기능을 제공하고 있습니다. 

    이런 기능을 사용하기 위해서는 일단 nltk package를 다운받아야 합니다. 


    예전에 패키지를 다운받아놓고 위치를 까먹어서 nltk.download()의 c 옵션으로 corpus 위치를 확인합니다. 




    >>> import nltk

    >>> nltk.download()




    ---------------------------------------------------------------------------

        d) Download   l) List    u) Update   c) Config   h) Help   q) Quit

    ---------------------------------------------------------------------------

    Downloader> c


    Data Server:

      - URL: <https://raw.githubusercontent.com/nltk/nltk_data/gh-pages/index.xml>

      - 3 Package Collections Available

      - 108 Individual Packages Available


    Local Machine:

      - Data directory: /root/nltk_data


    ---------------------------------------------------------------------------

        s) Show Config   u) Set Server URL   d) Set Data Dir   m) Main Menu

    ---------------------------------------------------------------------------

    Config>



    확인된 위치에 가서 stopwords 리스트를 확인합니다. 




    ~/nltk_data/corpora/stopwords# ll

    total 72

    drwxr-xr-x  2 root root 4096  2월 28 22:29 ./

    drwxr-xr-x 73 root root 4096  2월 28 23:02 ../

    -rw-r--r--  1 root root  424  2월 28 22:29 danish

    -rw-r--r--  1 root root  453  2월 28 22:29 dutch

    -rw-r--r--  1 root root  743  2월 28 22:29 english

    -rw-r--r--  1 root root 1579  2월 28 22:29 finnish

    -rw-r--r--  1 root root  805  2월 28 22:29 french

    -rw-r--r--  1 root root 1357  2월 28 22:29 german

    -rw-r--r--  1 root root 1227  2월 28 22:29 hungarian

    -rw-r--r--  1 root root 1654  2월 28 22:29 italian

    -rw-r--r--  1 root root 3880  2월 28 22:29 kazakh

    -rw-r--r--  1 root root  851  2월 28 22:29 norwegian

    -rw-r--r--  1 root root 1267  2월 28 22:29 portuguese

    -rw-r--r--  1 root root  521  2월 28 22:29 README

    -rw-r--r--  1 root root 1235  2월 28 22:29 russian

    -rw-r--r--  1 root root 2178  2월 28 22:29 spanish

    -rw-r--r--  1 root root  559  2월 28 22:29 swedish

    -rw-r--r--  1 root root  260  2월 28 22:29 turkish




    ???????????????


    한국어 stopwords 리스트가 없습니다. 

    한국어 문서 처리를 하려고 했는데 ㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋ큐ㅠㅠㅠㅠㅠㅠ







    i

    me

    my

    myself

    we

    our

    ours

    ourselves

    you

    your

    yours

    yourself

    yourselves

    he

    him

    his

    himself

    she

    her

    hers

    herself

    it

    its

    itself

    they

    them

    their

    theirs







    아쉬운 대로 영어 stopwords를 참고해서 만들어서 github에 업데이트 해놨으니

    필요하신 분들은 참고하세요. 


    github 바로가기








    728x90
    반응형
Designed by Tistory.