I'm trying to split a string up into words and punctuation, adding the punctuation to the list produced by the split.
For instance:
>>> c = "help, me"
>>> print c.split()
['help,', 'me']
What I really ... |
What would be the best way of removing any duplicate characters and sets of characters separated by spaces in string?
I think this example explains it better:
foo = 'h k k h2 ... |
Weird - I think what I want to do is a fairly common task but I've found no reference on the web. I have text, with punctuation, and I want an ... |
For example...
s = 'The fox jumped over a big brown log.'
k = FUNCTION(s,4)
k should be... "The fox jumped over"
I can write my own function that splits on whitespace, cuts the list ... |
I need to take a string, and shorten it to 140 characters.
Currently I am doing:
if len(tweet) > 140:
tweet = re.sub(r"\s+", " ", tweet) #normalize space
...
|
a brain dead third party program I'm forced to use determines how to treat paths depending if the input supplied is a single word, or a full path: in the former ... |
I have some random string, let's say :
s = "This string has some verylongwordsneededtosplit"
I'm trying to write a function trunc_string(string, len) that takes string as argument to operate on and 'len' ... |
|
I'm wondering how to remove a dynamic word from a string within Python.
It will always have a ":" at the end of the word, and sometimes there's more than one within ... |
I am pretty stumped at the moment. Based on http://stackoverflow.com/questions/1045628/can-i-use-win32-com-to-replace-text-inside-a-word-document I was able to code a simple template system that generates word docs out of a template word doc (in ... |
This is the problem:
Function Name: randomSentenceRedux
Parameters:
1.string – a string object to manipulate
Return Value:
A transformed string where the words from the original sentence are in a random order.
Test Case(s):
>>>print randomSentenceRedux("My name is ...
|
I can do such thing in python:
list = ['one', 'two', 'three']
if 'some word' in list:
...
This will check if 'some word' exists in the list. But can I do ... |
i want all combinations words of string "my first program"
|
Sorry if the question is bit confusing. This is similar to this question
I think this the above question is close to what I want, but in Clojure.
There is |
i have ugly strings that looks like this:
string1 = 'Fantini, Rauch, C.Straus, Priuli, Bertali: 'Festival Mass at the Imperial Court of Vienna, 1648' (Yorkshire Bach Choir & Baroque ...
|
I have a list as below
['Jellicle', 'Cats', 'are', 'black', 'and', 'white,\nJellicle', 'Cats', 'are', 'rather', 'small;\nJellicle', 'Cats', 'are', 'merry', 'and', 'bright,\nAnd', 'pleasant', 'to', 'hear', 'when', 'they', 'caterwaul.\nJellicle', 'Cats', 'have', 'cheerful', 'faces,\nJellicle', ... |
What is the best way performance wise to take a list of words and turn them into phrases in python.
words = ["hey","there","stack","overflow"]
print magicFunction(words)
>>> ["hey","there","stack","overflow", "hey there stack","hey there", "there stack ...
|
I want to split a sentence into a list of words.
For English and European languages this is easy, just use split()
>>> "This is a sentence.".split()
['This', 'is', 'a', 'sentence.']
But I also need ... |
How do I split up a string into several parts of a number of words in python. For example, turn a 10,000 word string into ten 1,000 word strings. Thanks.
|
Basically, I've got a bunch of phrases and I'm only interested in the ones that contain certain words. What I want to do is 1) find out if that word is ... |
how can I find the nth word in a text.
example:
my_txt("hello to you all" , 3)
all
I don't wanna use any built in function ...and this is not a homework :D
|
For example, having gone through this procedure the string:
Hello, WORLD, McGisty, you are my HERO THAT I am.
should return/be:
Hello, World, McGisty, you are my Hero That I am.
Thanks!
|
I have a list that contains many sentences. I want to iterate through the list, removing from all sentences words like "and", "the", "a", "are", etc.
I tried this:
def ...
|
I want to create computer for the word-game Ghost. However, I'm having problems thinking of a good way to deal with accessing the huge word list. ... |
I want to get a similarity percentage of two words, eg)
abcd versus zzabcdzz == 50% similarity
Don't need to be very accurate. Is there any way to do that? I am using ... |
i'm a new user of python , i don't know some place when i read the code . so i asked here.
cmd = u"sudo umount %(mountpoint)s >>%(log)s 2>&1"
i know that %(word) ... |
I have a list of words:
words = ['all', 'awesome', 'all', 'yeah', 'bye', 'all', 'yeah']
And I want to get a list of tuples:
[(3, 'all'), (2, 'yeah'), (1, 'bye'), (1, 'awesome')]
where each tuple ... |
I'm working with Python v2, and I'm trying to find out if you can tell if a word is in a string.
I have found some information about identifying if the word ... |
I'm trying to write code to find the 5 words on either side of a particular phrase. Easy enough, but I have to do this on a massive volume of data, ... |
I have a string:
'Specified, if char, else 10 (default).'
I want to split it into two tuples
words=('Specified', 'if', 'char', 'else', '10', 'default')
separators=(',', ' ', ',', ' ', ' (', ').')
Does anyone ... |
How can I delete words that appear multiple times in a file and just keep the first one and delete the clones.
|
I'm trying to convert a string to a list of words using python. I want to take something like the following:
string = 'This is a string, with words!'
Then convert to something ... |
I'm trying to add whole words from one string to another if they contain a certain character:
mylist = ["hahah", "hen","cool", "breaker", "when"]
newlist = []
for word in mylist:
store ...
|
I have a large list of domain names (around six thousand), and I would like to see which words trend the highest for a rough overview of our portfolio.
The problem I ... |
I am trying to split a Unicode string into words (simplistic), like this:
print re.findall(r'(?u)\w+', "??? ??? ???")
What I expect to see is:
['???','???','???']
But what I really get is:
['\xd1', '\xd0', '\xd0', '\xd0', '\xd0\xb2\xd0', ...
|
I have a data file (un-structed messy file) from which I have to scrub specific list of strings (delete strings).
Here is what I am doing but with no result:
infile = ...
|
>>> myStr="madam. i'm adam! i also tried c,o,m,m,a"
>>> myStr.title()
"Madam. I'M Adam! I Also Tried C,O,M,M,A"
This is certainly incorrect. Why would an apostrophe be considered be considered as the start of a ... |
Following example:
string1 = "calvin klein design dress calvin klein"
how can I remove the second two duplicates "calvin" and "klein"?
result should look like -> string2 = "calvin klein design dress"
only the second ... |
When using the Python string function split(), does anybody have a nifty trick to treat items surrounded by double-quotes as a non-splitting word?
Say I want to split only on white space ... |
Let's say I have a list of words:
resign
resins
redyed
resist
reeded
I also have a string ".10.10"
I need to iterate through the list and find the words where there are repeated characters in the same ... |
I have a list of single and multi-word phrases:
terms = ['Electronic rock', 'Alternative rock', 'Indie pop']
I want to detect that terms[0] and terms[1] share the word rock. Is there a Pythonic ... |
So I've been learning Python for some months now and was wondering how I would go about writing a function that will count the number of times a word occurs in ... |
I'm new in python and I'm having some issues doing a simple thing.
I've an array (or list as it's said in pyton) like this:
list = [ 'NICE dog' , 'blue ...
|
def in_string(string, value, poss = None): items = string.split() if value in items: if poss: if items.index(value) == poss: ... |
Hello, I have a list of strings in a text file. I have a second text file that contains dictionary words. I would like to parse the strings in the first text file to see if any of the dictionary words are present in the strings. I can do a compare with no problem. What I need to do is see ... |
std::vector wildcardify(std::string word) { std::vector result; result.push_back(word); result.push_back("*"+word); result.push_back(word+"*"); for (unsigned int c=1; c < word.length(); c++) for (unsigned int i=0; i <= word.length()-c; i++) result.push_back(std::string(word).replace(i, c, "*")); return result; |
occurence of words in a string by yogi Thu May 20, 2010 3:42 pm Hi there I try to write a programme that counts the occurrence of words in a string. I found a way to do so but if the word appear 10 times in the text it will write the word and its occurrence 10 times. Do you ... |
sentence = 'Hello, his name is Bart.' list = ['his', 'their'] list2 = ['her', 'our'] What I want to do is to search through 'sentence' to see if any of the words in 'list' is in it. If so, I want to replace that word with the word from the same element in 'list2' or vice versa. So it should look ... |
|
|
Code: Select all STOPWORDS = 'and i a as are at of the'.split() # Add to the list as appropriate def correcttitle(): title = raw_input('Enter the title of the article >') newtitle = [] # Look at each word for word in title.split(): ... |