Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added build/classes/random/text/generator/Gui$1.class
Binary file not shown.
Binary file added build/classes/random/text/generator/Gui.class
Binary file not shown.
Binary file modified build/classes/random/text/generator/RandomTextGenerator.class
Binary file not shown.
Binary file not shown.
Binary file not shown.
2 changes: 1 addition & 1 deletion nbproject/private/private.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
compile.on.save=true
user.properties.file=C:\\Users\\Ma Jing\\AppData\\Roaming\\NetBeans\\8.1\\build.properties
user.properties.file=C:\\Users\\Work\\AppData\\Roaming\\NetBeans\\8.0.2\\build.properties
6 changes: 5 additions & 1 deletion nbproject/private/private.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@
<editor-bookmarks xmlns="http://www.netbeans.org/ns/editor-bookmarks/2" lastBookmarkId="0"/>
<open-files xmlns="http://www.netbeans.org/ns/projectui-open-files/2">
<group>
<file>file:/C:/Users/Ma%20Jing/Documents/NetBeansProjects/Random%20Text%20Generator/src/random/text/generator/SpaceEfficientGenerator.java</file>
<file>file:/D:/OSS/Hacktoberfest/Random-Text-Generator/src/random/text/generator/SpaceEfficientGenerator.java</file>
<file>file:/D:/OSS/Hacktoberfest/Random-Text-Generator/src/random/text/generator/SpeedEfficientGenerator.java</file>
<file>file:/D:/OSS/Hacktoberfest/Random-Text-Generator/src/random/text/generator/RandomTextGenerator.java</file>
<file>file:/D:/OSS/Hacktoberfest/Random-Text-Generator/src/random/text/generator/WordSet.java</file>
<file>file:/D:/OSS/Hacktoberfest/Random-Text-Generator/src/random/text/generator/Gui.java</file>
</group>
</open-files>
</project-private>
13 changes: 9 additions & 4 deletions src/random/text/generator/Gui.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,15 @@ public void init() {
label.setAlignmentX(Component.CENTER_ALIGNMENT);
panel.add(label);

JTextArea textField = new JTextArea(5, 5);
textField.setText("Not randomly generated text.");
textField.setAlignmentX(Component.CENTER_ALIGNMENT);
panel.add(textField);
JTextArea inputTextArea = new JTextArea(5, 5);
inputTextArea.setText(RandomTextGenerator.getDefaultText());
inputTextArea.setAlignmentX(Component.CENTER_ALIGNMENT);
panel.add(inputTextArea);

JTextArea outputTextArea = new JTextArea(5, 5);
outputTextArea.setText("Not randomly generated text.");
outputTextArea.setAlignmentX(Component.CENTER_ALIGNMENT);
panel.add(outputTextArea);

JButton generateTextButton = new JButton("Generate text");
generateTextButton.setAlignmentX(Component.CENTER_ALIGNMENT);
Expand Down
20 changes: 19 additions & 1 deletion src/random/text/generator/RandomTextGenerator.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,32 @@
* to form a new text. This technique is called the Markov chain.
*/
public abstract class RandomTextGenerator {

protected static final String defaultText = "She is into superstitions, black cats and voodoo dolls. "
+ "I feel a premonition that girl is gonna make me fall. "
+ "She is into new sensations, new kicks in the candle light. "
+ "She has got a new addiction for every day and night. "
+ "She will make you take your clothes off and go dancing in the rain. "
+ "She will make you live her crazy life but she will take away your pain like a bullet to your brain. "
+ "Come On! Upside, inside out she is livin la vida loca. "
+ "She will push and pull you down, livin la vida loca. "
+ "Her lips are devil red and her skin is the color mocha. "
+ "She will wear you out livin la vida loca. Come On! Livin la vida loca, Come on! "
+ "She is livin la vida loca. Woke up in New York City in a funky cheap hotel. "
+ "She took my heart and she took my money. She must have slipped me a sleeping pill. "
+ "She never drinks the water and makes you order French Champagne. "
+ "Once you have had a taste of her you will never be the same. "
+ "Yeah, she will make you go insane.";
public final String[] text;
public final int SETSIZE = 3;

public RandomTextGenerator(String text) {
this.text = text.split("\\s+");
}

public static String getDefaultText(){
return defaultText;
}

public String generateText(int wordAmount) {
if (wordAmount <= SETSIZE) return null;

Expand Down
15 changes: 0 additions & 15 deletions src/random/text/generator/SpaceEfficientGenerator.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,21 +34,6 @@ public ArrayList<String> getFollowingWords(WordSet set) {
* @param args the command line arguments
*/
public static void main(String[] args) {
final String defaultText = "She is into superstitions, black cats and voodoo dolls. "
+ "I feel a premonition that girl is gonna make me fall. "
+ "She is into new sensations, new kicks in the candle light. "
+ "She has got a new addiction for every day and night. "
+ "She will make you take your clothes off and go dancing in the rain. "
+ "She will make you live her crazy life but she will take away your pain like a bullet to your brain. "
+ "Come On! Upside, inside out she is livin la vida loca. "
+ "She will push and pull you down, livin la vida loca. "
+ "Her lips are devil red and her skin is the color mocha. "
+ "She will wear you out livin la vida loca. Come On! Livin la vida loca, Come on! "
+ "She is livin la vida loca. Woke up in New York City in a funky cheap hotel. "
+ "She took my heart and she took my money. She must have slipped me a sleeping pill. "
+ "She never drinks the water and makes you order French Champagne. "
+ "Once you have had a taste of her you will never be the same. "
+ "Yeah, she will make you go insane.";
SpaceEfficientGenerator gen = new SpaceEfficientGenerator(defaultText);
System.out.println(gen.generateText(100));
}
Expand Down
15 changes: 0 additions & 15 deletions src/random/text/generator/SpeedEfficientGenerator.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,21 +52,6 @@ public ArrayList<String> getFollowingWords(WordSet set) {
* @param args the command line arguments
*/
public static void main(String[] args) {
final String defaultText = "She is into superstitions, black cats and voodoo dolls. "
+ "I feel a premonition that girl is gonna make me fall. "
+ "She is into new sensations, new kicks in the candle light. "
+ "She has got a new addiction for every day and night. "
+ "She will make you take your clothes off and go dancing in the rain. "
+ "She will make you live her crazy life but she will take away your pain like a bullet to your brain. "
+ "Come On! Upside, inside out she is livin la vida loca. "
+ "She will push and pull you down, livin la vida loca. "
+ "Her lips are devil red and her skin is the color mocha. "
+ "She will wear you out livin la vida loca. Come On! Livin la vida loca, Come on! "
+ "She is livin la vida loca. Woke up in New York City in a funky cheap hotel. "
+ "She took my heart and she took my money. She must have slipped me a sleeping pill. "
+ "She never drinks the water and makes you order French Champagne. "
+ "Once you have had a taste of her you will never be the same. "
+ "Yeah, she will make you go insane.";
SpeedEfficientGenerator gen = new SpeedEfficientGenerator(defaultText);
// Uncomment the line below to print all the WordSets and their following words
// gen.printWordMap();
Expand Down