Eliminate numbers from a sentence in Python -


i parsing xml file , trying build dictionary every context in xml. have done parsing successfully, , need rid of stopwords, punctuations , numbers string get.

however, reason, couldn't rid of numbers, have been debugging night, hope me it...

def is_number(s):     try:         float(s)         return true     except valueerror:         return false 

i have been checking method 'is_number' working, don't why still pass if statement:

if (words[headindex + index] not in cachedstopwords) , ~isnumber: 

thanks in advance!

the problem is:

~isnumber 

~ bitwise not operator. want not boolean operator:

>>> ~true -2 >>> ~false -1 >>> not true false >>> not false true 

the bitwise operator lead ~isnumber being truthy value (-1 or -2), , if statement entered.


Comments

Popular posts from this blog

node.js - How to mock a third-party api calls in the backend -

java - Could not locate OpenAL library -

Non Unique Username with ASP.Net Identity 2.0 -