Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate matching strings randomly instead of exhaustively #14

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

davisjam
Copy link

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
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