Skip to content

Generate matching strings randomly instead of exhaustively#14

Open
davisjam wants to merge 3 commits intocs-au-dk:masterfrom
davisjam:RandomStringGenerator
Open

Generate matching strings randomly instead of exhaustively#14
davisjam wants to merge 3 commits intocs-au-dk:masterfrom
davisjam:RandomStringGenerator

Conversation

@davisjam
Copy link
Copy Markdown

This is not a serious pull request, but the idea might be of interest and other people might want this feature.

Generating strings exhaustively may take a long time if all one desires is a random set of matching strings.

This patch:

  • introduces a getRandomStrings method that selects transitions and transition characters randomly to reduce the set of generated strings.
  • uses GSON for machine-parseable output
  • modifies pom.xml so that mvn package produces a jar that can be executed to generate random strings up to the requested length.

For example, to generate 10 strings for the regex /abc[0-9]+/ with 0 probability of "excessive" exploration:

(11:02:04) jamie@woody /tmp/dk.brics.automaton $ java -jar target/brics-string-generator-1.0.jar 'abc[0-9]+' 10 0 2>&1 | grep 'RAND STR'
RAND STR: "abc68715"
RAND STR: "abc2971316"
RAND STR: "abc53"
RAND STR: "abc7732"
RAND STR: "abc3"
RAND STR: "abc679"
RAND STR: "abc503916"

@davisjam davisjam changed the title generate matching strings randomly instead of exhaustively Generate matching strings randomly instead of exhaustively Jan 17, 2019
@amoeller
Copy link
Copy Markdown
Member

Thanks for the suggestion. Just a quick comment: Random strings could be generated with many different probability distributions, and it is not clear why this one is particularly useful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants