org.hibernate.search.test.util.textbuilder
Class SentenceInventor

java.lang.Object
  extended by org.hibernate.search.test.util.textbuilder.SentenceInventor

public class SentenceInventor
extends Object

Test utility meant to produce sentences of a randomly generated language, having some properties of natural languages. The goal is to produce sentences which look like a western text, but are not. All sentences from the same SentenceInventor will share a limited dictionary, making the frequencies suitable to test with Lucene. Sentences produced depend from the constructor arguments, making the output predictable for testing purposes.

Author:
Sanne Grinovero

Constructor Summary
SentenceInventor(long randomSeed, int dictionarySize)
           
 
Method Summary
static void main(String[] args)
           
 String nextPeriod()
          Combines a random (gaussian) number of sentences in a period, using some punctuation symbols and capitalizing first char, terminating with dot and newline.
 String nextSentence()
          Builds a sentence concatenating terms from the generated dictionary and spaces
 char randomCharacter()
           
 String randomString()
          Produces a randomly generated String, using only western alphabet characters and selecting the length as a normal distribution of natural languages.
 String randomString(int length)
           
 String randomTerm()
          Produces a random String, which might be lowercase, completely uppercase, or uppercasing the first char (randomly selected)
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SentenceInventor

public SentenceInventor(long randomSeed,
                        int dictionarySize)
Parameters:
randomSeed - the seed to use for random generator
dictionarySize - the number of terms to insert in the dictionary used to build sentences
Method Detail

randomCharacter

public char randomCharacter()
Returns:
a random character from the ASCII table (text chars only)

randomString

public String randomString(int length)
Parameters:
length - the desired length
Returns:
a randomly generated String

randomString

public String randomString()
Produces a randomly generated String, using only western alphabet characters and selecting the length as a normal distribution of natural languages.

Returns:
the generated String

randomTerm

public String randomTerm()
Produces a random String, which might be lowercase, completely uppercase, or uppercasing the first char (randomly selected)

Returns:
produced String

nextSentence

public String nextSentence()
Builds a sentence concatenating terms from the generated dictionary and spaces

Returns:
a sentence

nextPeriod

public String nextPeriod()
Combines a random (gaussian) number of sentences in a period, using some punctuation symbols and capitalizing first char, terminating with dot and newline.

Returns:

main

public static void main(String[] args)


Copyright © 2006-2010 Hibernate. All Rights Reserved.