Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

Removing punctuation with NLTK in Python

import string 
from nltk.tokenize import word_tokenize
s =  set(string.punctuation)          # !"#$%&'()*+,-./:;<=>?@[]^_`{|}~
sentence = "Hey guys !, How are 'you' ?"
sentence = word_tokenize(sentence)
filtered_word = []
for i in sentence:
    if i not in s:
        filtered_word.append(i);
for word in filtered_word:
  print(word,end = " ")
Comment

PREVIOUS NEXT
Code Example
Python :: python blackjack 
Python :: django desc order 
Python :: numpy random int 
Python :: difference between two dates in days python 
Python :: closing text files in python 
Python :: use sqlalchemy to create sqlite3 database 
Python :: django import settings 
Python :: find index of max value in 2d array python 
Python :: python return right operand if left is falsy 
Python :: resample and replace with mean in python 
Python :: variable inside class not detecting global variable in python 
Python :: python folium add minimap to map 
Python :: python list contains substring 
Python :: python program to convert tuple into string 
Python :: Embed picture in email using smtplib 
Python :: dashes seaborn 
Python :: copy file in python3 
Python :: xpath helium 
Python :: The name tf.train.Optimizer is deprecated. Please use tf.compat.v1.train.Optimizer instead. 
Python :: how to get words from a string in python 
Python :: create zero array in python 
Python :: python import upper directory 
Python :: create numpy table with random values in range 
Python :: views.home not found django 
Python :: add trendline to plot matplotlib 
Python :: overlapping date matplotlib 
Python :: rename one dataframe column python 
Python :: onlt int validator qt py 
Python :: numpy series reset index 
Python :: how to strip a list in python 
ADD CONTENT
Topic
Content
Source link
Name
1+3 =