comp.lang.ada
 help / color / mirror / Atom feed
From: mfb@mbunix.mitre.org (Michael F Brenner)
Subject: Re: String to Integer conversion.
Date: 1997/03/31
Date: 1997-03-31T00:00:00+00:00	[thread overview]
Message-ID: <5hoqre$6sk@top.mitre.org> (raw)
In-Reply-To: 333FEBF5.2143@mersinet.co.uk


Bazza asks:
    > Does anyone know how to convert something such as: 223 + 4234
    > from a string, to 3 seperate variables, 223, + and 4234.

Yes, there are several ways of doing it, including (a) using a shell tool
with regular expressions (like awk, perl, Snobol, gnat, turbo pascal, 
SQL PLUS, or Refine), (b) using a table-driven finite state automaton (FSA), 
(c) using a FSA implemented in code, (d) writing ad hoc code which would 
be hopefully equivalent to the FSA, (e) enhancing the FSA to automatically
generate the output according to a table in which case we may call it
a finite state transducer (FST), (f) enhancing the FST with a stack to 
permit nesting of expressions and parentheses, (g) using a semi-Thue
string rewriting system to cause the transduction, (h) enhancing the FST
with a staging mechanism to control parallel execution which we may call
a Petri Net, (i) writing a genetic algorithm to learn the typical patterns
of expressions used by programmers and from that table of patterns 
constructing a neural net to do the conversion, (j) congealing in an
electrophoresis vat a set of DNA molecules whose amino sequences encode
all possible valid strings in the desired grammar for the potential
algebraic expressions being recognized, (k) building an optical computer
using lenses - prisms - collators - mirrors - inferometers - and various
control mechanisms to do the recognition combined with computer generated
holographic output devices like those at the MIT optics lab, (l) using
the RS-232 interface to a TI calculator with an optical scanner reading
the display, (m) using a human computer comprising a sighted person
responsible for seeing and perceiving the inputs and a parser theory
student responsible for lexically processing the inputs and a Votrex
chip board to speak the outputs from the lexical processing stage, 
(n) assign it to your students, (o) ask on comp.lang.ada. The following 
FSA would perform the transduction you requested, subject to your
interpretation of the words <something such as>, using the techniques
in Epstein, Word Processing in Groups, or Ullman, the Dragon book. 

    > 223 + 4234 from a string, to 3 seperate variables, 223, + and 4234

type classes is (blank, end_of_file, all_others);
type states is (start, got_blank, got_blank_2, error, done);
type transition_rows is array (classes) of states;
type transition_matrices is array (states) of transition_rows;

transition_matrix: constant transition_matrices := 
  (start       => (got_blank,   error, start,       error, error),
   got_blank   => (got_blank,   error, got_blank,   error, error), 
   got_blank_2 => (got_blank_2, done,  got_blank_2, error, error),
   error       => (error,       error, error,       error, error),
   done        => (error,       error, error,       error, error));




  reply	other threads:[~1997-03-31  0:00 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1997-03-31  0:00 String to Integer conversion Bazza
1997-03-31  0:00 ` Michael F Brenner [this message]
1997-04-01  0:00 ` Bazza
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox