Shraddha Deshmukh
Shraddha Deshmukh

Reputation: 41

Meaningful sentence generation from words which are classified as per parts of speech

I am working on Natural Language Generation project. I've created bag of words from paragraph,like nouns,verbs,adjectives.etc and I am trying to generate sentence of pattern Subject+verb+object.
Example:

Subject and verbs must have a relation which will create a meaningful sentence.Is there any way to establish relation between nouns and probable verbs to generate subject+verb pattern?

Also If we have verbs then to find probable objects using input corpus to generate new meaningful sentences?
Example:

Upvotes: 1

Views: 2112

Answers (2)

Daniel
Daniel

Reputation: 6039

See the set of works under the name of "narrative schemas" by Nate Chambers. He does what you want.

This might be relevant as well.

Upvotes: 1

Omid
Omid

Reputation: 2667

Let's think about it this way. There are certain acts like barking and singing that could only be done by animate beings, thus a bike, an inanimate object, cannot sing. Also, barking is done by an animal, i.e, a human cannot be the one who does the act of barking. So let's define certain features for each one of our constituents. For instance:

eli = {'CAT': 'N', 'ORTH': 'Elizabeth', 'FEAT':'human'}
dog = {'CAT': 'N', 'ORTH': 'dog', 'FEAT':'animal'}
eiffel = {'CAT': 'N', 'ORTH': 'Eiffel Tower', 'FEAT':'inanimate'}
bike = {'CAT': 'N', 'ORTH': 'Bike', 'FEAT':'inanimate'}

nouns = [eli, dog, eiffel, bike]

sings = {'CAT': 'V', 'ORTH': 'sings', 'FEAT':'human'}
barks = {'CAT': 'V', 'ORTH': 'barks', 'FEAT':'animal'}
shines = {'CAT': 'V', 'ORTH': 'shines', 'FEAT':'inanimate'}

verbs = [sings, barks, shines]

# Our sentence pattern is: noun + verb + noun

for n in nouns:
    for v in verbs:
        if n['FEAT'] == v['FEAT']:
            print('{} {}'.format(n['ORTH'], v['ORTH']))

When you run this you get:

>>> 
Elizabeth sings
dog barks
Eiffel Tower shines
Bike shines
>>>

Same goes for pairing verbs with suitable objects. You simply have to assign proper features to your pairs.

Upvotes: 2

Related Questions