word

python check if word is in certain elements of a list

妖精的绣舞 提交于 2019-12-12 12:22:16
问题 I was wondering if there was a better way to put: if word==wordList[0] or word==wordList[2] or word==wordList[3] or word==worldList[4] 回答1: Very simple task, and so many ways to deal with it. Exciting! Here is what I think: If you know for sure that wordList is small (else it might be too inefficient), then I recommend using this one: b = word in (wordList[:1] + wordList[2:]) Otherwise I would probably go for this (still, it depends!): b = word in (w for i, w in enumerate(wordList) if i != 1)

find line number of a word in a file

血红的双手。 提交于 2019-12-12 04:37:30
问题 I have a file: file.txt, which contains the following data in it. GNU grep version: 2.5.1, System admin says NO to upgrading it to later version as it might impact production This is a file, my name is Karl, what is this process, karl is karl junior, file is a test file, file's name is file.txt My name is not Karl, my name is Karl Joey What is your name? Do you know your name and what it is? When I'm running the following command to get line# of a word "is" in this file using the following

Checking whether a particular word is a noun or verb

ⅰ亾dé卋堺 提交于 2019-12-12 03:54:41
问题 I tried to cheak with Microsoft Word (using vba code) for pump ((oil pump) whether it is a noun or verb according to Microsoft word it is verb ( actually pump is a noun) I need to check it for a list of words (mostly technical) Is it possible to compare to any database? Something else? 回答1: I think the only answer here is "It can't be done". Even with context, you'd need human interpretation to determine the word type in some cases. Time flies like an arrow. It can mean that time passes very

How to tokenize a list of words using nltk? [duplicate]

心已入冬 提交于 2019-12-12 03:45:58
问题 This question already has answers here : How do I tokenize a string sentence in NLTK? (2 answers) Closed 2 years ago . I have a text dataset. Those dataset consist of many lines that each lines are consist of two sentences split by tab, like this : this is string 1, first sentence. this is string 2, first sentence. this is string 1, second sentence. this is string 2, second sentence. and then I have split the datatext by this code : #file readdata.py from globalvariable import * import os

Get date from string by splitting

混江龙づ霸主 提交于 2019-12-12 01:36:24
问题 I have a batch of raw text files. Each file begins with Date>>month.day year News garbage . garbage is a whole lot of text I don't need, and varies in length. The words Date>> and News always appear in the same place and do not change. I want to copy month day year and insert this data into a CSV file, with a new line for every file in the format day month year . How do I copy month day year into separate variables? I tryed to split a string after a known word and before a known word. I'm

Grab the first word in a list that is found in a string. ( Python )

送分小仙女□ 提交于 2019-12-11 20:47:03
问题 So, I have a list of words like so: activationWords = ['cactus', 'cacti', 'rofl'] And I want to find any of those words and return the first word of any of those words appearing in a random string. I'll use this string as an example: str = "Wow, rofl I found a cactus in a cacti pile." As you can see with the above example string, the first instance of a word in the list is "rofl". I want to be able to detect that and return the word into a string that I can use to my discretion. How would I

converting integer input to words

霸气de小男生 提交于 2019-12-11 20:27:20
问题 I have to write a program such that I give it a three digit input and it converts it into word format. example: input = 907 output = nine hundred seven I can easily figure out how to give the hundred position output. I can divide the input by 100 and then store the whole part of result into a new variable. and then if the variable has value, let's say 7 make another new variable of character type and give it a value seven using if conditionals. But I can't figure out what to do for tens and

php : word proximity script?

微笑、不失礼 提交于 2019-12-11 18:07:37
问题 Okay - so, I've spent ages searching in Google, and even went through a few specific searches at hotscripts etc., several php forums and this place ... nothing (not of use anyway). i want to be able to take a block of text (page/file/doc) and pull it apart to find the "distance" between specific terms (find the proximity/raltional distance etc.). I woudl have thought there'd be at least a few such thigns around - but I'm not finding them. So - it may be harder than I thought. I understand it

Finding word in a matrix

∥☆過路亽.° 提交于 2019-12-11 17:04:34
问题 I have a matrix file (which python reads like a list of lists) and I need to tell if a word from a different file appears in that matrix, in a given direction. for example: given this matrix: c,a,T,e o,a,t,s w,o,t,e n,o,l,e the words: caT, cow, own, cat and the directions: downright (diagonal) I expect an output: cat:1 and for the direction: down, right I expect: cow:1 own:1 cat:1 my function is set like so: def word_finder(word_list,matrix, directions): What I find hard to do is go through a

Reading MathType MTEF Format

久未见 提交于 2019-12-11 12:15:14
问题 I have an XML file containing some scientific text that I want to display as proper as possible as HTML. Within the XML I find some text that looks like a binary string, possibly produced by MathType. An example of such a string is this one: ... are assumed to be independent and normally distributed as (0;σb2MathType@MTEF@5@5@+=feaafiart1ev1aaatCvAUfKttLearuWrP9MDH5MBPbIqV92AaeXatLxBI9gBaebbnrfifHhDYfgasaacH8akY=wiFfYdH8Gipec8Eeeu0xXdbba9frFj0=OqFfea0dXdd9vqai=hGuQ8kuc9pgc9s8qqaq