Comments (4)
There is no such method currently, but it can be done. Off the top of my head, I can think of two ways of implementing this:
-
Start at the root node and walk down the graph, choosing a child randomly. Unfortunately, this won't give you a uniform distribution. Longer words will appear less frequently.
-
To get a more uniform distribution across all DAWG items, you could point randomly into the children array and then find the path from the root to this particular child.
As this is just my hobby project, I can't plan when I get around to implementing this.
from dawgsharp.
@bzaar i liked the children array approach, i can already see this array populated in debug view, so can you please give me a rough idea how can find the path if i choose a random child for example
{
charIndex: 18
index: 112350
}
from dawgsharp.
I've committed a first (suboptimal) version of GetRandomItem
. The word distribution may not be fully uniform but it shouldn't be too bad. Please see if this fits your requirements.
from dawgsharp.
Thanks @bzaar
Having something is better than having nothing.
from dawgsharp.
Related Issues (20)
- Improve lookup speed
- Support .NET Standard HOT 1
- Possible error with your sample code HOT 3
- Make file even smaller by deduplicating payloads
- Поддерживается ли поиск с возможными заменами е<>ё? HOT 2
- Unexpected behaviour of DawgBuilder.TryGetValue() HOT 1
- How do i use it or anagram solving HOT 4
- Error when loading bin file HOT 8
- Dawg.MatchSuffix feature? HOT 5
- Dawg.MatchSuffix with max Count HOT 4
- EndOfStreamException: Unable to read beyond the end of the stream. HOT 4
- Dawg could use less memory HOT 2
- Optimise FuseEnds()
- Optimize the compaction algorithm for speed HOT 1
- Implement IDictionary <string, TValue> on Dawg and DawgBuilder HOT 1
- Add an XML comments file to the package HOT 1
- Consider MIT or LGPL please? HOT 2
- Use shorts instead of ints if the number of nodes is < 32K
- OutOfMemoryException HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dawgsharp.