library(readsent)read_until(?Delimiters, -Answer)
trim_blanks(+RawInput, ?Cleaned)
chars_to_words(+Chars, ?Words)
atom(X)
atom(the)
integer(X)
integer(12)
apost
'
aposts
's
string(X)
"..sequence of any.."
Thus the string the "Z-80" is on card 12. would be parsed as
[atom(the),string('Z-80'),atom(is),atom(on),atom(card), integer(12),'.'].
It is up to the sentence parser to decide what to
do with these. Note that the final full stop, if any, is retained,
as the parser may need it.
case_shift(+Mixed, ?Lower)
chars_to_atom has to alter. See also lower/2 in library(caseconv).
read_line(-Chars)
trim_blanks on the result. For
a routine that does not include the newline character in the result,
see the predicate get_line/1 in library(lineio).
read_sent(-Sentence)
is_period/1)
it finds, then throws characters
away until it has reached the end of a line. The characters read are then
broken up into "words", where a "word" is
atom(Word). For example, THIS would be returned
as atom(this)
integer(Value). For example, 0123 would be returned as integer(123).
Plus and minus signs become separate atoms.
string(X), where X is an atom containing the characters
between the quotes. Two adjacent quotes are read as one, so the input string
Double "" Quote is returned as string('Double " Quote').
's) is returned as the atom aposts.
') is returned as the atom apost.
The resulting string is returned in Sentence. Here is an example.
| ?- read_sent(X).
|: The predicate read_sent/1 accepts sentences
|: that span more than 1 line, but not lines
|: that contain +2 or more sentences. trash trash
X = [atom(the),atom(predicate),string(read_sent),
atom(accepts),atom(sentences),atom(that),
atom(span),atom(more),atom(than),integer(1),
atom(line),',',atom(but),atom(not),atom(lines),
atom(that),atom(contain),+,integer(2),atom(or),
atom(more),atom(sentences),.]
This is more unwieldy than the output of read_in/1, but it does mean that
your parser can tell the difference between words, numbers, and strings
by pattern matching rather than having to use the meta-logical
predicates atom/1, integer/1, and so forth.