public TextPoolGenerator(int size, Distributions distributions, TextGenerationProgressMonitor monitor) { this.size = size; checkNotNull(distributions, "distributions is null"); this.monitor = checkNotNull(monitor, "monitor is null"); this.grammars = new ParsedDistribution(distributions.getGrammars()); this.nounPhrases = new ParsedDistribution(distributions.getNounPhrase()); this.verbPhrases = new ParsedDistribution(distributions.getVerbPhrase()); prepositions = new IndexedDistribution(distributions.getPrepositions()); terminators = new IndexedDistribution(distributions.getTerminators()); adverbs = new IndexedDistribution(distributions.getAdverbs()); verbs = new IndexedDistribution(distributions.getVerbs()); auxiliaries = new IndexedDistribution(distributions.getAuxiliaries()); articles = new IndexedDistribution(distributions.getArticles()); adjectives = new IndexedDistribution(distributions.getAdjectives()); nouns = new IndexedDistribution(distributions.getNouns()); }
public static synchronized TextPool getDefaultTestPool() { if (DEFAULT_TEXT_POOL == null) { DEFAULT_TEXT_POOL = new TextPool(DEFAULT_TEXT_POOL_SIZE, Distributions.getDefaultDistributions()); } return DEFAULT_TEXT_POOL; }
public Distributions(Map<String, Distribution> distributions) { this.grammars = getDistribution(distributions, "grammar"); this.nounPhrase = getDistribution(distributions, "np"); this.verbPhrase = getDistribution(distributions, "vp"); this.prepositions = getDistribution(distributions, "prepositions"); this.nouns = getDistribution(distributions, "nouns"); this.verbs = getDistribution(distributions, "verbs"); this.articles = getDistribution(distributions, "articles"); this.adjectives = getDistribution(distributions, "adjectives"); this.adverbs = getDistribution(distributions, "adverbs"); this.auxiliaries = getDistribution(distributions, "auxillaries"); this.terminators = getDistribution(distributions, "terminators"); this.orderPriorities = getDistribution(distributions, "o_oprio"); this.shipInstructions = getDistribution(distributions, "instruct"); this.shipModes = getDistribution(distributions, "smode"); this.returnFlags = getDistribution(distributions, "rflag"); this.partContainers = getDistribution(distributions, "p_cntr"); this.partColors = getDistribution(distributions, "colors"); this.partTypes = getDistribution(distributions, "p_types"); this.marketSegments = getDistribution(distributions, "msegmnt"); this.nations = getDistribution(distributions, "nations"); this.regions = getDistribution(distributions, "regions"); }
private static void generateNounPhrase(Distributions distributions, ByteArrayBuilder builder, RandomInt random) { String syntax = distributions.getNounPhrase().randomValue(random); int maxLength = syntax.length(); for (int i = 0; i < maxLength; i++) { switch (syntax.charAt(i)) { case 'A': source = distributions.getArticles(); break; case 'J': source = distributions.getAdjectives(); break; case 'D': source = distributions.getAdverbs(); break; case 'N': source = distributions.getNouns(); break; case ',':
private static void generateVerbPhrase(Distributions distributions, ByteArrayBuilder builder, RandomInt random) { String syntax = distributions.getVerbPhrase().randomValue(random); int maxLength = syntax.length(); for (int i = 0; i < maxLength; i += 2) { Distribution source; switch (syntax.charAt(i)) { case 'D': source = distributions.getAdverbs(); break; case 'V': source = distributions.getVerbs(); break; case 'X': source = distributions.getAuxiliaries(); break; default: throw new IllegalArgumentException("Unknown token '" + syntax.charAt(i) + "'"); } // pick a random word String word = source.randomValue(random); builder.append(word); // add a space builder.append(" "); } }
private static void generateSentence(Distributions distributions, ByteArrayBuilder builder, RandomInt random) { String syntax = distributions.getGrammars().randomValue(random); break; case 'P': String preposition = distributions.getPrepositions().randomValue(random); builder.append(preposition); builder.append(" the "); String terminator = distributions.getTerminators().randomValue(random); builder.append(terminator); break;
public NationGenerator(BufferAllocator allocator, GenerationDefinition def, String...includedColumns) { super(TpchTable.NATION, allocator, def, 1, includedColumns); this.nations = Distributions.getDefaultDistributions().getNations(); this.nationKey = int8("n_nationKey"); this.name = varChar("n_name"); this.regionKey = int8("n_regionKey"); this.comment = varChar("n_comment"); finalizeSetup(); }
public RegionGenerator(BufferAllocator allocator, GenerationDefinition def, String...includedColumns) { super(TpchTable.REGION, allocator, def, 1, includedColumns); this.regions = Distributions.getDefaultDistributions().getRegions(); this.commentRandom = randomText(1500869201, TextPool.getDefaultTestPool(), COMMENT_AVERAGE_LENGTH); this.regionKey = int8("r_regionKey"); this.name = varChar("r_name"); this.comment = varChar("r_comment"); finalizeSetup(); }
public static synchronized Distributions getDefaultDistributions() { if (DEFAULT_DISTRIBUTIONS == null) { try { URL resource = Resources.getResource("dists.dss"); checkState(resource != null, "Distribution file 'dists.dss' not found"); DEFAULT_DISTRIBUTIONS = new Distributions(loadDistribution(Resources.asCharSource(resource, Charsets.UTF_8))); } catch (IOException e) { throw Throwables.propagate(e); } } return DEFAULT_DISTRIBUTIONS; }