hi there!

is it possible to writte a python program that transfer a sentence in the form of SVO (Subject Verb Object) into the form of SOV (Subject Object Verb)?
Example:
input: John eat bread
output:John bread eat

the sentence may be a complex sentence.

Recommended Answers

All 3 Replies

I'd suggest to compose, firstly, 2 lists of words - one for verbs, another for objects.
Then to try find each word from the sentence in these lists... then swap 2 words etc.
I think it's pretty clear what I mean.

thanks Xantipius, but what i want is a program that reorder words within tagged sentence by using the tag.

def sentence():
    svo= raw_input("Pleaser Enter your SVO: ")
    splitline = svo.split(' ')
    words = splitline[0]+" "+ splitline[2]+" "+ splitline[1]
    return words

result= sentence()
print result



>>> ================================ RESTART ================================
>>> 
Pleaser Enter your SVO: John eat bread
John bread eat
>>> 
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.