Skip to content
Advertisement

ntlk: how to get inflections of words

I have a list of words, nearly 5000 English words, and for each word I need these inflectional forms: noun: singular and plural verb: infinitive, present simple, present simple 3rd person, past simple, present participle (ing form), past participle adjective: comparative and superlative adverb How can I extract these information from a given word (e.g. help) in ntlk via python?

Pyautogui TypeError: ‘NoneType’ object is not iterable

I’m trying to use locateCenterOnScreen() function of PyAutoGUI, however it raises : My code is: How can I fix this problem? Answer From the documentation of Pyautogui here, the method locateCenterOnScreen returns None when it can’t find the image on your screen. Note that you are looking for 2 results from this method, but None is just one result (since

Hide tick label values but keep axis labels

I have this image: I want to hide the numbers; if I use: …I get this image: It also hide the labels, V and t. How can I keep the labels while hiding the values? Answer If you use the matplotlib object-oriented approach, this is a simple task using ax.set_xticklabels() and ax.set_yticklabels(). Here we can just set them to an

String/regex search over Excel in Python issue

I’m a newb to SO, and relatively new to Python, so i’m sorry if this is a simple fix or an inappropriate question. Firstly, my program generally works, but i’m trying to implement some redundancy/catchalls for to make it robust. The program looks over a directory (and sub-dirs) of excel files, opens them individually, scours for data (on a specific

pandas dataframe str.contains() AND operation

I have a df (Pandas Dataframe) with three rows: The function df.col_name.str.contains(“apple|banana”) will catch all of the rows: How do I apply AND operator to the str.contains() method, so that it only grabs strings that contain BOTH “apple” & “banana”? I’d like to grab strings that contains 10-20 different words (grape, watermelon, berry, orange, …, etc.) Answer You can do

how to turn protocol number to name with python?

the protocol like tcp and udp is all represented by a number. the above code will return 6. How I can get the protocol name if I know the protocol number? Answer I’m going to say there is almost definitely a better way then this, but all the protocol names (and values) are stored as constants prefixed by “IPPROTO_” so

Python – Tree without classes

How can I implement a tree without using classes in python? I can only use lists, dictionaries and queue. Obviously without the library bintree. Answer I usually use defaultdict: Usage: bonus: Maria Callas singing O Mio Babbino Caro

Pandas replace all items in a row with NaN if one value is NaN

I want to get rid of some records with NaNs. This works perfectly: However, it changes the shape of my dataframe, and the index is no longer uniformly spaced. Therefore, I’d like to replace all items in these rows with np.nan. Is there a simple way to do this? I was thinking about resampling the dataframe after dropna, but that

Detect white background on images using python

Is there a way to tell whether an image as a white background using python and what could be a good strategy to get a “percentage of confidence” about this question? Seems like the literature on internet doesn’t cover exactly this case and I can’t find anything strictly related. The images I want to analyze are typical e-commerce website product

Advertisement