SearchSuggestions

What a library (and each item in it) is about, from a vocabulary of everyday words: the search model's shipped one (VocabularyFile, ~4,200 words) or, before that's downloaded, the small built-in Vocabulary. Every word is scored against every item once, in the background after indexing, and summed up in small files; refreshed as the library grows.

  • Suggestions: words whose ten best items stand far above the library's typical score for them (in standard deviations). Things a library really has stand out; things it doesn't (no dogs in it, say) don't.

  • Looks like (looksLike): an item's own best words.

Functions

Link copied to clipboard
fun load(context: Context, model: AiModel): List<Suggestion>

The best ones for this library, strongest first; empty until computed.

Link copied to clipboard
fun looksLike(context: Context, model: AiModel, mediaId: Long, max: Int = 3): List<String>

What an item looks like: each word's score for it minus the word's median over the library (words that match everything a little don't win), then its best words: the top one above the library's bar and any close behind, a word only once ("tennis" and "tennis match" share one, as do near-synonyms), at most max. Ranking within the item keeps what a library is full of nameable: tennis videos in a tennis-heavy library still get "tennis".

Link copied to clipboard
fun refreshIfStale(context: Context, model: AiModel)

Recomputes when missing, when the vocabulary changed, or when the index grew or shrank noticeably.