Skip to content

Avoid Auto-Rebuild of LSI Indexes #10

Description

@tra38

ClassifierReborn::Summarizer.perform_lsi uses a neat trick to avoid LSI's default behavior of "auto-rebuilding" the index after every time a person adds new content .

def perform_lsi(chunks, count, separator)
    lsi = ClassifierReborn::LSI.new auto_rebuild: false
    chunks.each { \|chunk\| lsi << chunk unless chunk.strip.empty? \|\| chunk.strip.split.size == 1 }
    lsi.build_index
    summaries = lsi.highest_relative_content count
    summaries.reject { \|chunk\| !summaries.include? chunk }.map(&:strip).join(separator)
end

This could be useful behavior to have.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions