You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mahout.apache.org by sr...@apache.org on 2010/09/05 12:00:33 UTC
svn commit: r992751 -
/mahout/trunk/utils/src/test/java/org/apache/mahout/utils/vectors/text/DictionaryVectorizerTest.java
Author: srowen
Date: Sun Sep 5 10:00:33 2010
New Revision: 992751
URL: http://svn.apache.org/viewvc?rev=992751&view=rev
Log:
Fixed one instance where tests may not be able to fix a RNG seed.
Modified:
mahout/trunk/utils/src/test/java/org/apache/mahout/utils/vectors/text/DictionaryVectorizerTest.java
Modified: mahout/trunk/utils/src/test/java/org/apache/mahout/utils/vectors/text/DictionaryVectorizerTest.java
URL: http://svn.apache.org/viewvc/mahout/trunk/utils/src/test/java/org/apache/mahout/utils/vectors/text/DictionaryVectorizerTest.java?rev=992751&r1=992750&r2=992751&view=diff
==============================================================================
--- mahout/trunk/utils/src/test/java/org/apache/mahout/utils/vectors/text/DictionaryVectorizerTest.java (original)
+++ mahout/trunk/utils/src/test/java/org/apache/mahout/utils/vectors/text/DictionaryVectorizerTest.java Sun Sep 5 10:00:33 2010
@@ -44,16 +44,16 @@ public final class DictionaryVectorizerT
private static final String CHARSET = "abcdef";
private static final String DELIM = " .,?;:!\t\n\r";
private static final String ERRORSET = "`1234567890" + "-=~@#$%^&*()_+[]{}'\"/<>|\\";
- private static final Random random = RandomUtils.getRandom();
+ private final Random random = RandomUtils.getRandom();
private FileSystem fs;
- private static char getRandomDelimiter() {
- return DELIM.charAt(random.nextInt(DictionaryVectorizerTest.DELIM.length()));
+ private char getRandomDelimiter() {
+ return DELIM.charAt(random.nextInt(DELIM.length()));
}
- private static String getRandomDocument() {
- int length = (AVG_DOCUMENT_LENGTH >> 1) + DictionaryVectorizerTest.random.nextInt(AVG_DOCUMENT_LENGTH);
+ private String getRandomDocument() {
+ int length = (AVG_DOCUMENT_LENGTH >> 1) + random.nextInt(AVG_DOCUMENT_LENGTH);
StringBuilder sb = new StringBuilder(length * AVG_SENTENCE_LENGTH * AVG_WORD_LENGTH);
for (int i = 0; i < length; i++) {
sb.append(getRandomSentence());
@@ -61,8 +61,8 @@ public final class DictionaryVectorizerT
return sb.toString();
}
- private static String getRandomSentence() {
- int length = (AVG_SENTENCE_LENGTH >> 1) + DictionaryVectorizerTest.random.nextInt(AVG_SENTENCE_LENGTH);
+ private String getRandomSentence() {
+ int length = (AVG_SENTENCE_LENGTH >> 1) + random.nextInt(AVG_SENTENCE_LENGTH);
StringBuilder sb = new StringBuilder(length * AVG_WORD_LENGTH);
for (int i = 0; i < length; i++) {
sb.append(getRandomString()).append(' ');
@@ -71,16 +71,14 @@ public final class DictionaryVectorizerT
return sb.toString();
}
- private static String getRandomString() {
- int length = (AVG_WORD_LENGTH >> 1) + DictionaryVectorizerTest.random.nextInt(AVG_WORD_LENGTH);
+ private String getRandomString() {
+ int length = (AVG_WORD_LENGTH >> 1) + random.nextInt(AVG_WORD_LENGTH);
StringBuilder sb = new StringBuilder(length);
for (int i = 0; i < length; i++) {
- sb.append(DictionaryVectorizerTest.CHARSET.charAt(
- DictionaryVectorizerTest.random.nextInt(DictionaryVectorizerTest.CHARSET.length())));
+ sb.append(CHARSET.charAt(random.nextInt(CHARSET.length())));
}
- if (DictionaryVectorizerTest.random.nextInt(10) == 0) {
- sb.append(DictionaryVectorizerTest.ERRORSET.charAt(
- DictionaryVectorizerTest.random.nextInt(DictionaryVectorizerTest.ERRORSET.length())));
+ if (random.nextInt(10) == 0) {
+ sb.append(ERRORSET.charAt(random.nextInt(ERRORSET.length())));
}
return sb.toString();
}