Home | History | Annotate | Download | only in root

Lines Matching refs:seed

21  *      seed = wrongly spelled word
27 auto speller(alias dg)(const(char)[] seed)
30 const size_t maxdist = seed.length < 4 ? seed.length / 2 : 2;
33 if (auto p = spellerX!dg(seed, distance != 0))
54 * seed = starting string
59 auto spellerX(alias dg)(const(char)[] seed, bool flag)
61 if (!seed.length)
67 auto sb = SmallBuffer!char(seed.length + 1, tmp[]);
74 buf[0 .. seed.length - 1] = seed[1 .. $];
75 foreach (i; 0 .. seed.length)
79 auto np = flag ? spellerY!dg(buf[0 .. seed.length - 1], i, ncost)
80 : dg(buf[0 .. seed.length - 1], ncost);
83 buf[i] = seed[i];
89 buf[0 .. seed.length] = seed;
90 for (size_t i = 0; i + 1 < seed.length; i++)
93 buf[i] = seed[i + 1];
94 buf[i + 1] = seed[i];
97 auto np = dg(buf[0 .. seed.length], ncost);
100 buf[i] = seed[i];
105 buf[0 .. seed.length] = seed;
106 foreach (i; 0 .. seed.length)
113 auto np = flag ? spellerY!dg(buf[0 .. seed.length], i + 1, ncost)
114 : dg(buf[0 .. seed.length], ncost);
118 buf[i] = seed[i];
122 buf[1 .. seed.length + 1] = seed;
123 foreach (i; 0 .. seed.length + 1) // yes, do seed.length+1 iterations
130 auto np = flag ? spellerY!dg(buf[0 .. seed.length + 1], i + 1, ncost)
131 : dg(buf[0 .. seed.length + 1], ncost);
135 if (i < seed.length)
136 buf[i] = seed[i];
146 * seed = starting string
147 * index = index into seed[] that is where we will mutate it
152 auto spellerY(alias dg)(const(char)[] seed, size_t index, out int cost)
154 if (!seed.length)
161 auto sb = SmallBuffer!char(seed.length + 1, tmp[]);
163 buf[0 .. index] = seed[0 .. index];
168 /* Delete character at seed[index] */
169 if (index < seed.length)
171 buf[index .. seed.length - 1] = seed[index + 1 .. $]; // seed[] with deleted character
173 auto np = dg(buf[0 .. seed.length - 1], ncost); // look it up
178 /* Substitute character at seed[index] */
179 if (index < seed.length)
181 buf[0 .. seed.length] = seed;
184 buf[index] = s; // seed[] with substituted character
187 auto np = dg(buf[0 .. seed.length], ncost);
193 /* Insert character at seed[index] */
194 buf[index + 1 .. seed.length + 1] = seed[index .. $];
200 auto np = dg(buf[0 .. seed.length + 1], ncost);