Monday, October 1, 2012

Re: Matching/Sorting line terminations

On Sep 30, 11:31 am, jbl <lethbri...@jblethbridge.com> wrote:
> Hi. Thanks. Here is a better sample of the raw lines file sorted as
> you suggest. This is the form I generated ages ago to work on these
> repetitions, and which I am now trying to sort again into groups
> repeating the last two terms, last three terms ... and so on. You can
> see that the repetitions of two and three terms and non-repetitions
> are all mixed up together:
>
> FQ 6.8.5.5 And did his head for bashfulnesse abase
> FQ 4.6.3.4 The armes he bore, his speare he gan abase
> FQ 6.6.31.9 He stayd his second strooke, and did his hand abase
> FQ 6.1.12.7 But through misfortune, which did me abase
> FQ 5.5.30.1 With that she turn'd her head, as halfe abashed
> FQ 6.4.30.7 All these our ioyes, and all our blisse abate
> FQ 4.8.1.7 With sufferaunce soft, which rigour can abate
> FQ 1.3.7.2 Quoth she, his princely puissance doth abate
> FQ 3.7.35.3 That at the last his fiercenesse gan abate
> FQ 4.8.17.8 That her inburning wrath she gan abate
> FQ 3.8.28.7 Ne ought your burning fury mote abate
> FQ 3.8.51.6 Mote not mislike you also to abate
> FQ 3.9.14.4 And both full liefe his boasting to abate
> FQ 4.9.34.6 Him selfe he bent their furies to abate
> FQ 4.3.26.6 Which when for want of breath gan to abate
> FQ 1.10.26.2 His daintie corse, proud humors to abate
> FQ 5.9.46.7 Which when as \Zele\ perceiued to abate
> FQ 4.2.50.2 To graunt her boone, and rigour to abate
> FQ 2.2.19.5 And th'=others pleasing seruice to abate
> FQ 5.12.19.1 So did the Faerie knight himselfe abeare
> FQ 6.9.45.1 Thus did the gentle knight himselfe abeare
> FQ 4.3.11.2 The meede of thy mischalenge and abet
> FQ 6.5.22.4 To reskue him, and his weake part abet
>
> I think the command you suggest sorts only on the last term of the
> line. In this sample I have sorted by first reversing the order of
> words in the line and then sorting and again reversing the order of
> words. Pretty much as suggested just now by someone else.
>
> Thanks,
>
> Julian
>
>
>
>
>
> On Sun, Sep 30, 2012 at 8:17 PM, Bee <fo...@calcentral.com> wrote:
> > On Sep 30, 9:14 am, jbl <lethbri...@jblethbridge.com> wrote:
> >> The problem is this: I have a large file of poetry in
> >> alphabetical order sorted on the last term in each line,
>
> > This will sort the lines by the last term:
>
> > sort ir /\w\+$/
>
> > :help :sort
>
> > Bill
>
> > --
> > You received this message from the "vim_use" maillist.
> > Do not top-post! Type your reply below the text you are replying to.
> > For more information, visithttp://www.vim.org/maillist.php
>
> --
> J.B. Lethbridge
> (Gen. Ed. The Manchester Spenser)
> English Seminar
> Tuebingen University
> WIlhelmstrasse 50
> Tuebingen
> 72074 Germany

" -------1---------2---------3---------4---------5---------6----
" Found time to play with this sort.
"
" The following vim function will sort
" the selected lines of poetry and
" put the result in the "a register.
"
" It is most likely much slower than Tim's python script
" but is is completely vim script.
"
" Does it do what you want?

function! SortPoems() range
let aaa = []
let current = a:firstline
while current <= a:lastline
let aaa = aaa + [reverse(split(getline(current)))]
let current = current + 1
endwhile
let sss = sort(aaa,1) " 1=ignore case

let @a = ""
let current = 0
while current < a:lastline - a:firstline
let @a = @a . join(reverse(sss[current])) . "\n"
let current = current + 1
endwhile
let @a = @a . join(reverse(sss[current]))
endfun " usage :'<,'>call SortPoems()<cr>

finish

" -------1---------2---------3---------4---------5---------6----
Raw:

6.4.30.7 All these our ioyes and all our blisse abate
2.12.15.9 And after them did driue with all her power and might
3.9.14.4 And both full liefe his boasting to abate
6.6.27.9 And layd at him amaine with all his will and might
6.1.38.2 At once did heaue with all their powre and might
6.1.12.7 But through misfortune which did me abase
5.11.57.9 Did set vpon those troupes with all his powre and might
6.2.26.5 For deare affection and vnfayned zeale
3.2.13.6 For hardy thing it is to weene by might
4.9.6.9 He her vnwares attacht and captiue held by might
6.1.32.9 He spide come pricking on with al his powre and might
6.6.31.9 He stayd his second strooke and did his hand abase
3.8.51.6 Mote not mislike you also to abate
3.8.28.7 Ne ought your burning fury mote abate
1.7.35.1 No magicke arts hereof had any might
5.8.46.8 She at her ran with all her force and might
1.10.2.8 She cast to bring him where he chearen might
3.7.35.3 That at the last his fiercenesse gan abate
4.8.17.8 That her inburning wrath she gan abate
1.10.47.7 That hill they scale with all their powre and might
4.6.3.4 The armes he bore his speare he gan abase
5.9.39.4 To all assayes; his name was called Zele
2.9.7.4 To serue that Queene with all my powre and might
2.1.26.7 When suddenly that warriour gan abace
6.12.23.9 Where he him found despoyling all with maine and might
1.5.1.8 With greatest honour he atchieuen might
4.8.1.7 With sufferaunce soft which rigour can abate
5.5.30.1 With that she turn'd her head as halfe abashed

" -------1---------2---------3---------4---------5---------6----
Result:

2.1.26.7 When suddenly that warriour gan abace
4.6.3.4 The armes he bore his speare he gan abase
6.6.31.9 He stayd his second strooke and did his hand abase
6.1.12.7 But through misfortune which did me abase
5.5.30.1 With that she turn'd her head as halfe abashed
6.4.30.7 All these our ioyes and all our blisse abate
4.8.1.7 With sufferaunce soft which rigour can abate
3.7.35.3 That at the last his fiercenesse gan abate
4.8.17.8 That her inburning wrath she gan abate
3.8.28.7 Ne ought your burning fury mote abate
3.8.51.6 Mote not mislike you also to abate
3.9.14.4 And both full liefe his boasting to abate
5.8.46.8 She at her ran with all her force and might
6.12.23.9 Where he him found despoyling all with maine and might
2.12.15.9 And after them did driue with all her power and might
6.1.32.9 He spide come pricking on with al his powre and might
5.11.57.9 Did set vpon those troupes with all his powre and might
2.9.7.4 To serue that Queene with all my powre and might
6.1.38.2 At once did heaue with all their powre and might
1.10.47.7 That hill they scale with all their powre and might
6.6.27.9 And layd at him amaine with all his will and might
1.7.35.1 No magicke arts hereof had any might
1.5.1.8 With greatest honour he atchieuen might
4.9.6.9 He her vnwares attacht and captiue held by might
3.2.13.6 For hardy thing it is to weene by might
1.10.2.8 She cast to bring him where he chearen might
6.2.26.5 For deare affection and vnfayned zeale
5.9.39.4 To all assayes; his name was called Zele

" -------1---------2---------3---------4---------5---------6----

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

No comments:

Post a Comment