Skip to content

andlyu/random-text-gen

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

49 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

random-text-gen

PRODUCT:

Read DEMO.md

purpose:

I wanted a program that could generate random text. The main criteria is that it should be plausible.
This means that a "A pencil can fly" because "a pencil can fly across a room if somebody threw it"
Initially my goal was to start with sentences, and to build up to stories, but I was only able to generate coherent sentances.

Continuation

Merge
My attempt to implement NLP into this project

Database organization

Noun.txt

1 person 1,2,3,4,5 10.1,10.2,10.2.1
1.1 child P 10.2
1.1.1 boy P 10.2.1.2
1.1.2 girl P 10.2.1.2
1.1.3 student P 10.2.1.2
1.1.4 baby P 10.2.1.3

Verb.txt

1.2.1.1 sense 1,2-1,2,3,4/1.5,1.6-3
1.2.1.1.1 see 1.1.1,1.1.2,1.1.3,2-1,2,3,4/1.5,1.6-3
1.2.1.1.2 smell 1,2-1,2,4/1.5,1.6-3
1.2.1.1.3 hear 1,2-1,2/1.5,1.6-3
1.2.1.1.4 touch 1,2-1,2,4/1.5,1.6-3

Explanation

Noun.txt format

  • The number and period sequence is a words iD
  • The word
  • Adjective
    1. the Adjective that can be used with a noun. If it doesn't change from it's parent, then the "P" acts as a place holder
  • Groups
    1. all groups are start with 10, and they are ways to categorize instead of the order of the IDs

Verb.txt format

  • The number and period sequence is a words iD
  • The word
  • Properties
    1. (All nouns that can be the subjects(separated by commas)) "-" (all nouns that can be objects(separated by commas)
    2. if a verb is intransitive, a dash will not be present
    3. "/" all prepositions that can be used "-" all the nouns where the verb can take place (for the prepositional phrase)

Example

In the example above, if we start "see", for the subject we can choose any nouns that start with the iD 1.1.1, 1.1.2, 1,1,3 and 2.

Lets choose "student". <br/>

for the object, we can choose any nouns that start with the iD 1, 2, 3, and 4.

lets choose "child"<br>

We will have a preposition. It's iD will start with either 1.5 or 1.6.

Lets choose "near"

For the place, the Noun's iD must start with a 3.

Lets choose "3.2.1.3 field"

The sentence will end up being:

The student sees a child near a field.

SympleNLG does all of the adjustment with placing periods, capitalization, and changing "see" to "sees"
Thanks SympleNLG

Conclusion

The clauses turn out being all right, however when connecting multiple clauses, they become too illogical. It could be solved by adding more parameters to the vocab files, but I thought that using NLP to create the text files would be much more efficient.

Disclaimer

Sorry that much of the code uses bad practices. Much of it was writen before I knew what to do and what not to do.

Citations

I used SympleNLG for creating the sentences out of the words that I fed to it.

About

generate random text

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published