LISTSERV mailing list manager LISTSERV 16.0

Help for SW-L Archives


SW-L Archives

SW-L Archives


SW-L@LISTSERV.VALENCIACOLLEGE.EDU


View:

Message:

[

First

|

Previous

|

Next

|

Last

]

By Topic:

[

First

|

Previous

|

Next

|

Last

]

By Author:

[

First

|

Previous

|

Next

|

Last

]

Font:

Proportional Font

LISTSERV Archives

LISTSERV Archives

SW-L Home

SW-L Home

SW-L  October 2011

SW-L October 2011

Subject:

Re: Signbox size and coordinate strings

From:

Alan Post <[log in to unmask]>

Reply-To:

SignWriting List: Read and Write Sign Languages

Date:

Thu, 6 Oct 2011 11:36:18 -0600

Content-Type:

text/plain

Parts/Attachments:

Parts/Attachments

text/plain (143 lines)

I've seen too much code that uses regular expressions when it should
be doing actual parsing, and the slipperly slope of that boundary is
having to do backtracking/lookahead in a regular expression.

The end-game, if you're not going to work on optimizing what you've
got, is to define the full grammar for this data encoding, use a
parser, and pick the data you'd like out of the parse tree, rather
than cherry-picking it out of the incoming data by using a regular
expression.

There is a very large design space between there and the problem
you're trying to solve, though!  I'm not suggesting the above to be
the only route available.  It's just where all the roads lead.

I wonder why you have 0,0 at the origin, rather than at one of the
corners?  It seems computationally more efficient to pick 0,0 to be,
say, the bottom left and get rid of negative numbers entirely.  You
can always normalize your coordinate system by doing what you
describe below, but all the intermediate steps would just use the
always-positive x,y values.

The idea of providing a limit on the coordinate size seems very
sound to me.  TeX did this, many years ago, because paper is only so
large, and you can pick a value that is an order of magnitude larger
and find that no one ever cares.  The same principle applies here,
a sufficiently high limit is essentially infinite, because the
problem domain is defined by limitations of human perception, not
by limitations of current computer hardware.

As a final note, least relevant, there are at least two ways to
build regular expression engines, and they each have different
performance behaviors with different classes of regular expressions.
Are you using a bad RE engine?  Will other users do so if you don't?
(http://swtch.com/~rsc/regexp/regexp1.html)  Even simple things like
compiling the RE before using it can make a difference...

Nothing below scares me, from a living with it forever point of
view,

-Alan

On Thu, Oct 06, 2011 at 10:58:47AM -0500, Steve Slevinski wrote:
> Hi list,
> 
> Here is my current design and a technical discussion.  Any feedback
> is appreciated.  Please ignore if you don't want to peak under the
> hood.
> 
> Background material:
> =============
> 1) Regular Expressions
> http://en.wikipedia.org/wiki/Regular_expression
> 
> 2) Cartesian Coordinates.
> http://en.wikipedia.org/wiki/Cartesian_coordinates
> 
> =============
> 
> I use Cartesian Coordinates for the SignPuddle data.  We start with
> a 2-dimensional canvas.  Both the width and the height are divided
> into specific points to create a grid.  The center of the grid is
> point (0,0).  The horizontal position is called the X value.  The
> vertical position is called the Y value.
> 
>          -y|
>            |
>            |
>            |
> -x         |          +x
> -----------+------------
>            |
>            |
>            |
>            |
>          +y|
> 
> 
> 
> In my current design, the x and y values are unlimited.  Negative to
> the top-left.  Positive to the bottom-right.
> 
> In general, the challenge I face is to create a string that
> represents a specific coordinate.  My current string has the form
> "n100x100" for the coordinate (-100,100)".  Simply replace the "-"
> minus sign with an "n" and replace the "," comma with an "x".  The
> purpose of these replacements is to enable double click selection.
> The "n" and the "x" continue the string without a character that
> creates a gap.
> 
> Regular Expressions allow for efficient searching and pattern
> matching.  Regular expressions are simple and powerful when used
> correctly.  They can easily become overly complex and difficult to
> understand.
> 
> The current coordinate characters can be described with the regular
> expression pattern:
> "n?[0-9]+xn?[0-9]+"
> 
> This can be understood in parts.
> 
> n? , may or may not have an "n"
> 
> [0-9] , select one value between 0 and 9.
> 
> [0-9]+ , select one or more digits
> 
> x , match the character "x"
> 
> I've run into a problem that general searching is inefficient or
> slow.  This is due to Unicode and the current form of the coordinate
> value.  More accurate searching is forcing me use overly complex
> Regular Expressions features, like negative lookahead.
> 
> I think I need to change the form of my coordinates so that
> searching