{"id":188,"date":"2017-09-29T10:26:10","date_gmt":"2017-09-29T10:26:10","guid":{"rendered":"http:\/\/python.wp.w3.pt\/?p=188"},"modified":"2017-09-30T11:29:59","modified_gmt":"2017-09-30T11:29:59","slug":"nltk-natural-language-toolkit","status":"publish","type":"post","link":"http:\/\/python.w3.pt\/?p=188","title":{"rendered":"NLTK &#8211; Natural Language Toolkit"},"content":{"rendered":"<p>Vou trabalhar com o <a href=\"http:\/\/www.nltk.org\/\">Natural Language Toolkit<\/a> para lematizar palavras e termos em ingl\u00eas. O pacote NLTK tem que ser instalado. Para isso uso o comando:<\/p>\n<p><code>pip install -U nltk<\/code><\/p>\n<p>Instalei tamb\u00e9m o Numpy: <\/p>\n<p><code>pip install -U numpy<\/code><\/p>\n<p>Para testar a instala\u00e7\u00e3o, entrei no python e digitei <code>import nltk<\/code>. Depois \u00e9 necess\u00e1rio importar os dados. O NLTK tem v\u00e1rios corpus de dados. Podemos instal\u00e1-los todos, ou selecionar apenas aqueles de que necessitamos. Um dos pacotes \u00e9 o RSLP (Removedor de Sufixos da Lingua Portuguesa). Eu vou o usar o pacote WordNet. Para isso, entro no Python e digito:<\/p>\n<p><code>import nltk<br \/>\nnltk.download()<\/code><\/p>\n<p>Depois primo a op\u00e7\u00e3o d (Download) e escrevo <code>wordnet<\/code>. Para instalar todos os pacotes, pode escrever-se <code>all<\/code>. E est\u00e1 conclu\u00edda a instala\u00e7\u00e3o.<\/p>\n<p>Exemplo de uso do <em>lemmatizer<\/em>:<\/p>\n<pre>>>> from nltk.stem.wordnet import WordNetLemmatizer\r\n>>> lmtzr = WordNetLemmatizer()\r\n>>> lmtzr.lemmatize('cars')\r\nu'car'\r\n>>> lmtzr.lemmatize('feet')\r\nu'foot'\r\n>>> lmtzr.lemmatize('fantasized','v')\r\nu'fantasize'\r\n>>> lmtzr.lemmatize('people')\r\n'people'\r\n>>><\/pre>\n<p>Usei como guia, o stackoverflow, <a href=\"https:\/\/stackoverflow.com\/questions\/771918\/how-do-i-do-word-stemming-or-lemmatization\">How do I do word Stemming or Lemmatization?<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Vou trabalhar com o Natural Language Toolkit para lematizar palavras e termos em ingl\u00eas. O pacote NLTK tem que ser instalado. Para isso uso o comando: pip install -U nltk Instalei tamb\u00e9m o Numpy: pip install -U numpy Para testar a instala\u00e7\u00e3o, entrei no python e digitei import nltk. Depois \u00e9 necess\u00e1rio importar os dados. &hellip; <\/p>\n<p class=\"link-more\"><a href=\"http:\/\/python.w3.pt\/?p=188\" class=\"more-link\">Continuar a ler <span class=\"screen-reader-text\">&#8220;NLTK &#8211; Natural Language Toolkit&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"_links":{"self":[{"href":"http:\/\/python.w3.pt\/index.php?rest_route=\/wp\/v2\/posts\/188"}],"collection":[{"href":"http:\/\/python.w3.pt\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/python.w3.pt\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/python.w3.pt\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/python.w3.pt\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=188"}],"version-history":[{"count":7,"href":"http:\/\/python.w3.pt\/index.php?rest_route=\/wp\/v2\/posts\/188\/revisions"}],"predecessor-version":[{"id":195,"href":"http:\/\/python.w3.pt\/index.php?rest_route=\/wp\/v2\/posts\/188\/revisions\/195"}],"wp:attachment":[{"href":"http:\/\/python.w3.pt\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=188"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/python.w3.pt\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=188"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/python.w3.pt\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=188"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}