Python Forum
Generating all simple sentence possibilities
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Generating all simple sentence possibilities
#1
Hello all,

I am using Python 3.7.0 on Windows 7. I am trying to make a program that can generate all possible simple sentences. Here is the problem.

"Aaa aaa aaa." - is a message received and only lets you know about the capitalization and grammar of the sentence. Make a program that generates all possibilities in English.
The answer to the problem is: "The dog ran."

Any thoughts or pointers on how to start this problem or where to look would be great! The only go to reference source I have found is: Natural Language Processing in Python.


-Thanks!
Reply
#2
You are going to need a word list. You are going to need to load that word list and store the words by length. Then you will need to combine them with product from the itertools library.

That will give you all the sentences, but a lot of them will not be grammatical (like 'ran dog the'). For weeding out the bad sentences, you are going to need serious natural language processing.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply
#3
the natural language processing tool NLTK: http://www.nltk.org/ comes with a huge set of copora. It's quite easy to use, and is worth spending an hour or so looking at to see if it will fulfill your needs.
Reply
#4
-Thanks for the replies everyone!
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  List all possibilities of a nested-list by flattened lists sparkt 1 878 Feb-23-2023, 02:21 PM
Last Post: sparkt
  while sentence kimyyya 3 2,905 Mar-20-2021, 06:00 AM
Last Post: Pedroski55
  List / arrays putting in sentence Kurta 3 2,514 Dec-25-2020, 11:29 AM
Last Post: Larz60+
  How to make a telegram bot respond to the specific word in a sentence? Metodolog 2 6,271 Dec-22-2020, 07:30 AM
Last Post: martabassof
  How to match partial sentence in long sentence Mekala 1 1,486 Jul-22-2020, 02:21 PM
Last Post: perfringo
  Remove a sentence if it contains a word. lokhtar 6 5,771 Feb-11-2020, 04:43 PM
Last Post: stullis
  Regex Help for clubbing similar sentence segments regstuff 3 2,113 Nov-20-2019, 06:46 AM
Last Post: perfringo
  how to get all the possible permutation and combination of a sentence in python sodmzs 1 4,121 Jun-13-2019, 07:02 AM
Last Post: perfringo
  Sentence maker help bidoofis 2 2,450 Feb-08-2019, 03:59 AM
Last Post: bidoofis
  wont print last sentence.. mitmit293 2 2,323 Jan-27-2019, 05:38 PM
Last Post: aakashjha001

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020