Refactor Post#related_posts to build the index in a different method
This commit is contained in:
parent
ffa93c22f1
commit
09c1c01d07
|
@ -229,16 +229,7 @@ module Jekyll
|
|||
return [] unless posts.size > 1
|
||||
|
||||
if self.site.lsi
|
||||
self.class.lsi ||= begin
|
||||
puts "Starting the classifier..."
|
||||
lsi = Classifier::LSI.new(:auto_rebuild => false)
|
||||
$stdout.print(" Populating LSI... ");$stdout.flush
|
||||
posts.each { |x| $stdout.print(".");$stdout.flush;lsi.add_item(x) }
|
||||
$stdout.print("\n Rebuilding LSI index... ")
|
||||
lsi.build_index
|
||||
puts ""
|
||||
lsi
|
||||
end
|
||||
build_index
|
||||
|
||||
related = self.class.lsi.find_related(self.content, 11)
|
||||
related - [self]
|
||||
|
@ -247,6 +238,19 @@ module Jekyll
|
|||
end
|
||||
end
|
||||
|
||||
def build_index
|
||||
self.class.lsi ||= begin
|
||||
puts "Starting the classifier..."
|
||||
lsi = Classifier::LSI.new(:auto_rebuild => false)
|
||||
$stdout.print(" Populating LSI... "); $stdout.flush
|
||||
posts.each { |x| $stdout.print("."); $stdout.flush; lsi.add_item(x) }
|
||||
$stdout.print("\n Rebuilding LSI index... ")
|
||||
lsi.build_index
|
||||
puts ""
|
||||
lsi
|
||||
end
|
||||
end
|
||||
|
||||
# Add any necessary layouts to this post.
|
||||
#
|
||||
# layouts - A Hash of {"name" => "layout"}.
|
||||
|
|
Loading…
Reference in New Issue