Ashref Ashref - 25 days ago 7
Python Question

Python : find words in string without white space

I'm trying to make a function to look for words in a string without white space : 'Daysaregood' .
i iterate for every letter until i find if the word exists by comparing with list based on already iterated letter, using enchant the module enchant.
and this is what i tried:

import enchant
import time

fulltext =[]
def work(out):

if len(out)>0:

word = ''
wd = ""
# iterate for every Letter
for i in out:
word = word + i
print word
d = enchant.Dict('en_US')
# a list of words to compare to
list = d.suggest(word.title())
print list
#check if word exists
if word.title() in list :
print 'Word found'
wd = word
print 'Word not found'

print '\n'+wd

print '\n fulltext : '
print fulltext


Now for this text the scripts runs like i want, i get a list like this :
['Days', 'are', 'good'].
But when i try something like 'spaceshuttle', the function gets confused with 'space' and steels the 's' in 'shuttle' so i get this :
['spaces', 'hut', 't', 'l', 'e'].
My goal is to take return every word by itself and store them into a list.
Any help is appreciated.


The issue with your task is that the desired output doesn't follow strict rules, per se. If you were to input 'pineapple', would you expect ['pine', 'apple'] or ['pineapple']? It would be rather difficult / impossible to have it predict this.