Permalink
Browse files

Deduplicate artists before returning

  • Loading branch information...
1 parent 5ac2fc4 commit b1c5a8d5f168d3523b17cc44afbcf6d1c7554991 Phil Cowans committed May 29, 2011
Showing with 7 additions and 6 deletions.
  1. +7 −6 lib/artistractor/artist_extractor.rb
@@ -11,16 +11,17 @@ def setup
end
def extract_from_text(text)
- extracted_artists = []
-
java_string = Java::JavaLang::String.new(text)
-
chunking = @chunker.chunk(text)
+
+ artist_names = []
chunking.each do |chunk|
- artist_name = java_string.substring(chunk.start,chunk.end)
- extracted_artists << {:name => artist_name, :mbid => @mbids[artist_name.downcase]}
+ artist_names << java_string.substring(chunk.start,chunk.end)
+ end
+
+ artist_names.sort.uniq.map do |artist_name|
+ {:name => artist_name, :mbid => @mbids[artist_name.downcase]}
end
- extracted_artists
end
end
end

0 comments on commit b1c5a8d

Please sign in to comment.