Le Sun, 3 May 2009 21:59:23 -0400,
Dan Liang s'exprima ainsi:
> Hi tutors,
>
> I am working on a file and need to replace each occurrence of a certain
> label (part of speech tag in this case) by a number of sub-labels. The file
> has the following format:
>
> word1 \tTag1
> word2 \tT
"Dan Liang" wrote
def replaceTagging(source_name, target_name):
source_file = file(source_name, 'r')
source = source_file.read() # not really necessary
this reads the entire file as a string
target_file = open(target_name, "w")
# replacement loop
for li
Le Mon, 4 May 2009 10:15:35 -0400,
Dan Liang s'exprima ainsi:
> Hi Spir and tutors,
>
> Thank you Spir for your response. I went ahead and tried your code after
> adding a couple of dictionary entries, as below:
> ---Code Begins---
> #!usr/bin/python
>
> tags = {
>
>
> 'c
So far the script works fine, it avoids printing the lines i want and
I can add new domain names as needed. It looks like this:
#!/usr/bin/python
import re
outFile = open('outFile.dat', 'w')
log = file("log.dat", 'r').read().split('Source') # Set the line delimiter
for line in log:
if not re.
Hi Spir and tutors,
Thank you Spir for your response. I went ahead and tried your code after
adding a couple of dictionary entries, as below:
---Code Begins---
#!usr/bin/python
tags = {
'case_def_gen':['case_def','gen','null'],
'nsuff_fem_pl':['nsuff','null', 'null'],
'ab
Original:
'case_def_gen':['case_def','gen','null'],
'nsuff_fem_pl':['nsuff','null', 'null'],
'abbrev': ['abbrev, null, null'],
'adj': ['adj, null, null'],
'adv': ['adv, null, null'],}
Note the values for 'abbrev', 'adj' and 'adv' are not lists, but strings
containing comma-separated lists.
S
Hi
I am looking for method enables advanced text string search. Method
string.find() or re module seems no supporting what I am looking for. The
idea is as follows:
Text ="FDA meeting was successful. New drug is approved for whole sale
distribution!"
I would like to scan the text using AND and
Thanks, Kent, but that doesn't solve my problem. In fact, I need
ConfigParser to work with non-ascii characters, since my App may run
in "latin-1" environments (folders e files names). I must find out why
the str() function in the module ConfigParser doesn't use the encoding
defined for the applica
Here is the traceback, after the last change you sugested:
Traceback (most recent call last):
File "/home/pablo/workspace/E-Dictor/src/MainFrame.py", line 1057, in OnClose
self.SavePreferences()
File "/home/pablo/workspace/E-Dictor/src/MainFrame.py", line 1069,
in SavePreferences
self.
Advanced Strings searches are Regex via re module.
EX:
import re
m = re.compile("(FDA.*?(approved|supported)|Ben[^\s])*")
if m.search(Text):
print m.search(Text).group()
Vince
On Mon, May 4, 2009 at 6:45 AM, Alex Feddor wrote:
> Hi
>
> I am looking for method enables advanced text str
"Nick Burgess" wrote
for line in log:
if not re.search(r'notneeded.com|notneeded1.com',line):
outFile.write(line)
I tried the in method but it missed any other strings I put in, like
the pipe has no effect. More complex strings will likely be needed so
perhaps re might be better..?
Nick Burgess wrote:
> So far the script works fine, it avoids printing the lines i want and
> I can add new domain names as needed. It looks like this:
>
> #!/usr/bin/python
> import re
>
> outFile = open('outFile.dat', 'w')
> log = file("log.dat", 'r').read().split('Source') # Set the line delim
"Paul McGuire" wrote
For much of my own code, I find lists of string literals to be tedious to
enter, and easy to drop a ' character. This style is a little easier on
the
eyes, and harder to screw up.
'case_def_gen':['case_def gen null'.split()],
'nsuff_fem_pl':['nsuff null null'.split()],
"Alex Feddor" wrote
I am looking for method enables advanced text string search. Method
string.find() or re module seems no supporting what I am looking for.
The
idea is as follows:
The re module almost certainly can do what you want but regex
are notoriously hard to master and often obscu
On 5/4/2009 11:03 AM Alan Gauld said...
"Alex Feddor" wrote
I am looking for method enables advanced text string search. Method
string.find() or re module seems no supporting what I am looking for.
The
idea is as follows:
The re module almost certainly can do what you want but regex
are n
On Mon, May 4, 2009 at 10:09 AM, Pablo P. F. de Faria
wrote:
> Thanks, Kent, but that doesn't solve my problem. In fact, I need
> ConfigParser to work with non-ascii characters, since my App may run
> in "latin-1" environments (folders e files names).
Yes, I understand that.
Python has two diffe
On Mon, May 4, 2009 at 1:32 PM, Pablo P. F. de Faria
wrote:
> Hi, all.
>
> I've found something that worked for me, but I'm not sure of its
> secureness. The solution is:
>
> reload(sys)
> sys.setdefaultencoding('utf-8')
>
> That's exactly what I wanted to do, but is this good practice?
No. You s
Le Mon, 4 May 2009 10:38:31 -0600,
vince spicer s'exprima ainsi:
> Advanced Strings searches are Regex via re module.
>
> EX:
>
> import re
>
> m = re.compile("(FDA.*?(approved|supported)|Ben[^\s])*")
>
> if m.search(Text):
> print m.search(Text).group()
>
>
> Vince
This is not at all
Le Mon, 4 May 2009 11:09:25 -0300,
"Pablo P. F. de Faria" s'exprima ainsi:
> Thanks, Kent, but that doesn't solve my problem. In fact, I need
> ConfigParser to work with non-ascii characters, since my App may run
> in "latin-1" environments (folders e files names). I must find out why
> the str()
Compiling the regular expression works great, I cant find the tutorial
Mr. Gauld is referring to!! I searched python.org and alan-g.me.uk.
Does anyone have a link?
On Mon, May 4, 2009 at 1:46 PM, Martin Walsh wrote:
> Nick Burgess wrote:
>> So far the script works fine, it avoids printing the
2009/5/4 Kent Johnson :
> str.decode() converts a string to a unicode object. unicode.encode()
> converts a unicode object to a (byte) string. Both of these functions
> take the encoding as a parameter. When Python is given a string, but
> it needs a unicode object, or vice-versa, it will encode or
On Mon, May 4, 2009 at 3:54 PM, Sander Sweers wrote:
> 2009/5/4 Kent Johnson :
>> str.decode() converts a string to a unicode object. unicode.encode()
>> converts a unicode object to a (byte) string. Both of these functions
>> take the encoding as a parameter. When Python is given a string, but
>>
On Mon, May 4, 2009 at 8:45 AM, Alex Feddor wrote:
> Hi
>
> I am looking for method enables advanced text string search. Method
> string.find() or re module seems no supporting what I am looking for. The
> idea is as follows:
>
> Text ="FDA meeting was successful. New drug is approved for whole s
On Mon, May 4, 2009 at 12:38 PM, vince spicer wrote:
> Advanced Strings searches are Regex via re module.
>
> EX:
>
> import re
>
> m = re.compile("(FDA.*?(approved|
> supported)|Ben[^\s])*")
>
> if m.search(Text):
> print m.search(Text).group()
This won't match "approved FDA" which may be de
Dear list,
in different books I come across different syntax for dealing with
files. It seems that open(filename, 'r') and file(filename, 'r') are
used interchangeably, and I wonder what this is all about. Is there a
reason why Python allows such ambiguity here?
Cheers for a quick shot of enlight
On Tue, May 05, 2009, David wrote:
>Dear list,
>
>in different books I come across different syntax for dealing with
>files. It seems that open(filename, 'r') and file(filename, 'r') are
>used interchangeably, and I wonder what this is all about. Is there a
>reason why Python allows such ambiguity
PDavid wrote:
Dear list,
in different books I come across different syntax for dealing with
files. It seems that open(filename, 'r') and file(filename, 'r') are
used interchangeably, and I wonder what this is all about. Is there a
reason why Python allows such ambiguity here?
regarding file
Dear Tutors and fellow pythonistas,
I would like to get access to the private methods of my function.
For instance:
Who can I reference the docstring of a function within the function itself?
Please have a look at the code below and assist me.
Thanks and regards,
Timmie
CODE ###
s = 'hel
On 5/4/2009 2:50 PM bob gailer said...
PDavid wrote:
Dear list,
in different books I come across different syntax for dealing with
files. It seems that open(filename, 'r') and file(filename, 'r') are
used interchangeably, and I wonder what this is all about. Is there a
reason why Python allows
On 5/4/2009 3:37 PM Tim Michelsen said...
Dear Tutors and fellow pythonistas,
I would like to get access to the private methods of my function.
For instance:
Who can I reference the docstring of a function within the function itself?
def show2(str):
"""prints str"""
print str
d =
First, thanks in advance for any insight on how to assist in making me a
better Python programmer.
Here is my question. I work with a lot of sockets and most of them require
hex data. I am usually given a string of data to send to the socket.
Example:
"414243440d0a"
Is there a way in Python to
Mr. Gauld is referring to!! I searched python.org and alan-g.me.uk.
Does anyone have a link?
I posted a link to the Python howto and my tutorial is at alan-g.me.uk
You will find it on the contents frame under Regular Expressions...
Its in the Advanced Topics section.
--
Alan Gauld
Author of t
On 5/4/2009 4:17 PM Tom Green said...
First, thanks in advance for any insight on how to assist in making me a
better Python programmer.
Here is my question. I work with a lot of sockets and most of them
require hex data. I am usually given a string of data to send to the
socket. Example:
"Emile van Sebille" wrote in message
news:gtnrtf$pi...@ger.gmane.org...
On 5/4/2009 2:50 PM bob gailer said...
PDavid wrote:
Dear list,
in different books I come across different syntax for dealing with
files. It seems that open(filename, 'r') and file(filename, 'r') are
used interchangeably,
Thank you, I didn't realize it was that easy. I tried binascii before and I
thought it didn't work properly.
I appreciate it.
Mike.
On Mon, May 4, 2009 at 7:40 PM, Emile van Sebille wrote:
> On 5/4/2009 4:17 PM Tom Green said...
>
>> First, thanks in advance for any insight on how to assist i
"Tom Green" wrote
Here is my question. I work with a lot of sockets and most of them
require
hex data. I am usually given a string of data to send to the socket.
Example:
"414243440d0a"
Is there a way in Python to say this is a string of HEX characters like
Perl's pack? Right now I have
On Mon, May 4, 2009 at 6:37 PM, Tim Michelsen
wrote:
> Who can I reference the docstring of a function within the function itself?
You can refer to the function by name inside the function. By the time
the body is actually executed, the name is defined:
In [1]: def show2(s):
...: """print
ect: [Tutor] Advanced String Search using operators AND, OR etc..
> To: tutor@python.org
> Message-ID:
><5bf184e30905040545i78bc75b8ic78eabf44a55a...@mail.gmail.com>
> Content-Type: text/plain; charset="iso-8859-1"
>
> Hi
>
> I am looking for method enables
(Please disregard my earlier message that was sent by mistake before I
finished composing. Sorry about that! :().
Hello Spir, Alan, and Paul, and tutors,
Thank you Spir, Alan, and Paul for your help with my previous code! Earlier,
I was asking how to separate a composite tag like the one in field
"spir" wrote in message
news:20090501220601.31891...@o...
Le Fri, 1 May 2009 15:19:29 -0300,
"Pablo P. F. de Faria" s'exprima ainsi:
self.cfg.write(codecs.open(self.properties_file,'w','utf-8'))
As one can see, the character encoding is explicitly UTF-8. But
ConfigParser keeps trying to sa
Alan Gauld wrote:
> And file has been removed again in Python v3
In fact open is now an alias for io.open and no longer simply returns
a file object - in fact the file type itself is gone too!
A pity, there are cases where I found file() more intuitive than
open and vice versa so liked havi
>> From: Alex Feddor
>>
>> I am looking for method enables advanced text string search. Method
>> string.find() or re module seems no supporting what I am looking
>> for. The idea is as follows:
>>
>> Text ="FDA meeting was successful. New drug is approved for whole
>> sale distribution!"
>>
>
42 matches
Mail list logo