Each component has its own text file. I merge everything together with simple dependency resolution so I can figure out implementation order easier. Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
38 lines
1.2 KiB
Plaintext
38 lines
1.2 KiB
Plaintext
== Files ==
|
|
ocarina/include/
|
|
filter.h
|
|
ocarina/lib/
|
|
filter.cpp
|
|
|
|
== Depends ==
|
|
index
|
|
|
|
Filter: (lib/filter.cpp)
|
|
Filtering is used to generate a subset of songs for easier searching.
|
|
|
|
- Index:
|
|
map<string, string> lowercase_cache;
|
|
map<string, set<string>> substring_cache;
|
|
Index filter_index("");
|
|
|
|
- Parsing:
|
|
1) Convert the provided string into a list of words, using whitespace
|
|
and the following characters as delimiters: \/,;()_~+"
|
|
|
|
For each word:
|
|
2) Check the lowercase_cache to see if we have seen the word before,
|
|
a) If we have, return the stored string
|
|
b) Convert the string to lowercase and strip out remaining
|
|
special characters. Add the result to the lowercase_cache;
|
|
3) Check the substring_cache to see if we have seen the word before,
|
|
a) If we have, use the substring set returned
|
|
b) Break the word into substrings from the front only. For
|
|
example: "dalek" would contain the substrings
|
|
{d, da, dal, dale, dalek}. Add to the substring cache.
|
|
|
|
- API:
|
|
filter :: add(string, track_id);
|
|
Parses the string and adds the track_id to the index.
|
|
void filter :: search(string, set<track_id> &);
|
|
Parse the string and fill in the set with matching tracks.
|