[Date Prev][Date Next][Subject Prev][Subject Next][ Date Index][ Subject Index]

2 spaces





Following is a version of a program to add two spaces at the end
of sentences. Note that the abbreviations list is sparse, but it
only pertains to uppercase abbreviations. Lowercase ones are
skipped over.

I don't even pretend it's complete. It works successfully on the
kind of files I receive and use, but everyone has a unique
situation. However, if anyone has anything to say, feel welcome,
either simple or complex. I've seen enough of my programs run on
other people's computers to know that seemingly meaningless
factors can have a major consequence, but I have tested it in
Xy3+, Xy4, and Xywin. It took about 7 sec to process a 22K file
in Xy3+. And I know that Xy4 and Xywin have advanced features
that 3+ doesn't, but I like all my programs to run wherever I use
them whenever I can.

The way I look at it, having user feedback is best, but it's also
time-consuming. So I prefer an automatic approach even if it
overlooks some instances. That's what proofreaders are for. :)

--------------------------------------------------------------


{lb-2pace.pm, to try to add two spaces after a sentence}DX {gl-var}

If anyone's trying to type this, it would be better to leave the
display on (leaving DX out). Moreover, the program assumes
redlining off, insert mode, normal display.

Note that comment lines don't affect the program (except maybe
make it a little slower) as long as they're written between
labels.

Variables include a counter, alpha, space, return, middle
initials, common abbreviations. Of course, they can be extended
as desired.

{lb-var}{sv10, }{sv12, }{sv15,A}{sv16,Z}{sv20,}
{sv41,A.B.C.D.E.F.G.H.I.J.K.L.M.N.O.P.R.S.T.U.V.W.X.Y.Z.}
{sv42,Mr.Mrs.Ms.Jr.Dr.Prof.}GT {gl-mainloop}

Take the cursor position to determine end of program, and define
what is between the sentences.

{lb-mainloop}{sx33,{CP}}NS {sx35,{CP}}{if({pv33}=={pv35})}
{gl-end}{ei}DF CR DF {sv17}XD {gl-where}

Check to see if we're dealing with an abbreviation (such as U.S.,
the cursor would land on an alpha).

{lb-where}{sx17,@UPR({is17})}{if({is17}=>{is15})&({is17}=<{is16})}

{gl-mainloop}{ei}CR CR DF CL CL PW DF {sv77}XD {gl-word}

If there's an ENTER or a double-space, go back to the main loop:
the extra cursor moves are to account for outside punctuation,
such as parens or quotes.

Note that the lowercase e between is## expressions represents
epsilon.

{lb-word}NW {if({is12}e{is77}=>0)!({is20}e{is77}=>0)}
{gl-mainloop}{ei}{gl-cap}

If it's a cap letter, ask to insert space; if not, back to
mainloop.

{lb-cap}DF CR DF {sv79}XD {if({is79}=>{is15})&({is79}=<{is16})}CL
PW DW {sv81}XD {gl-ask}{ei}{gl-mainloop}

The ask came about because I thought of asking for feedback; but
I thought, "Would I want to bother. No" . . . so it's automatic.

Note that the lowercase e between is## expressions represents
epsilon.

{lb-ask}{if({is81}e{is41}=>0)!({is81}e{is42}=>0)}{gl-mainloop}
{ei}NW {gl-place}

The trick of going to the next word and a search back is not to
be tripped up over ellipsis.

{lb-place}BC seb / /XC {if{er}}{gl-abort1}{ei}{pv10}{gl-mainloop}

The error condition above is theoretically impossible, but why not.

{lb-abort1}DO {PRUnexpected missing space--aborted}{ex}

The end.

{lb-end}DO {PRDid it--maybe}{ex}
---
 ? SLMR 2.1a ? Art + write + dtp = chet.gottfried@xxxxxxxx