Re: [Tutor] swapping list elements based on some criterion

2011-10-11 Thread Emad Mohamed
On Tue, Oct 11, 2011 at 1:21 AM, Steven D'Aprano wrote: > Wayne Werner wrote: > >> 2011/10/7 Emad Nawfal (عمـ نوفل ـاد) >> >> I want to re-structure English so that the adjectives appear after the >>> nouns, instead of before. >>> If I have a sentence like: >>> >>> The tall man plays well >>> I

Re: [Tutor] swapping list elements based on some criterion

2011-10-10 Thread Steven D'Aprano
Wayne Werner wrote: 2011/10/7 Emad Nawfal (عمـ نوفل ـاد) I want to re-structure English so that the adjectives appear after the nouns, instead of before. If I have a sentence like: The tall man plays well I need to change it to The man tall plays well Others have offered plenty of help, th

Re: [Tutor] swapping list elements based on some criterion

2011-10-10 Thread Wayne Werner
2011/10/7 Emad Nawfal (عمـ نوفل ـاد) > I want to re-structure English so that the adjectives appear after the > nouns, instead of before. > If I have a sentence like: > > The tall man plays well > I need to change it to > The man tall plays well > Others have offered plenty of help, though I not

Re: [Tutor] swapping list elements based on some criterion

2011-10-08 Thread عمـ نوفل ـاد
On Sat, Oct 8, 2011 at 12:34 PM, Andreas Perstinger < andreas.perstin...@gmx.net> wrote: > On 2011-10-08 11:11, Andreas Perstinger wrote: > >> def swap(sentence): >> s = sentence.split() >> for i in reversed(range(len(s))): >> if s[i].endswith("/N") and s[i-1].endswith("/ADJ"):

Re: [Tutor] swapping list elements based on some criterion

2011-10-08 Thread Andreas Perstinger
On 2011-10-08 11:11, Andreas Perstinger wrote: def swap(sentence): s = sentence.split() for i in reversed(range(len(s))): if s[i].endswith("/N") and s[i-1].endswith("/ADJ"): s[i], s[i-1] = s[i-1], s[i] return s Oops, noticed a little bug: The for-loop sh

Re: [Tutor] swapping list elements based on some criterion

2011-10-08 Thread عمـ نوفل ـاد
On Sat, Oct 8, 2011 at 12:11 PM, Andreas Perstinger < andreas.perstin...@gmx.net> wrote: > On 2011-10-08 09:53, Peter Otten wrote: > >> Emad Nawfal (عمـ نوفل ـاد) wrote: >> >>> Here is the function as I used it, and it works fine: >>> >>> def swap(sentence): >>>buffer = [] >>>adjectives

Re: [Tutor] swapping list elements based on some criterion

2011-10-08 Thread Andreas Perstinger
On 2011-10-08 09:53, Peter Otten wrote: Emad Nawfal (عمـ نوفل ـاد) wrote: Here is the function as I used it, and it works fine: def swap(sentence): buffer = [] adjectives = [] for word in sentence.split(): if word.endswith('/ADJ'): adjectives.append(word)

Re: [Tutor] swapping list elements based on some criterion

2011-10-08 Thread Peter Otten
Emad Nawfal (عمـ نوفل ـاد) wrote: > Here is the function as I used it, and it works fine: > > def swap(sentence): >buffer = [] >adjectives = [] >for word in sentence.split(): >if word.endswith('/ADJ'): >adjectives.append(word) >elif word.endswith('/N'): >

Re: [Tutor] swapping list elements based on some criterion

2011-10-07 Thread عمـ نوفل ـاد
2011/10/8 Emad Nawfal (عمـ نوفل ـاد) > Hi Steven ans Tutors, > Thanks for the code. > Actually I'm not a student at all. I'm an assistant professor of Arabic at > Suez Canal University in Egypt. I would appreciate more contributions from > you and the other list members. > > > 2011/10/8 Steven D'

Re: [Tutor] swapping list elements based on some criterion

2011-10-07 Thread عمـ نوفل ـاد
Hi Steven ans Tutors, Thanks for the code. Actually I'm not a student at all. I'm an assistant professor of Arabic at Suez Canal University in Egypt. I would appreciate more contributions from you and the other list members. 2011/10/8 Steven D'Aprano > Emad Nawfal (عمـ نوفل ـاد) wrote: > >> Hell

Re: [Tutor] swapping list elements based on some criterion

2011-10-07 Thread Steven D'Aprano
Emad Nawfal (عمـ نوفل ـاد) wrote: Hello Tutors, It's been quite some time since I last posted something here, and now I'm back with a question: I want to re-structure English so that the adjectives appear after the nouns, instead of before. If I have a sentence like: The tall man plays well I n

[Tutor] swapping list elements based on some criterion

2011-10-07 Thread عمـ نوفل ـاد
Hello Tutors, It's been quite some time since I last posted something here, and now I'm back with a question: I want to re-structure English so that the adjectives appear after the nouns, instead of before. If I have a sentence like: The tall man plays well I need to change it to The man tall pla