Pete Froslie wrote:
The url function btw:
def url():
fin = open("journey_test.txt", "r")
response = re.split(r"[/|/,\n, , ,:\"\"\.?,)(\-\<>\[\]'\r']",
fin.read())
thesaurus = API_URL + response[word_number] + '/' #API_URL is
established at the start of the code
return thesaurus
>
> You don't seem to understand functions. Part of the point is to *avoid*
> global variables. If everything a function uses is passed in as arguments,
> and if everything it produces is returned as return value(s), it's much
> easier to see its effect. And to make sure it doesn't have bugs.
Pete Froslie wrote:
so, I've been playing with the functions a bit-- took a little time to get
the hang of them after I started that other mess. Initially, I've done the
opposite suggested here by creating functions without the input values. I do
see the where it will pay off in re-usability that
On 7/12/2009 12:01 PM Pete Froslie said...
(2)not sure why this function doesn't work:
word_count = 0 #set up variable to increment through text
def increment(x):
return x+1
increment(word_count)
You need to capture and assign the result (or possibly restructure to
work
so, I've been playing with the functions a bit-- took a little time to get
the hang of them after I started that other mess. Initially, I've done the
opposite suggested here by creating functions without the input values. I do
see the where it will pay off in re-usability that route.. Alan, I'll re
"Pete Froslie" wrote
This seems the basic form for a function:
*def** hello*():
*print* "Hello World!"
*return*
That is a very limited form that encourages bad practice. The more
general form is:
def aFunction(inputValue1, inputValue2,...):
# do some processing here
retu
Pete Froslie wrote:
the trailing comma is getting me much closer right away! -- will read about
the other options you suggest (rstrip(); stdout: write()) I clearly have a
few other issues I need to sort out now. i guess I've been assuming that
print was a good way to trace what is happening rathe
the trailing comma is getting me much closer right away! -- will read about
the other options you suggest (rstrip(); stdout: write()) I clearly have a
few other issues I need to sort out now. i guess I've been assuming that
print was a good way to trace what is happening rather than thinking about
Pete Froslie wrote:
thanks for the advice Alan.. I am wondering about the following:
new_word = response3[2]
old_word = response[word_number]
#this works but adds carriage returns*
for line in fileinput.FileInput("journey_test.txt",inplace=1):
line = line.replace(old_word, new_word)
thanks for the advice Alan.. I am wondering about the following:
new_word = response3[2]
old_word = response[word_number]
#this works but adds carriage returns*
for line in fileinput.FileInput("journey_test.txt",inplace=1):
line = line.replace(old_word, new_word)
print line
It seem
> I am having trouble with probably the most simple part:
> I cannot seem to go back into the 'txt' file and replace the word I just
> searched with the new word!
Its not a good idea to try to read and write to the same file at the same
time. The normal approach is to weither ead the file into
So, I basically have this working so that it pulls a word from a 'txt' file;
searches for the synonym in the thesaurus; returns the result... but then I
am having trouble with probably the most simple part: I cannot seem to go
back into the 'txt' file and replace the word I just searched with the n
> right now, but Chinese apparently has no distinct verb forms for past,
> present,
> future. So they rely on other words to indicate which they might mean.
Chinese also has the problem of relying on intonation to distinguish between
identically spelled words. We have the same in English
My favorite rendition of this is in the related field of text-to-speech. In
early Object Management Group days, OMG conference proceedings were
available as transcripts, but there was substantial delay in getting these
out. An attempt to automate this with TTS software of the time was
discarded q
Kent Johnson wrote:
On Fri, Jul 10, 2009 at 7:08 AM, Dave Angel wrote:
Alan Gauld wrote:
Or the translation program that translated the expression
Out of sight, out of mind
from English to Russian and back with the result:
Invisible, lunatic
Or the expression:
"The
On Fri, Jul 10, 2009 at 7:08 AM, Dave Angel wrote:
> Alan Gauld wrote:
>> Or the translation program that translated the expression
>>
>> Out of sight, out of mind
>>
>> from English to Russian and back with the result:
>>
>> Invisible, lunatic
> Or the expression:
> "The spirit is willing, but t
Alan Gauld wrote:
"Angus Rodgers" wrote
parsing these two sentences:
Time flies like an arrow.
Fruit flies like a banana.
Or the translation program that translated the expression
Out of sight, out of mind
from English to Russian and back with the result:
Invisible, lunatic
Alan G.
http://pywordnet.sourceforge.net/
This will get you started. This is a tad easier to play with than its
newer implementation. Read and experiment. it may meet most of your
needs in this arena.
Good Luck,
Robert
On Wed, 2009-07-08 at 18:28 -0400, Pete Froslie wrote:
> okay.. I'm getting the ha
okay.. I'm getting the hang of python a little more. I'd like to try
something a bit more complicated (for me). I would like to convert each word
in a series of paragraphs to its first matching synonym in a thesaurus. I'm
a bit stuck as how to start.. I think I understand how to split and parse
the
19 matches
Mail list logo