AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Multi choice text and grammar correction
Goto page Previous  1, 2, 3  Next
 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
engunneer



Joined: 30 Aug 2005
Posts: 7698
Location: Germany (but I only speak English)

PostPosted: Sun Apr 12, 2009 8:27 pm    Post subject: Reply with quote

I simplified the \, comma replacement in HugoV's code. He did all the hard work, though.

Code:

/*
Multi choice text and grammar correction (Expand shorthand code)
Autohotkey 1.47+ @ http://www.autohotkey.com/
Forum: http://www.autohotkey.com/forum/topic43116.html
Type shorthand and press numpad0 (zero on the numeric keyboard)

Test:
 
4bcdefhikl
=
"The suspended timber floor in the moves underfoot, slopes, is
cracked and which, together with the nature of the site and the
construction of the property, leads us to suspect the quality of
the sub-floor construction. Therefore, a more detailed
investigation should be carried out. We would refer you to our
advice in Section C2 in respect of the timber decay, which may
be present under the floor."

*/

List= ; list of all sentences. You could replace this with a FileRead
(
[*] The front of the building faces approximately [A] north [B] north east [C] east [D] south east [E] south [F] south west [G] west [H] north west [-] and all directions in this report are given as if viewing the property from the front. [I] The main entrance is on the ... of the property.
[*] Access will be difficult [A] owing to the proximity of the main road [B] because of the restricted visibility\, [C] during severe weather as the drive is very steep\, [-] and great care must be taken with vehicles when entering or leaving the property. [D] As this could affect future saleability, we would refer you to our comments in Section F3.
[*] Within the [A] ... [-] roof space [B] stored household goods\, [C] insulation\, [D] timber boarding\, [E] dust/debris\, [F] a layer of polythene under the rafters\, [G] ... [H] also [I] severely [-] obstructed our inspection of the interior.
[*] The [A] solid [B] suspended timber [-] floor [C] in the ... [D] moves underfoot\, [E] slopes\, [F] is cracked\, [G] has lifted\, [-] which, [H] together with the nature of the site and the construction of the property, [-] leads us to suspect the quality of the [I] sub-floor construction. [J] supporting structure. [K] Therefore, a more detailed investigation should be carried out. [L] We would refer you to our advice in Section C2 in respect of the timber decay, which may be present under the floor.
[*] There is a [A] covered [B] open air [C] swimming pool [D] tennis court [E] leisure complex [F] ... [G] in the ... garden. [H] at the ... of the property. [*] No comments can be made on condition.
)
StringSplit, Sentence, List, `n ; create array

Numpad0::
AutoTrim, on
ClipSaved := ClipboardAll   ; Save the entire clipboard to restore later
Clipboard= ; clear clipboard
Send, ^+{left}^x ; cut word to the left
Clipwait, 2 ; wait for clipboard to have content
RegExMatch(Clipboard, "^\d+", Number) ; get sentence
Line := Sentence%Number%
; bug is here
StringReplace, Line, Line, [-], _, All ; mark for later use - they MUST be included but can not be part of the sections array
StringSplit, Section, Line, [ ; split string into sections (array)
Loop, % Section0 ; loop to remove "letter]"
   StringTrimLeft, Section%A_Index%, Section%A_Index%, 2

StringReplace, Shorthand, Clipboard, %Number%, , All ; translate shorthand code to section code
StringReplace, Shorthand, Shorthand, a,  3`,, all
StringReplace, Shorthand, Shorthand, b,  4`,, all
StringReplace, Shorthand, Shorthand, c,  5`,, all
StringReplace, Shorthand, Shorthand, d,  6`,, all
StringReplace, Shorthand, Shorthand, e,  7`,, all
StringReplace, Shorthand, Shorthand, f,  8`,, all
StringReplace, Shorthand, Shorthand, g,  9`,, all
StringReplace, Shorthand, Shorthand, h, 10`,, all
StringReplace, Shorthand, Shorthand, i, 11`,, all
StringReplace, Shorthand, Shorthand, j, 12`,, all
StringReplace, Shorthand, Shorthand, k, 13`,, all
StringReplace, Shorthand, Shorthand, l, 14`,, all
StringReplace, Shorthand, Shorthand, m, 15`,, all
StringReplace, Shorthand, Shorthand, n, 16`,, all
StringReplace, Shorthand, Shorthand, o, 17`,, all
StringReplace, Shorthand, Shorthand, p, 18`,, all
StringReplace, Shorthand, Shorthand, q, 19`,, all
StringReplace, Shorthand, Shorthand, r, 20`,, all
StringReplace, Shorthand, Shorthand, s, 21`,, all
StringReplace, Shorthand, Shorthand, t, 22`,, all
StringReplace, Shorthand, Shorthand, u, 23`,, all
StringReplace, Shorthand, Shorthand, v, 24`,, all
StringReplace, Shorthand, Shorthand, w, 25`,, all
StringReplace, Shorthand, Shorthand, x, 26`,, all
StringReplace, Shorthand, Shorthand, y, 27`,, all
StringReplace, Shorthand, Shorthand, z, 28`,, all
; etc if you need more.

StringTrimRight, Shorthand, Shorthand, 1 ; remove trailing ","
Shorthand = 2,%Shorthand% ; always include "first" sections (which is 2)

Loop, % Section0 ; loop all sections
   {
    Append:=Section%A_Index%
    IfInString, Append, _ ; at least part of this section must always be included
      {
       StringSplit, SplitAppend, Append, _
       Append:=SplitAppend1
      }
    If A_Index IN %Shorthand% ; get each section from Shorthand
      {
       IfInString, Append, ..
         {
          InputBox, InsertText, Insert Text, %FullText% %A_Space% %Append%
          StringReplace, Append, Append, ..., %InsertText%, All
         }
      }
    Else   
      Append=
    FullText .= Append " " SplitAppend2
    SplitAppend2=
   }
   
Loop ; get rid of space comma
{
    StringReplace, FullText, FullText, %A_Space%`,,`,,UseErrorLevel
    if ErrorLevel = 0 ; No more replacements needed.
        break
}

Loop ; get rid of double spacing
{
    StringReplace, FullText, FullText, %A_Space%%A_Space%,%A_Space%,UseErrorLevel
    if ErrorLevel = 0  ; No more replacements needed.
        break
}
FullText = %FullText% ; get rid of leading and trailing spaces
FullText .= " " ; add space :-)

; if one instance of \, is found, it is removed,
; if two instances are found, the first is replaced with an 'and' and the second one removed,
; if three or more of the instances are found, the last but one is replaced with an 'and' and the other \, tags are replaced with commas;


   StringReplace, FullText, FullText, `\`, , `\`,, UseErrorLevel ; get number of commas
   Commas:=ErrorLevel
   Loop % Commas-2
      StringReplace, FullText, FullText, `\`, , `,
   
   StringReplace, FullText, FullText, `\`, , %A_Space%and
   StringReplace, FullText, FullText, `\`, ,


   Clipboard:=FullText
   Sleep, 10
   FullText=
   Line=
   Number=
   Shorthand=
   Commas=
   Send ^v ; paste
   Clipboard := ClipSaved   ; Restore the original clipboard. Note the use of Clipboard (not ClipboardAll).
   ClipSaved =   ; Free the memory in case the clipboard was very large
Return

_________________
Unless noted, all code is UNTESTED.
Answers Here: 1.(Loops, Viruses, etc.) 2.Search 3.RTFM 4.Ask for Help.
PMs will be ignored unless you are hiring me.
Back to top
View user's profile Send private message Visit poster's website
stephenmika



Joined: 09 Apr 2009
Posts: 17
Location: Reading UK

PostPosted: Sun Apr 12, 2009 10:03 pm    Post subject: Multi choice text and grammar correction Reply with quote

Hugo and Engunneer, this is very good. I did not intend to seek a finished solution but I realise now that I simply do not have the expertise to add or improve what you both have already done. You are 95% there and if we can iron out a few last issues, I would like to make a contribution to a charity of Hugo's choice for his time and expertise which simply I could not replicate, (as you say Enginneer, he has done the most work).

These issues being -

1) Sorry but I did not tell you but I have a number of phrases which start not with an [*] but with an [A] choice - using the current program when just typing the phrase number, the program inserts the [A] text string and if the number and A are typed the first two options [A] and [B] text strings are inserted, if typing the number and the [B] choice, the [B] and [C] text strings are inserted - try the following phrase -

[A] The [B] However, the [C] roof timbers [D] rafters [E] and [F] purlins [-] need [G] more support\, [H] better restraint\, [I] some repair\, [-] to stop any [J] further [K] possible [-] deflection.

2) The ... insert GUI does not appear when the insert string, the three periods ... is in an option preceeded by the tag [-]. Try to use the insert in the following phrase -

[*] The [A] ... [-] roof is formed with [B] conventional [C] factory made [D] steel [E] timber [F] rafters\, [G] purlins\, [H] roof trusses\, [-] supporting the ....

Some final considerations -

3) If possible I would like to retain the phrase numbering as a reference in the list as not all phrases are number seqentially. For example phrase numbers run from 1 - 10 and then from 15 - 26 and then from 30 - 38 and then from 45 - 53 and then from 60 - 72 and so on. So there are no phrases 11 - 14, 27 - 29 or 39 - 44 and so on. This enables me to introduce a few new phrases without having to renumber them all which means a major change to the printed list. It also makes revisions a lot easier.

4) Whilst there is one tag ( \, - a backward slash and comma) for automatic 'ands', is it possible to have one other tag (say a forward slash and comma /, ) for another set of automatic 'ands'. This will enable me to have two sentances in one phrase, each of which could be pluralised without upsetting the placing of the earlier set of automatic 'ands'.

Well thats it. Again thank you both for your kind help.

Regards
_________________
Many thanks

Stephen Mika
University of Reading
Back to top
View user's profile Send private message
engunneer



Joined: 30 Aug 2005
Posts: 7698
Location: Germany (but I only speak English)

PostPosted: Mon Apr 13, 2009 12:12 am    Post subject: Reply with quote

4) is easy. here is the new section for comma replacement:
Code:

; if one instance of \, is found, it is removed,
; if two instances are found, the first is replaced with an 'and' and the second one removed,
; if three or more of the instances are found, the last but one is replaced with an 'and' and the other \, tags are replaced with commas;


   StringReplace, FullText, FullText, \`, , \`,, UseErrorLevel ; get number of commas
   Commas:=ErrorLevel
   Loop % Commas-2
      StringReplace, FullText, FullText, \`, , `,
   
   StringReplace, FullText, FullText, \`, , %A_Space%and
   StringReplace, FullText, FullText, \`, ,


; if one instance of /, is found, it is removed,
; if two instances are found, the first is replaced with an 'and' and the second one removed,
; if three or more of the instances are found, the last but one is replaced with an 'and' and the other \, tags are replaced with commas;
   StringReplace, FullText, FullText, /`, , /`,, UseErrorLevel ; get number of commas
   Commas:=ErrorLevel
   Loop % Commas-2
      StringReplace, FullText, FullText, /`, , `,
   
   StringReplace, FullText, FullText, /`, , %A_Space%and
   StringReplace, FullText, FullText, /`, ,


3) has a fast workaround (hack), but easy. Just add blank sentences with [*] for those lines. This is particularly easy to manage if you use a text editor with line numbers. The line number is the sentence number. I recommend PSPad, personally. You can then use a single FileRead command to get the sentences (and a FileInstall command just before it, so you can still distribute a single exe file to your users)

2) I'll try to look at this if Hugo doesn't beat me. (see edit below)

1) just put a [*] before the [A] and it should read just fine.

EDIT:
Code:


/*
Multi choice text and grammar correction (Expand shorthand code)
Autohotkey 1.47+ @ http://www.autohotkey.com/
Forum: http://www.autohotkey.com/forum/topic43116.html
Type shorthand and press numpad0 (zero on the numeric keyboard)

Test:
 
4bcdefhikl
=
"The suspended timber floor in the moves underfoot, slopes, is
cracked and which, together with the nature of the site and the
construction of the property, leads us to suspect the quality of
the sub-floor construction. Therefore, a more detailed
investigation should be carried out. We would refer you to our
advice in Section C2 in respect of the timber decay, which may
be present under the floor."

6bdh=
"There is a open air tennis court at the rear of the property."

9bdik=
"However, the rafters need some repair and to stop any possible deflection."


*/

List= ; list of all sentences. You could replace this with a FileRead
(
[*] The front of the building faces approximately [A] north [B] north east [C] east [D] south east [E] south [F] south west [G] west [H] north west [-] and all directions in this report are given as if viewing the property from the front. [I] The main entrance is on the ... of the property.
[*] Access will be difficult [A] owing to the proximity of the main road [B] because of the restricted visibility\, [C] during severe weather as the drive is very steep\, [-] and great care must be taken with vehicles when entering or leaving the property. [D] As this could affect future saleability, we would refer you to our comments in Section F3.
[*] Within the [A] ... [-] roof space [B] stored household goods\, [C] insulation\, [D] timber boarding\, [E] dust/debris\, [F] a layer of polythene under the rafters\, [G] ... [H] also [I] severely [-] obstructed our inspection of the interior.
[*] The [A] solid [B] suspended timber [-] floor [C] in the ... [D] moves underfoot\, [E] slopes\, [F] is cracked\, [G] has lifted\, [-] which, [H] together with the nature of the site and the construction of the property, [-] leads us to suspect the quality of the [I] sub-floor construction. [J] supporting structure. [K] Therefore, a more detailed investigation should be carried out. [L] We would refer you to our advice in Section C2 in respect of the timber decay, which may be present under the floor.
[*]
[*] There is a [A] covered [B] open air [C] swimming pool [D] tennis court [E] leisure complex [F] ... [G] in the ... garden. [H] at the ... of the property. [*] No comments can be made on condition.
[*]
[*] The [A] ... [-] roof is formed with [B] conventional [C] factory made [D] steel [E] timber [F] rafters\, [G] purlins\, [H] roof trusses\, [-] supporting the ....
[*] [A] The [B] However, the [C] roof timbers [D] rafters [E] and [F] purlins [-] need [G] more support\, [H] better restraint\, [I] some repair\, [-] to stop any [J] further [K] possible [-] deflection.
)


StringSplit, Sentence, List, `n ; create array

Numpad0::
AutoTrim, on
ClipSaved := ClipboardAll   ; Save the entire clipboard to restore later
Clipboard= ; clear clipboard
Send, ^+{left}^x ; cut word to the left
Clipwait, 2 ; wait for clipboard to have content
RegExMatch(Clipboard, "^\d+", Number) ; get sentence
Line := Sentence%Number%
; bug is here
StringReplace, Line, Line, [-], _, All ; mark for later use - they MUST be included but can not be part of the sections array
StringSplit, Section, Line, [ ; split string into sections (array)
Loop, % Section0 ; loop to remove "letter]"
   StringTrimLeft, Section%A_Index%, Section%A_Index%, 2

StringReplace, Shorthand, Clipboard, %Number%, , All ; translate shorthand code to section code
StringReplace, Shorthand, Shorthand, a,  3`,, all
StringReplace, Shorthand, Shorthand, b,  4`,, all
StringReplace, Shorthand, Shorthand, c,  5`,, all
StringReplace, Shorthand, Shorthand, d,  6`,, all
StringReplace, Shorthand, Shorthand, e,  7`,, all
StringReplace, Shorthand, Shorthand, f,  8`,, all
StringReplace, Shorthand, Shorthand, g,  9`,, all
StringReplace, Shorthand, Shorthand, h, 10`,, all
StringReplace, Shorthand, Shorthand, i, 11`,, all
StringReplace, Shorthand, Shorthand, j, 12`,, all
StringReplace, Shorthand, Shorthand, k, 13`,, all
StringReplace, Shorthand, Shorthand, l, 14`,, all
StringReplace, Shorthand, Shorthand, m, 15`,, all
StringReplace, Shorthand, Shorthand, n, 16`,, all
StringReplace, Shorthand, Shorthand, o, 17`,, all
StringReplace, Shorthand, Shorthand, p, 18`,, all
StringReplace, Shorthand, Shorthand, q, 19`,, all
StringReplace, Shorthand, Shorthand, r, 20`,, all
StringReplace, Shorthand, Shorthand, s, 21`,, all
StringReplace, Shorthand, Shorthand, t, 22`,, all
StringReplace, Shorthand, Shorthand, u, 23`,, all
StringReplace, Shorthand, Shorthand, v, 24`,, all
StringReplace, Shorthand, Shorthand, w, 25`,, all
StringReplace, Shorthand, Shorthand, x, 26`,, all
StringReplace, Shorthand, Shorthand, y, 27`,, all
StringReplace, Shorthand, Shorthand, z, 28`,, all
; etc if you need more.

StringTrimRight, Shorthand, Shorthand, 1 ; remove trailing ","
Shorthand = 2,%Shorthand% ; always include "first" sections (which is 2)

Loop, % Section0 ; loop all sections
   {
    Append:=Section%A_Index%
    IfInString, Append, _ ; at least part of this section must always be included
      {
       StringSplit, SplitAppend, Append, _
       Append:=SplitAppend1
      }
    If A_Index IN %Shorthand% ; get each section from Shorthand
      {
       IfInString, Append, ..
         {
          InputBox, InsertText, Insert Text, %FullText% %A_Space% %Append%
          StringReplace, Append, Append, ..., %InsertText%, All
         }
      }
    Else   
      Append=
    FullText .= Append " " SplitAppend2
    SplitAppend2=
   }
   
Loop ; get rid of space comma
{
    StringReplace, FullText, FullText, %A_Space%`,,`,,UseErrorLevel
    if ErrorLevel = 0 ; No more replacements needed.
        break
}

Loop ; get rid of double spacing
{
    StringReplace, FullText, FullText, %A_Space%%A_Space%,%A_Space%,UseErrorLevel
    if ErrorLevel = 0  ; No more replacements needed.
        break
}
FullText = %FullText% ; get rid of leading and trailing spaces
FullText .= " " ; add space :-)

; if one instance of \, is found, it is removed,
; if two instances are found, the first is replaced with an 'and' and the second one removed,
; if three or more of the instances are found, the last but one is replaced with an 'and' and the other \, tags are replaced with commas;


   StringReplace, FullText, FullText, \`, , \`,, UseErrorLevel ; get number of commas
   Commas:=ErrorLevel
   Loop % Commas-2
      StringReplace, FullText, FullText, \`, , `,
   
   StringReplace, FullText, FullText, \`, , %A_Space%and
   StringReplace, FullText, FullText, \`, ,


; if one instance of /, is found, it is removed,
; if two instances are found, the first is replaced with an 'and' and the second one removed,
; if three or more of the instances are found, the last but one is replaced with an 'and' and the other \, tags are replaced with commas;
   StringReplace, FullText, FullText, /`, , /`,, UseErrorLevel ; get number of commas
   Commas:=ErrorLevel
   Loop % Commas-2
      StringReplace, FullText, FullText, /`, , `,
   
   StringReplace, FullText, FullText, /`, , %A_Space%and
   StringReplace, FullText, FullText, /`, ,

;find any remaining ... and prompt for replacement
   Loop {
     If InStr(FullText, "...") {
          StringReplace, promptText, FullText, ... , -->...<--
       InputBox, InsertText, Insert Additional Text, %promptText%
        StringReplace, FullText, promptText, -->...<--, %InsertText%
       } else {
       break
      }
   }


   Clipboard:=FullText
   Sleep, 10
   FullText=
   Line=
   Number=
   Shorthand=
   Commas=
   Send ^v ; paste
   Clipboard := ClipSaved   ; Restore the original clipboard. Note the use of Clipboard (not ClipboardAll).
   ClipSaved =   ; Free the memory in case the clipboard was very large
Return


There might be a problem with #6 (in this example). it has another [*] in it. Should it be a letter or [-]?
_________________
Unless noted, all code is UNTESTED.
Answers Here: 1.(Loops, Viruses, etc.) 2.Search 3.RTFM 4.Ask for Help.
PMs will be ignored unless you are hiring me.
Back to top
View user's profile Send private message Visit poster's website
hugov



Joined: 27 May 2007
Posts: 2181

PostPosted: Mon Apr 13, 2009 7:07 am    Post subject: Reply with quote

Quote:
There might be a problem with #6 (in this example). it has another [*] in it. Should it be a letter or [-]?
[*] sections not in the beginning should also be included by default, but if you simply change those, easy to find with a text editor, to [-] it will include those by default, try it with 6.
_________________
Tut 4 Newbies
TF : Text file & string lib, TF Forum
Back to top
View user's profile Send private message Visit poster's website
hugov



Joined: 27 May 2007
Posts: 2181

PostPosted: Mon Apr 13, 2009 8:45 am    Post subject: Reply with quote

Keeping to your original format:

Save this as list.txt
Code:
1 [*] The front of the building faces approximately [A] north [B] north east [C] east [D] south east [E] south [F] south west [G] west [H] north west [-] and all directions in this report are given as if viewing the property from the front. [I] The main entrance is on the ... of the property.
2 [*] Access will be difficult [A] owing to the proximity of the main road [B] because of the restricted visibility\, [C] during severe weather as the drive is very steep\, [-] and great care must be taken with vehicles when entering or leaving the property. [D] As this could affect future saleability, we would refer you to our comments in Section F3.
3 [*] Within the [A] ... [-] roof space [B] stored household goods\, [C] insulation\, [D] timber boarding\, [E] dust/debris\, [F] a layer of polythene under the rafters\, [G] ... [H] also [I] severely [-] obstructed our inspection of the interior.
4 [*] The [A] solid [B] suspended timber [-] floor [C] in the ... [D] moves underfoot\, [E] slopes\, [F] is cracked\, [G] has lifted\, [-] which, [H] together with the nature of the site and the construction of the property, [-] leads us to suspect the quality of the [I] sub-floor construction. [J] supporting structure. [K] Therefore, a more detailed investigation should be carried out. [L] We would refer you to our advice in Section C2 in respect of the timber decay, which may be present under the floor.
15 [*] There is a [A] covered [B] open air [C] swimming pool [D] tennis court [E] leisure complex [F] ... [G] in the ... garden. [H] at the ... of the property. [-] No comments can be made on condition.
36 [*] The [A] ... [-] roof is formed with [B] conventional [C] factory made [D] steel [E] timber [F] rafters\, [G] purlins\, [H] roof trusses\, [-] supporting the ....
71 [*] [A] The [B] However, the [C] roof timbers [D] rafters [E] and [F] purlins [-] need [G] more support\, [H] better restraint\, [I] some repair\, [-] to stop any [J] further [K] possible [-] deflection.
and then you could use this
Code:
Fileread, import, list.txt
Loop, parse, import, `n, `r
   {
   StringLeft, Number, A_LoopField, (InStr(A_LoopField, A_Space) - 1)
   Sentence%Number% := SubStr(A_LoopField, InStr(A_LoopField, A_Space))
   }
MsgBox % Sentence15 ; example
to import the list (this would replace the StringSplit, Sentence, List, `n ; create array in the script(s) above.
This should be your original format is it not?
_________________
Tut 4 Newbies
TF : Text file & string lib, TF Forum
Back to top
View user's profile Send private message Visit poster's website
stephenmika



Joined: 09 Apr 2009
Posts: 17
Location: Reading UK

PostPosted: Mon Apr 13, 2009 10:15 am    Post subject: Multi choice text and grammar correction Reply with quote

Hugo, Engunneer, thank you both.

In 6 the other [*] is a mistake, appologies.

1) Putting the [*] before the phrases starting with [A] resolves this issue

3) I think the workaround with blank sentances is preferable with line numbers (PSPad) doing the job of referencing the phrases. Hugo, thanks for the code to strip the numbers but I prefer not to have a separate file 'list.txt' and would like to keep the whole set of phrases within the exe as this stops anyone playing around with the text file or deleting it entirely. This does happen.

4) excellent, now I can have two lots of 'ands'. I can also introduce other grammer rules based on the syntax used for coding the tags.

I look forward to resolving number 2 !

Kind regards
_________________
Many thanks

Stephen Mika
University of Reading
Back to top
View user's profile Send private message
hugov



Joined: 27 May 2007
Posts: 2181

PostPosted: Mon Apr 13, 2009 11:26 am    Post subject: Reply with quote

2) I think engunneer solved issue 2, try it.

List format: You can use the same method as above but keep the list IN the script like so
Code:
list=
(
1 [*] The front of the building faces approximately [A] north [B] north east [C] east [D] south east [E] south [F] south west [G] west [H] north west [-] and all directions in this report are given as if viewing the property from the front. [I] The main entrance is on the ... of the property.
2 [*] Access will be difficult [A] owing to the proximity of the main road [B] because of the restricted visibility\, [C] during severe weather as the drive is very steep\, [-] and great care must be taken with vehicles when entering or leaving the property. [D] As this could affect future saleability, we would refer you to our comments in Section F3.
3 [*] Within the [A] ... [-] roof space [B] stored household goods\, [C] insulation\, [D] timber boarding\, [E] dust/debris\, [F] a layer of polythene under the rafters\, [G] ... [H] also [I] severely [-] obstructed our inspection of the interior.
4 [*] The [A] solid [B] suspended timber [-] floor [C] in the ... [D] moves underfoot\, [E] slopes\, [F] is cracked\, [G] has lifted\, [-] which, [H] together with the nature of the site and the construction of the property, [-] leads us to suspect the quality of the [I] sub-floor construction. [J] supporting structure. [K] Therefore, a more detailed investigation should be carried out. [L] We would refer you to our advice in Section C2 in respect of the timber decay, which may be present under the floor.
15 [*] There is a [A] covered [B] open air [C] swimming pool [D] tennis court [E] leisure complex [F] ... [G] in the ... garden. [H] at the ... of the property. [-] No comments can be made on condition.
36 [*] The [A] ... [-] roof is formed with [B] conventional [C] factory made [D] steel [E] timber [F] rafters\, [G] purlins\, [H] roof trusses\, [-] supporting the ....
71 [*] [A] The [B] However, the [C] roof timbers [D] rafters [E] and [F] purlins [-] need [G] more support\, [H] better restraint\, [I] some repair\, [-] to stop any [J] further [K] possible [-] deflection.
)
Loop, parse, list, `n, `r
   {
   StringLeft, Number, A_LoopField, (InStr(A_LoopField, A_Space) - 1)
   Sentence%Number% := SubStr(A_LoopField, InStr(A_LoopField, A_Space))
   }
MsgBox % Sentence71 ; example
saves you the trouble of putting in empty [*]
_________________
Tut 4 Newbies
TF : Text file & string lib, TF Forum
Back to top
View user's profile Send private message Visit poster's website
stephenmika



Joined: 09 Apr 2009
Posts: 17
Location: Reading UK

PostPosted: Mon Apr 13, 2009 10:29 pm    Post subject: Multi choice text and grammar correction Reply with quote

Hugo, Engunneer, appolgies for the delay but it is Easter Monday here and a bank Holiday. I have added my working list of phrases below as I am not sure how to add the complete program to a reply

Now, problem 2 solved, - thanks Engunneer.

Engunneer, the automatic 'ands' is not quite right. If only one \, is present, it should be deleted but currently an 'and' is added. Try 23B with my phrases below

Hugo, whilst the MsgBox shows the right phrase number, inputting that number works fine until the number goes out of sequence. For example with my test phrases below,

typing 4 pulls phrase 5
typing 5 pulls phrase 6
and so on

typing 16 pulls phrase 20
typing 20 pulls phrase 24
typing 21 pulls phrase 25
typing 22 pulls phrase 30

But then it works -

typing 40 pulls phrase 40 ??
typing 41 pulls phrase 41 ??
typing 42 pulls phrase 42 ??

I think I will put in the blank line prefixed by [*] as you suggest as a workaround.

Finally, my whole 900+ phrase contains some 170000 characters - phew. this exceeds the maximum characters for a variable length. As mentioned previously, I would prefer to incoporate the whole phrases within the exe. Is it possible to concatenate the 'list' variable for say 200000 characters, if so, how is it done.

Hugo, if you want to send me info on a charity via Email, that would be fine.

Kind regards

list=
(
1 [*] 1None
2 [*] 2Not applicable.
3 [*] 3Inspected on the ....
5 [*] 5We are pleased to advise you that in our opinion this property is, on the whole, a reasonable purchase at the agreed price of £.... We found no evidence of any significant defects or shortcomings and providing the property is kept in good repair, we cannot foresee any special difficulties arising on resale in normal market conditions.
6 [*] 6The property is considered to be a reasonable purchase at the agreed price of £... provided that you are prepared to accept the cost and inconvenience of dealing with the various repair/improvement works reported. These deficiencies are quite common in properties of this age and type and as long as the necessary works are carried out to a satisfactory standard and the property is kept in good repair, we can see no reason why there should be any special difficulties on resale in normal market conditions.
7 [*] 7The property suffers from the exceptional disadvantage that ... and the agreed price of £... reflects this. However, we must advise you that in our opinion it is likely to have an adverse effect on resale. We therefore, urge you to consider with the utmost care whether you wish to proceed with the purchase.
8 [*] 8The property is considered to be a reasonable purchase provided that you are prepared to accept the cost and inconvenience of dealing with the various repair/improvement works reported. However, the agreed price of £... is in our opinion too high and you may wish to renegotiate it on the basis of the cost of the necessary repairs. [A] There is the further consideration that even if the works are carried out to a satisfactory standard, the particular disadvantage of ... will remain. You may, therefore, find resale difficult even if market conditions are favourable at the time.
9 [*] 9In our opinion the property is not a reasonable purchase at the agreed price of £.... This is because .... We very much regret, therefore, that we must advise you that it would be most unwise to proceed.
10 [*] 10This property is in need of extensive remedial/modernisation works and we recommend that, if you wish to proceed, you should obtain further advice and quotations as discussed in the report and listed in Section F. Although our overall opinion on the Market Value of the property would normally be given, in this particular case it is not possible to do so because of the very substantial nature and extent of the proposed works. However, we will be pleased to give our opinion as soon as this additional information becomes available.
11 [*] 11We are pleased to advise you that in our opinion this property is, on the whole, a reasonable purchase at or near the valuation. We found no evidence of any significant defects or shortcomings and providing the property is kept in good repair, we cannot foresee any special difficulties arising on resale in normal market conditions.
12 [*] 12The property is considered to be a reasonable proposition for purchase at the valuation provided that you are prepared to accept the cost and inconvenience of dealing with the various repair/improvement works reported. These deficiencies are quite common in properties of this age and type and as long as the necessary works are carried out to a satisfactory standard and the property is kept in good repair, we can see no reason why there should be any special difficulties on resale in normal market conditions.
13 [*] 13The property suffers from the exceptional disadvantage that ... and the valuation reflects this. However, we must advise you that in our opinion it is likely to have an adverse effect on resale. We, therefore, urge you to consider with the utmost care whether you wish to proceed with the purchase.
14 [*] 14The property is considered to be a reasonable purchase at the valuation provided that you are prepared to accept the cost and inconvenience of dealing with the various repair/improvement works reported. [A] There is the further consideration that even if the works are carried out to a satisfactory standard, the particular disadvantage of ... will remain. You may, therefore, find resale difficult even if market conditions are favourable at the time.
15 [*] 15In our opinion the property is not a reasonable purchase. This is because of .... We very much regret, therefore, that we must advise you that it would be most unwise to proceed.
16 [*] 16This property is in need of extensive remedial/modernisation works and we recommend that, if you wish to proceed, you should obtain further advice and quotations as discussed in the report and listed in Section F. Although our overall opinion on the Market Value of the property would normally be given, in this particular case it is not possible to do so because of the very substantial nature and extent of the proposed works. However, we will be pleased to give our opinion as soon as this additional information becomes available.
20 [*] 20The property is a [A] single storey [B] two storey [C] ... storey [D] split level [E] non-[F] traditional [G] back-to-back [H] mid-terraced [I] end-terraced [J] semi-detached [K] link detached [L] detached [M] chalet style [N] house [O] bungalow [P] cottage [-] built around ....
21 [*] 21The property is a [A] converted [B] purpose-built [C] self-contained [D] single storey [E] two storey [F] basement [G] ground floor [H] first floor [I] second floor [J] ... floor [K] flat [L] maisonette [-] with ... others in a ... storey building, built around ....
22 [*] 22We believe it was originally constructed for the [A] ... [B] local authority. [C] New Town Development Corporation. [D] housing association.
23 [A] 23It has been extended to the [B] front\, [C] side\, [D] rear\, [E] The accommodation has been extended into the roof [F] recently. [G] and this was carried out in .... [H] and your legal advisers should find out when this was carried out. [I] You should check whether local authority permission for the work has been obtained and in this respect, we refer you to our comments in Section E2.
24 [*] 24It was originally a ... and [A] was converted to its present form in .... [B] was converted to its present form some time ago. [C] your legal advisers should find out when this was carried out. [D] A check should be made whether local authority permission has been obtained for the work and we refer you to our comments in Section E2.
25 [*] 25The front of the building faces approximately [A] north [B] north east [C] east [D] south east [E] south [F] south west [G] west [H] north west [-] and all directions in this report are given as if viewing the property from the front. [I] The main entrance is on the ... of the property.
30 [*] 30The external walls are of [A] traditional [B] non-traditional [C] timber framed [D] cavity [E] and [F] solid [-] construction [G] (approximately ... mm thick) [H] (varying in thickness from ... mm to ... mm) [-] with [I] mainly [J] brick\, [K] reconstituted [L] stone\, [M] rendered\, [N] ...\, [O] clad [-] elevations.
31 [*] 31The main roof is [A] pitched and [B] flat and [-] covered with [C] tiles. [D] slates. [E] felt. [F] .... [-] Internally, the [G] floor is [H] floors are [I] mainly [-] of [J] timber [K] and [L] with some [M] solid [N] concrete [O] ... [-] construction.
32 [*] 32The [A] ... [B] addition [C] portion [D] also [-] has a [E] tile [F] slate [G] felt [H] ... [-] covered roof.
33 [*] 33The ... extension is [A] also [-] constructed in [B] ... mm thick [C] ... [D] brickwork\, [E] reconstituted [F] stone\, [G] rendered masonry\, [-] with a [H] timber [I] and [J] concrete [-] floor and a [K] tile [L] slate [M] felt [N] ... [-] covered roof.
34 [*] 34The [A] ... mm thick [-] external walls of the block are built of [B] concrete [C] brick\, [D] reconstituted [E] stone\, [F] rendered [G] masonry\, [H] ... [I] with ... cladding [-] and are of [J] timber framed [K] cavity [L] and [M] solid [-] construction. The main roof is covered with [N] tiles. [O] slates. [P] felt. [Q] ....
40 [*][A] 40Basement: [B] 40Cellar:
41 [*] 41Ground floor:
42 [*] 42First floor:
43 [*] 43Second floor:
44 [*] 44... floor:
)
_________________
Many thanks

Stephen Mika
University of Reading
Back to top
View user's profile Send private message
engunneer



Joined: 30 Aug 2005
Posts: 7698
Location: Germany (but I only speak English)

PostPosted: Tue Apr 14, 2009 3:01 am    Post subject: Reply with quote

Quote:

1 [*] 1None
2 [*] 2Not applicable.
3 [*] 3Inspected on the ....


are the numbers meant to be here twice?

A good charity is Autohotkey Smile I think there is a paypal link to support@autohotkey.com on the forum. I can dig it up if you like. Autohotkey is free because of donations. HugoV may of course ask for something else.

I'll try to look at the ands again later. (Have to do taxes right now)
_________________
Unless noted, all code is UNTESTED.
Answers Here: 1.(Loops, Viruses, etc.) 2.Search 3.RTFM 4.Ask for Help.
PMs will be ignored unless you are hiring me.
Back to top
View user's profile Send private message Visit poster's website
stephenmika



Joined: 09 Apr 2009
Posts: 17
Location: Reading UK

PostPosted: Tue Apr 14, 2009 7:00 am    Post subject: Reply with quote

Engunneer, yes the numbers are in twice. This makes it easier to check which phrase is produced when testing the Autokey sequence. They will be omitted in the final version - as follows

1 [*] None
2 [*] Not applicable.
3 [*] Inspected on the ....

Autokey Support will receive a contribution.

regards
_________________
Many thanks

Stephen Mika
University of Reading
Back to top
View user's profile Send private message
hugov



Joined: 27 May 2007
Posts: 2181

PostPosted: Tue Apr 14, 2009 7:13 am    Post subject: Reply with quote

- Instructions on how to Concatenate a list
- Replaced the and/comma routine with the old one, should work better now
- If you ALWAYS include [*] after a number it shouldn't get out of sync.
- Edit: I cleaned up some grammar typos in the code, added a short intro at the top of the script, others may find it useful ...

Update 2 - 15 April 2009:

Added Join`n % to list, saves you the trouble of escaping each %
Reference: http://www.autohotkey.com/docs/Scripts.htm#continuation

Update 1 - 14 April 2009:

50acdef
=
The external walls are concrete, brick, mud and stone with rendered verticals.

50acdf
The external walls are concrete, brick and stone with rendered verticals.

50acf
The external walls are concrete and stone with rendered verticals.

50af
The external walls are stone with rendered verticals.


Code:
/*

Multi choice text and grammar correction (Expand shorthand code)
Autohotkey 1.47+ @ http://www.autohotkey.com/

Forum : http://www.autohotkey.com/forum/topic43116.html
Usage : Type shorthand and press numpad0 (zero on the numeric keyboard)
Date : 14 April 2009
For : Stephen Mika @ University of Reading (UK)

Mandatory LIST FORMAT:

Number_[*]_Sentence
where _ denotes a space, if the [*] is not present it will fail

[*] Always include this start section
[A] Optional section as in 5ace
[-] Must always be included regardles of section of which it seems to be part of: [B] This is optional [-] but this section must always be included [C] Another optional peice
\, and /, one or more are translated to the correct number of commas and "and" see script below for explanation
If ... is part of a section user Input is requested

*/

list=
(Join`n %
1 [*] None
2 [*] Not applicable.
3 [*] Inspected on the ....
4 [*]
5 [*] We are pleased to advise you that in our opinion this property is, on the whole, a reasonable purchase at the agreed price of £.... We found no evidence of any significant defects or shortcomings and providing the property is kept in good repair, we cannot foresee any special difficulties arising on resale in normal market conditions.
6 [*] The property is considered to be a reasonable purchase at the agreed price of £... provided that you are prepared to accept the cost and inconvenience of dealing with the various repair/improvement works reported. These deficiencies are quite common in properties of this age and type and as long as the necessary works are carried out to a satisfactory standard and the property is kept in good repair, we can see no reason why there should be any special difficulties on resale in normal market conditions.
7 [*] The property suffers from the exceptional disadvantage that ... and the agreed price of £... reflects this. However, we must advise you that in our opinion it is likely to have an adverse effect on resale. We therefore, urge you to consider with the utmost care whether you wish to proceed with the purchase.
8 [*] The property is considered to be a reasonable purchase provided that you are prepared to accept the cost and inconvenience of dealing with the various repair/improvement works reported. However, the agreed price of £... is in our opinion too high and you may wish to renegotiate it on the basis of the cost of the necessary repairs. [A] There is the further consideration that even if the works are carried out to a satisfactory standard, the particular disadvantage of ... will remain. You may, therefore, find resale difficult even if market conditions are favourable at the time.
9 [*] In our opinion the property is not a reasonable purchase at the agreed price of £.... This is because .... We very much regret, therefore, that we must advise you that it would be most unwise to proceed.
10 [*] This property is in need of extensive remedial/modernisation works and we recommend that, if you wish to proceed, you should obtain further advice and quotations as discussed in the report and listed in Section F. Although our overall opinion on the Market Value of the property would normally be given, in this particular case it is not possible to do so because of the very substantial nature and extent of the proposed works. However, we will be pleased to give our opinion as soon as this additional information becomes available.
11 [*] We are pleased to advise you that in our opinion this property is, on the whole, a reasonable purchase at or near the valuation. We found no evidence of any significant defects or shortcomings and providing the property is kept in good repair, we cannot foresee any special difficulties arising on resale in normal market conditions.
12 [*] The property is considered to be a reasonable proposition for purchase at the valuation provided that you are prepared to accept the cost and inconvenience of dealing with the various repair/improvement works reported. These deficiencies are quite common in properties of this age and type and as long as the necessary works are carried out to a satisfactory standard and the property is kept in good repair, we can see no reason why there should be any special difficulties on resale in normal market conditions.
13 [*] The property suffers from the exceptional disadvantage that ... and the valuation reflects this. However, we must advise you that in our opinion it is likely to have an adverse effect on resale. We, therefore, urge you to consider with the utmost care whether you wish to proceed with the purchase.
14 [*] The property is considered to be a reasonable purchase at the valuation provided that you are prepared to accept the cost and inconvenience of dealing with the various repair/improvement works reported. [A] There is the further consideration that even if the works are carried out to a satisfactory standard, the particular disadvantage of ... will remain. You may, therefore, find resale difficult even if market conditions are favourable at the time.
15 [*] In our opinion the property is not a reasonable purchase. This is because of .... We very much regret, therefore, that we must advise you that it would be most unwise to proceed.
16 [*] This property is in need of extensive remedial/modernisation works and we recommend that, if you wish to proceed, you should obtain further advice and quotations as discussed in the report and listed in Section F. Although our overall opinion on the Market Value of the property would normally be given, in this particular case it is not possible to do so because of the very substantial nature and extent of the proposed works. However, we will be pleased to give our opinion as soon as this additional information becomes available.
17 [*]
18 [*]
19 [*]
20 [*] The property is a [A] single storey [B] two storey [C] ... storey [D] split level [E] non-[F] traditional [G] back-to-back [H] mid-terraced [I] end-terraced [J] semi-detached [K] link detached [L] detached [M] chalet style [N] house [O] bungalow [P] cottage [-] built around ....
21 [*] The property is a [A] converted [B] purpose-built [C] self-contained [D] single storey [E] two storey [F] basement [G] ground floor [H] first floor [I] second floor [J] ... floor [K] flat [L] maisonette [-] with ... others in a ... storey building, built around ....
22 [*] We believe it was originally constructed for the [A] ... [B] local authority. [C] New Town Development Corporation. [D] housing association.
23 [*] [A] It has been extended to the [B] front\, [C] side\, [D] rear\, [E] The accommodation has been extended into the roof [F] recently. [G] and this was carried out in .... [H] and your legal advisers should find out when this was carried out. [I] You should check whether local authority permission for the work has been obtained and in this respect, we refer you to our comments in Section E2.
24 [*] It was originally a ... and [A] was converted to its present form in .... [B] was converted to its present form some time ago. [C] your legal advisers should find out when this was carried out. [D] A check should be made whether local authority permission has been obtained for the work and we refer you to our comments in Section E2.
25 [*] The front of the building faces approximately [A] north [B] north east [C] east [D] south east [E] south [F] south west [G] west [H] north west [-] and all directions in this report are given as if viewing the property from the front. [I] The main entrance is on the ... of the property.
26 [*]
27 [*]
28 [*]
29 [*]
30 [*] The external walls are of [A] traditional [B] non-traditional [C] timber framed [D] cavity [E] and [F] solid [-] construction [G] (approximately ... mm thick) [H] (varying in thickness from ... mm to ... mm) [-] with [I] mainly [J] brick\, [K] reconstituted [L] stone\, [M] rendered\, [N] ...\, [O] clad [-] elevations.
31 [*] The main roof is [A] pitched and [B] flat and [-] covered with [C] tiles. [D] slates. [E] felt. [F] .... [-] Internally, the [G] floor is [H] floors are [I] mainly [-] of [J] timber [K] and [L] with some [M] solid [N] concrete [O] ... [-] construction.
32 [*] The [A] ... [B] addition [C] portion [D] also [-] has a [E] tile [F] slate [G] felt [H] ... [-] covered roof.
33 [*] The ... extension is [A] also [-] constructed in [B] ... mm thick [C] ... [D] brickwork\, [E] reconstituted [F] stone\, [G] rendered masonry\, [-] with a [H] timber [I] and [J] concrete [-] floor and a [K] tile [L] slate [M] felt [N] ... [-] covered roof.
34 [*] The [A] ... mm thick [-] external walls of the block are built of [B] concrete [C] brick\, [D] reconstituted [E] stone\, [F] rendered [G] masonry\, [H] ... [I] with ... cladding [-] and are of [J] timber framed [K] cavity [L] and [M] solid [-] construction. The main roof is covered with [N] tiles. [O] slates. [P] felt. [Q] ....
35 [*]
36 [*]
37 [*]
38 [*]
39 [*]
40 [*] [A] Basement: [B] Cellar:
41 [*] Ground floor:
42 [*] First floor:
43 [*] Second floor:
44 [*] ... floor:
45 [*]
46 [*]
47 [*]
48 [*]
49 [*]
50 [*] There is no garage with this property.
51 [*] There is [A] a terraced [B] a semi-detached [C] an attached [D] a detached [E] an integral [F] single [G] double [H] triple [-] garage with the property. [I] This is located in a separate block.
52 [*] [A] There is [B] There are [C] also [D] a shed\, [E] ... sheds\, [F] a greenhouse\, [G] an external w.c.\, [H] a conservatory\, [I] a covered way\, [J] a carport\, [K] ... [L] in the ... garden. [M] attached [N] to the ... of the property.
53 [*] [A] No [B] Only on-street [C] Off-street [D] Both on and off-street [-] parking is available. [E] Parking times are, however, restricted. [F] A residents' parking scheme operates in the immediate area. [G] Space is limited and parking may be a problem from time to time. [H] However, there is no dropped kerb adjoining the road for cars to gain access onto the property and we refer you to our comments in Section E2.
54 [*] There is a [A] covered [B] open air [C] swimming pool\, [D] tennis court\, [E] leisure complex\, [F] ... [G] in the ... garden. [H] at the ... of the property. [-] No comments can be made as this is outside the scope of the homebuyer service.
55 [*] There is no private garden with this property.
56 [*] The property has a [A] communal [B] surrounding [C] front\, [D] side\, [E] rear\, [-] garden. [F] The front garden is open plan with a drive.
57 [*] The property [A] fronts onto the pavement and [-] has a [B] small front [C] forecourt and a [D] garden and a [E] shared [F] private enclosed [-] rear [G] yard. [H] garden.
58 [*]
59 [*]
60 [*] The property is [A] on a small [B] on a large [C] ... [D] estate [-] in a [E] mixed [F] predominantly [G] residential\, [H] commercial\, [I] semi-rural [J] rural [-] area [K] within reasonable distance of the usual amenities. [L] with limited [M] with no [N] shopping facilities in the locality. [O] There is a wide range of shops and other services in ... which is approximately ... miles away.
61 [*] Public transport is [A] also [B] limited. [C] available in the immediate locality.
62 [*] On the estate there [A] is one other similar block of [B] are ... other similar blocks of [C] flats. [D] maisonettes.
63 [*] The immediate neighbourhood [A] is rather run down with a number of properties vacant and in various states of repair. [B] contains a number of rented properties. [C] has been substantially improved in recent years.
64 [*] The property is on a [A] relatively [B] flat [C] sloping [D] steep [E] low lying [F] terraced [-] site. [G] It is close to the [H] river [I] .... [J] Your legal advisers should make enquiries about the risk of flooding and we would refer you to our recommendations in Section E4.
65 [*] Access will be difficult [A] owing to the proximity of the main road\, [B] because of the restricted visibility\, [C] during severe weather as the drive is very steep\, [-] and great care must be taken with vehicles when entering or leaving the property. [D] As this could affect future saleability, we would refer you to our comments in Section F3.
66 [*] We believe the property is [A] also [B] on [C] close to [-] a former landfill site. Further enquiries should be made by your legal advisers and we refer you to our comments in Section E4. [D] This could also affect future saleability and you should consider our advice in Section F3.
67 [*] There is high voltage electrical supply equipment close to the property. The possible effects of electromagnetic fields have been the subject of media coverage. The Health Protection Agency (HPA), an independent body with responsibility for advising on electromagnetic fields, has advised that, following studies, there may be a risk, in specified circumstances, to the health of certain categories of people. Public perception may, therefore, affect marketability and future value of the property. Further, and detailed, technical information can be obtained from the HPA, Centre for Radiation, Chemical and Environmental Hazards at Chilton, Didcot, Oxon, OX11 ORO or at http://www.hpa.org.uk/radiation/default.htm or the environmental health department of the local authority, or from the local electricity company. [A] As mentioned, this could affect future saleability and we therefore, refer you to our recommendations in Section F3.
68 [*] The Health Protection Agency (HPA) has identified the local area as one in which, in more than 1% of dwellings, the levels of radon gas entering the property are such that remedial action is recommended. It is not possible in the course of the inspection/survey to determine whether radon gas is present in any given building, as the gas is colourless and odourless. Tests can be carried out to assess the level of radon in a building. At a small charge test instruments and results are available by post from the HPA and other approved laboratories. The minimum testing period is 3 months. The HPA strongly advises against using shorter-term instruments as they can give misleading results. If tests have not been carried out, they are recommended. It has been the experience of the HPD that it is not expensive, in proportion to the value of the property, to effect the recommended remedial measures. You can obtain further information from the HPD, Centre for Radiation, Chemical and Environmental Hazards at Chilton, Didcot, Oxon, OX11 ORO or at http://www.hpa.org.uk/radiation/default.htm or the environmental health department of the local authority. [A] Further enquiries should be made by your legal advisers and we refer you to our comments in Section E4. [B] As this could also affect future saleability, you should consider our comments in Section F3.
69 [*] The [A] proposed [B] building [C] road [D] development which we believe is taking place in the vicinity\, [E] proximity of [F] the motorway\, [G] the main road\, [H] the footpath\, [I] the right of way\, [J] the railway\, [K] the public house\, [L] a livestock farm\, [M] the ... airport flight path\, [N] the industrial estate\, [O] the sewage treatment plant\, [P] ... [Q] some ... miles away [-] may be a nuisance. [R] Further enquiries should be made by your legal advisers and we refer you to our recommendations in Section E4. [S] As this could also affect future saleability, we refer you our comments in Section F3.
70 [*] We believe the property [A] may be listed and [B] has been listed and [C] may be within a conservation area and [D] is located within a conservation area and [E] may have an agricultural occupancy restriction and [F] has an agricultural occupancy restriction and [-] a number of planning restrictions may therefore, be in force. Your legal advisers should make further enquiries about this and we refer you to our comments in Section E2.
)

 
Loop, parse, list, `n, `r
{
StringLeft, Number, A_LoopField, (InStr(A_LoopField, A_Space) - 1)
Sentence%Number% := SubStr(A_LoopField, InStr(A_LoopField, A_Space))
}

Numpad0::
AutoTrim, on
ClipSaved := ClipboardAll ; Save the entire clipboard to restore later
Clipboard= ; clear clipboard
Send, ^+{left}^x ; cut word to the left
Clipwait, 2 ; wait for clipboard to have content
RegExMatch(Clipboard, "^\d+", Number) ; get sentence number
Line := Sentence%Number%
StringReplace, Line, Line, [-], _, All ; mark for later use - they MUST be included but can not be part of the sections array
StringSplit, Section, Line, [ ; split string into sections (array)
Loop, % Section0 ; loop to remove "letter]"
StringTrimLeft, Section%A_Index%, Section%A_Index%, 2

StringReplace, Shorthand, Clipboard, %Number%, , All ; translate shorthand code to section code
StringReplace, Shorthand, Shorthand, a, 3`,, all
StringReplace, Shorthand, Shorthand, b, 4`,, all
StringReplace, Shorthand, Shorthand, c, 5`,, all
StringReplace, Shorthand, Shorthand, d, 6`,, all
StringReplace, Shorthand, Shorthand, e, 7`,, all
StringReplace, Shorthand, Shorthand, f, 8`,, all
StringReplace, Shorthand, Shorthand, g, 9`,, all
StringReplace, Shorthand, Shorthand, h, 10`,, all
StringReplace, Shorthand, Shorthand, i, 11`,, all
StringReplace, Shorthand, Shorthand, j, 12`,, all
StringReplace, Shorthand, Shorthand, k, 13`,, all
StringReplace, Shorthand, Shorthand, l, 14`,, all
StringReplace, Shorthand, Shorthand, m, 15`,, all
StringReplace, Shorthand, Shorthand, n, 16`,, all
StringReplace, Shorthand, Shorthand, o, 17`,, all
StringReplace, Shorthand, Shorthand, p, 18`,, all
StringReplace, Shorthand, Shorthand, q, 19`,, all
StringReplace, Shorthand, Shorthand, r, 20`,, all
StringReplace, Shorthand, Shorthand, s, 21`,, all
StringReplace, Shorthand, Shorthand, t, 22`,, all
StringReplace, Shorthand, Shorthand, u, 23`,, all
StringReplace, Shorthand, Shorthand, v, 24`,, all
StringReplace, Shorthand, Shorthand, w, 25`,, all
StringReplace, Shorthand, Shorthand, x, 26`,, all
StringReplace, Shorthand, Shorthand, y, 27`,, all
StringReplace, Shorthand, Shorthand, z, 28`,, all
; etc if you need more.

StringTrimRight, Shorthand, Shorthand, 1 ; remove trailing ","
Shorthand = 2,%Shorthand% ; always include "first" sections (which is 2)

Loop, % Section0 ; loop all sections
{
Append:=Section%A_Index%
IfInString, Append, _ ; at least part of this section must always be included
{
StringSplit, SplitAppend, Append, _
Append:=SplitAppend1
}
If A_Index IN %Shorthand% ; get each section from Shorthand
{
IfInString, Append, ..
{
InputBox, InsertText, Insert Text, %FullText% %A_Space% %Append%
StringReplace, Append, Append, ..., %InsertText%, All
}
}
Else
Append=
FullText .= Append " " SplitAppend2
SplitAppend2=
}

Loop ; get rid of space comma
{
StringReplace, FullText, FullText, %A_Space%`,,`,,UseErrorLevel
if ErrorLevel = 0 ; No more replacements needed.
break
}

Loop ; get rid of double spacing
{
StringReplace, FullText, FullText, %A_Space%%A_Space%,%A_Space%,UseErrorLevel
if ErrorLevel = 0 ; No more replacements needed.
break
}

FullText = %FullText% ; get rid of leading and trailing spaces
FullText .= " " ; add space Smile

; if one instance of \, is found, it is removed,
; if two instances are found, the first is replaced with an 'and' and the second one removed,
; if three or more of the instances are found, the last but one is replaced with an 'and' and the other \, tags are replaced with commas;

StringReplace, FullText, FullText, \`, , \`,, UseErrorLevel ; get number of commas
Commas:=ErrorLevel
If (Commas = 1)
StringReplace, FullText, FullText, \`, ,
Else If (Commas = 2)
{
StringReplace, FullText, FullText, \`, , %A_Space%and
StringReplace, FullText, FullText, \`, ,
}
Else If (Commas > 2)
{
Loop % Commas
{
If (A_Index = Commas - 1)
{
StringReplace, FullText, FullText, \`, , %A_Space%and
StringReplace, FullText, FullText, \`, ,
Break
}
Else
StringReplace, FullText, FullText, \`, , `,
}
}

; if one instance of /, is found, it is removed,
; if two instances are found, the first is replaced with an 'and' and the second one removed,
; if three or more of the instances are found, the last but one is replaced with an 'and' and the other \, tags are replaced with commas;

StringReplace, FullText, FullText, /`, , /`,, UseErrorLevel ; get number of commas
Commas:=ErrorLevel
If (Commas = 1)
StringReplace, FullText, FullText, `/`, ,
Else If (Commas = 2)
{
StringReplace, FullText, FullText, `/`, , %A_Space%and
StringReplace, FullText, FullText, `/`, ,
}
Else If (Commas > 2)
{
Loop % Commas
{
If (A_Index = Commas - 1)
{
StringReplace, FullText, FullText, /`, , %A_Space%and
StringReplace, FullText, FullText, /`, ,
Break
}
Else
StringReplace, FullText, FullText, /`, , `,
}
}

;find any remaining ... and prompt for replacement
Loop {
If InStr(FullText, "...") {
StringReplace, promptText, FullText, ... , -->...<--
InputBox, InsertText, Insert Additional Text, %promptText%
StringReplace, FullText, promptText, -->...<--, %InsertText%
} else {
break
}
}


Clipboard:=FullText
Sleep, 10
FullText= ; clear variables to free the memory
Line=
Number=
Shorthand=
Commas=
Send ^v ; paste
Clipboard := ClipSaved ; Restore the original clipboard. Note the use of Clipboard (not ClipboardAll).
ClipSaved = ; Free the memory in case the clipboard was very large
Return

_________________
Tut 4 Newbies
TF : Text file & string lib, TF Forum


Last edited by hugov on Wed Apr 15, 2009 9:45 am; edited 5 times in total
Back to top
View user's profile Send private message Visit poster's website
stephenmika



Joined: 09 Apr 2009
Posts: 17
Location: Reading UK

PostPosted: Tue Apr 14, 2009 10:00 am    Post subject: Multi choice text and grammar correction Reply with quote

Hugo, thank you. I will work on the Concatenation later today.

The auto 'ands' still seems to cause a problem when there are more than two \,. The 'and' appears to replace the last \, and not the previous one.

Try this phrase

50 [*][A] The [B] However, the [-] external walls are [C] concrete\, [D] brick\, [E] mud\, [F] stone\, [-] with rendered [G] masonry/, [H] timber/, [I] plasterboard/, [J] wattle/, [-] verticals.

50acdef produces
The exterrnal walls are concrete, brick, mud, stone and with rendered verticals.

Kind regards
_________________
Many thanks

Stephen Mika
University of Reading
Back to top
View user's profile Send private message
hugov



Joined: 27 May 2007
Posts: 2181

PostPosted: Tue Apr 14, 2009 10:33 am    Post subject: Reply with quote

Good catch. The ", and" should be fixed now, I've updated the script above. I PMed you about the charity. Thanks in advance.
_________________
Tut 4 Newbies
TF : Text file & string lib, TF Forum
Back to top
View user's profile Send private message Visit poster's website
engunneer



Joined: 30 Aug 2005
Posts: 7698
Location: Germany (but I only speak English)

PostPosted: Wed Apr 15, 2009 7:33 am    Post subject: Reply with quote

I see now the flaw in my logic. Hugo's code is more robust. It was interesting to look at the script. I really like the result.
_________________
Unless noted, all code is UNTESTED.
Answers Here: 1.(Loops, Viruses, etc.) 2.Search 3.RTFM 4.Ask for Help.
PMs will be ignored unless you are hiring me.
Back to top
View user's profile Send private message Visit poster's website
stephenmika



Joined: 09 Apr 2009
Posts: 17
Location: Reading UK

PostPosted: Wed Apr 15, 2009 7:44 am    Post subject: Multi choice text and grammar correction Reply with quote

Hugo, thanks for your revsion but I cannot see the script in your help message. Am I missing somethng?

Kind regards
_________________
Many thanks

Stephen Mika
University of Reading
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Goto page Previous  1, 2, 3  Next
Page 2 of 3

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group