Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #26261

Re: simplified Python parsing question

Path csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <esj@harvee.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.002
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'string.': 0.04; 'subject:Python': 0.05; 'source.': 0.05; 'class,': 0.07; 'expressions': 0.07; 'parsing': 0.07; 'table.': 0.07; 'subject:question': 0.08; 'python': 0.09; ':-(': 0.09; 'backwards': 0.09; 'parsed': 0.09; 'subject:parsing': 0.09; 'symbols': 0.09; 'programs.': 0.11; ':-)': 0.13; 'file,': 0.15; '"level"': 0.16; '10:59': 0.16; 'programmers.': 0.16; 'pygments': 0.16; 'symbol,': 0.16; 'tokenize': 0.16; 'translation': 0.16; 'wrote:': 0.17; 'code.': 0.20; 'translate': 0.20; 'define': 0.20; 'otherwise,': 0.20; 'trying': 0.21; 'disabled': 0.22; 'sorry,': 0.22; 'example': 0.23; 'split': 0.23; 'random': 0.24; 'idea': 0.24; 'header:In-Reply-To:1': 0.25; 'header:User-Agent:1': 0.26; 'skip:[ 10': 0.26; 'am,': 0.27; 'possibility': 0.27; 'in.': 0.27; 'regular': 0.27; 'block,': 0.29; 'cases.': 0.29; 'dictionary': 0.29; 'spaces': 0.29; 'staying': 0.29; 'definition': 0.29; 'probably': 0.29; 'this.': 0.29; "i'm": 0.29; '(from': 0.30; 'normally': 0.30; 'code': 0.31; 'help,': 0.32; 'could': 0.32; 'problem': 0.33; 'to:addr:python-list': 0.33; 'form.': 0.33; 'times.': 0.33; 'another': 0.33; 'adds': 0.35; 'direction': 0.35; 'there': 0.35; 'received:org': 0.36; 'but': 0.36; 'generation': 0.36; 'method': 0.36; 'should': 0.36; 'too': 0.36; 'possible': 0.37; 'subject:: ': 0.38; 'fact': 0.38; 'to:addr:python.org': 0.39; 'received:192': 0.39; 'space': 0.39; 'little': 0.39; 'received:192.168': 0.40; 'header:Received:5': 0.40; 'help': 0.40; 'think': 0.40; 'your': 0.60; 'identify': 0.61; 'first': 0.61; 'letters': 0.62; 'more': 0.63; 'family': 0.68; 'friendly': 0.71; 'increase': 0.72; 'hand': 0.82; 'friends': 0.83; 'affraid': 0.84; 'complexity': 0.84; 'divide': 0.84; 'nagy': 0.84; 'papers,': 0.84; 'probably,': 0.84; 'received:192.168.1.7': 0.84; 'recognition': 0.84; 'speech': 0.84; 'navigate': 0.91
X-Virus-Scanned amavisd-new at harvee.org
Date Mon, 30 Jul 2012 11:40:50 -0400
From "Eric S. Johansson" <esj@harvee.org>
User-Agent Mozilla/5.0 (Windows NT 6.1; WOW64; rv:14.0) Gecko/20120713 Thunderbird/14.0
MIME-Version 1.0
To python-list@python.org
Subject Re: simplified Python parsing question
References <5015C58D.4040101@harvee.org> <50165308.5060708@shopzeus.com> <50165A94.5050906@harvee.org> <5016A140.7010106@shopzeus.com>
In-Reply-To <5016A140.7010106@shopzeus.com>
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.2735.1343662857.4697.python-list@python.org> (permalink)
Lines 47
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1343662857 news.xs4all.nl 6900 [2001:888:2000:d::a6]:43930
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:26261

Show key headers only | View raw


On 7/30/2012 10:59 AM, Laszlo Nagy wrote:
>
>>
>> yeah the problem is also little more complicated than simple parsing of 
>> Python code. For example, one example (from the white paper)
>>
>> *meat space blowback = Friends and family [well-meaning attempt]
>>
>> *could that be parsed by the tools you mention?
>
> It is not valid Python code. Pygments is able to tokenize code that is not 
> valid Python code. Because it is not parsing, it is just tokenizing. But if 
> you put a bunch of random tokens into a file, then of course you will never be 
> able to split that into statements.

If you have been reading the papers, you would understand what I'm doing. I'm 
trying to take Python code with speech recognition friendly symbols and 
translate the symbols into a code friendly form. My conjecture is that you can 
change your perspective on the code and look for the edge that would normally be 
used to define start of a symbol, you should be able to define the name string. 
Another possibility is looking at the region which just contains letters numbers 
and spaces and outside and use that as your definition of a name string. It 
would probably help to verify that each word is found in a dictionary although 
that adds extra complexity if you are trying to increase the dictionary at the 
same time as the translation table.

I'm beginning to think for the first generation I should just use regular 
expressions looking forwards and backwards and try to enumerate the possible cases.
>
> Probably, you will need to process ident/dedent tokens, identify the "level" 
> of the satement. And then you can tell what file, class, inner class, method 
> you are staying in. Inside one "level" or code block, you could try to divide 
> the code into statements.

I was starting in that direction so that is good confirmation

>
> Otherwise, I have no idea how a blind person could navigate in a Python 
> source. In fact I have no idea how they use regular programs. So I'm affraid I 
> cannot help too much with this. :-(

I'm sorry, I am, and I'm trying to help, hand disabled programmers. There are 
more disability than blindness and after almost 20 years of encountering this 
shortsightedness, I do get a little cranky at times. :-)
>
>

Back to comp.lang.python | Previous | NextNext in thread | Find similar | Unroll thread


Thread

Re: simplified Python parsing question "Eric S. Johansson" <esj@harvee.org> - 2012-07-30 11:40 -0400
  Re: simplified Python parsing question Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-07-31 01:54 +0000
    Re: simplified Python parsing question "Eric S. Johansson" <esj@harvee.org> - 2012-07-30 22:11 -0400
      Re: simplified Python parsing question "BartC" <bc@freeuk.com> - 2012-08-03 21:04 +0100
    OT: accessibility (was "Re: simplified Python parsing question") Tim Chase <python.list@tim.thechases.com> - 2012-07-30 21:54 -0500
    Re: OT: accessibility (was "Re: simplified Python parsing question") Ian Kelly <ian.g.kelly@gmail.com> - 2012-07-31 00:23 -0600
    Re: OT: accessibility (was "Re: simplified Python parsing question") "Eric S. Johansson" <esj@harvee.org> - 2012-07-31 07:56 -0400
    Re: simplified Python parsing question Chris Angelico <rosuav@gmail.com> - 2012-08-01 08:15 +1000

csiph-web