473,404 Members | 2,174 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,404 software developers and data experts.

create words of various lengths

"X-No-Archive: yes"

what I am looking for is

1. To create a list of different words of various lengths(1-15) using
A-Z,a-z,0-9 and punctuations.Basically anything that could be found on
a text document.

2. The words formed need not be meaningful .FOr example 'ajf' or
'fcjgdtfhbs' or even 'gfdew!' or '#bang.' would be a valid entry in the
list.

3.So I am looking for a random set of words of sizes 1 to 15.The proble
might be the time complexity. I inderstand that there would be too many
permutations.

Jul 19 '05 #1
9 2127
su*******@gmail.com wrote:
"X-No-Archive: yes"

what I am looking for is

1. To create a list of different words of various lengths(1-15) using
A-Z,a-z,0-9 and punctuations.Basically anything that could be found on
a text document.

2. The words formed need not be meaningful .FOr example 'ajf' or
'fcjgdtfhbs' or even 'gfdew!' or '#bang.' would be a valid entry in the
list.

3.So I am looking for a random set of words of sizes 1 to 15.The proble
might be the time complexity. I inderstand that there would be too many
permutations.


So why don't you take one step back and tell us what you think you need
this list *for*? We might be able to come up with feasible alternatives.

--
Robert Kern
rk***@ucsd.edu

"In the fields of hell where the grass grows high
Are the graves of dreams allowed to die."
-- Richard Harter

Jul 19 '05 #2
Hi Robert,
At first I thought it would be an interesting thing to have a little
swift module to create a database of all words in the dictionary.But
then I thought y just the words in the dictionary? y not all possible
words like 'and' and 'adn'. Just was inspired with the little idea of
if its an 'and' or 'adn' when u read it in a combination of other words
you read it as 'and' itself.

"nohting spceific wsa jsut plyaing around wtih ideas "

Jul 19 '05 #3
su*******@gmail.com wrote:
what I am looking for is

1. To create a list of different words of various lengths(1-15) using
A-Z,a-z,0-9 and punctuations.Basically anything that could be found on
a text document.

2. The words formed need not be meaningful .FOr example 'ajf' or
'fcjgdtfhbs' or even 'gfdew!' or '#bang.' would be a valid entry in the
list.

3.So I am looking for a random set of words of sizes 1 to 15.The proble
might be the time complexity. I inderstand that there would be too many
permutations.


how many words do you need? the following bruce-force solution
doesn't take that long to run on my machine, and the resulting words
are guaranteed to be almost entirely meaningless ;-)

import string
from random import choice, randint, shuffle

alphabet = string.letters + string.digits + "%&!?#"

words = {}

while len(words) < 10000:
words["".join(choice(alphabet) for i in range(randint(1,15)))] = None

words = words.keys()
shuffle(words)

to generate text from this, reshuffle the word list after you've written
a number of words. (or you could slice off a random number of words
and run the loop again, at random intervals. or something.)

the character and word distribution will have no similaries with real text,
of course, but maybe that doesn't matter.

</F>

Jul 19 '05 #4
su*******@gmail.com wrote:
Hi Robert,
At first I thought it would be an interesting thing to have a little
swift module to create a database of all words in the dictionary.
Okay, take one more step back. Why is it interesting to have such a
dictionary? How do you intend to use it?

Having answered those questions, why is it interesting to extend this
with meaningless collections of symbols?

No one can offer you a better method if we don't have a metric to judge
whether a method is "better" than another.
But
then I thought y just the words in the dictionary? y not all possible
words like 'and' and 'adn'. Just was inspired with the little idea of
if its an 'and' or 'adn' when u read it in a combination of other words
you read it as 'and' itself.

"nohting spceific wsa jsut plyaing around wtih ideas "


Well, that's a somewhat different problem.

--
Robert Kern
rk***@ucsd.edu

"In the fields of hell where the grass grows high
Are the graves of dreams allowed to die."
-- Richard Harter

Jul 19 '05 #5
no specific number of words.
and I get a syntax error on line:
words["".join(choice(alphabet) for i in range(randint(1,15)))] = None


Jul 19 '05 #6
this works

while len(words) < 10000:
wd = ""
for i in ["".join(choice(alphabet)) for i in
range(randint(1,15))]:
wd += i
words[wd] = None

anyway Thanks for that this is exactly what i need..

Jul 19 '05 #7
su*******@gmail.com wrote:
no specific number of words.
anything between one and a gazillion, you mean? having some idea of
the upper bound helps when chosing what algorithm/database/computer
to use...
and I get a syntax error on line:
words["".join(choice(alphabet) for i in range(randint(1,15)))] = None


so what's your excuse for not using a recent version of Python? ;-)

if you're stuck with an older version,

words["".join([choice(alphabet) for i in range(randint(1,15))])] = None

should work.

</F>

Jul 19 '05 #8
:) the reason for me not upgrading my python is I am waiting for
version of Numeric to be released for python 2.4 .The stable version of
Numeric is only release for windows and not Linux I guess the last time
i checked. which i use a lot .

Anyway thanks

Jul 19 '05 #9
su*******@gmail.com wrote:
:) the reason for me not upgrading my python is I am waiting for
version of Numeric to be released for python 2.4 .The stable version of
Numeric is only release for windows and not Linux I guess the last time
i checked. which i use a lot .


Install from source. It works just fine. Numeric will never be released
"just for Windows."

--
Robert Kern
rk***@ucsd.edu

"In the fields of hell where the grass grows high
Are the graves of dreams allowed to die."
-- Richard Harter

Jul 19 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Jeff Thies | last post by:
It seems that there can be too many words on a line. This is a problem with pages that are not fixed width. There seems to be a few problems. 1) Finding where the next line starts after...
10
by: Aaron | last post by:
string a = "i have an apple"; i want the output to be "I Have An Apple"; i was able to capitalize the first word but can't figure out how to capitalize every word in that string Thanks,...
5
by: Siv | last post by:
Hi, I have a class module that I have created and I have looked at the various descriptions of how you should implement a dispose method in your own class and I am finding it mighty confusing. ...
9
by: Steven | last post by:
Hello, I have a question about strcmp(). I have four words, who need to be compared if it were two strings. I tried adding the comparison values like '(strcmp(w1, w2) + strcmp(w3, w4))', where...
4
by: yoram.ayalon | last post by:
Hi, I need to create a multipart request to UPS manifest upload electronic service. UPS wants the request to consist of a series of headers and bodies, and its not clear how can I use the...
4
by: etuncer | last post by:
Hello All, I have Access 2003, and am trying to build a database for my small company. I want to be able to create a word document based on the data entered through a form. the real question is...
4
by: mojeza | last post by:
I would like to create generic object which will be used for store of single row of DataTable. Lets say I create class as follow: Public Class Participant Public ParticipantID As Int64 Public...
4
by: sumedh..... | last post by:
In a compiler there are 36bits for a word and to store a character 8bits are needed. In this to store a character two words appended. Then for storing k characters string,how many words are needed?
4
by: Alan Mailer | last post by:
Again, I'm new to VB.net and there is something I need help with: Like (I assume) many of us, over time I want to be able to create some VB.net classes that I might want to use in more than one...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.