categorize 0.0.6 → 0.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- NDZiODNkODIyOTFiNGQyZDBiYWM3NmM3MDg0YjBkOGM5ZjUyOTQ0OA==
4
+ YmI4NmJiZjFkYjJjY2ZkNTFjMGQyM2RhNTM2MjJhYTQ3MmQ2Nzc4Zg==
5
5
  data.tar.gz: !binary |-
6
- OTg5YWJjN2QwYTc3OWMxYjJiZTI5ZWM5MWEwMzllZGRiNGRmZDVmZQ==
6
+ ZGMwZmU4YTgyY2ZkZjFjNTljNmQwNmE2MTdkMmRlMWRlYjc1NjlmOA==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- NWRlMTAzMTlhMTgwN2VlM2M3NWE3MTI3NTQ5ZDRiNTFjNDJhZWQ0ZjY4ZTVm
10
- NWY2MTA0YTE2NWI2N2Q4ZTgyMDk4NDk0ZTg1MDFkNWI0YjFiYTMyM2U2ZjIz
11
- ZTgzZTdkMGMyNjY4YmU2NTVlYTJlZjhhYWE4Nzg4MDk3ZjYwYjk=
9
+ YzBkOTQwNjVhMGEzM2MyZDA3YTlhNjZmYTNiZWFlNjgwOTFlMGM2YjhlMjRm
10
+ NzUzMjFlNzE0ZTc0NThhOTBjY2E0ZjcwMzgzOThhNDg3NGQ0ZmI4MzY4MjM4
11
+ NTJlZmJjNTg1Y2I2ZDNjNmIzOTcxMTVhMDFmYTc2ODYxYTc1Yjk=
12
12
  data.tar.gz: !binary |-
13
- YzlkZDkzYTYzYTE1ZDBlNzNmZTY3ZDA0ZDA3ODc1YmYzNzU5NTgzODk5MTU5
14
- NzI0ZjQ1NGU5NGExOWIxZDhjNzQyM2VlMzAyMmE3MjUzNmVjNGFhNThjZjMw
15
- NWI0MTNhNTI3MTI5ZTA3MGEzZmM3NmMxNjA1NTFhOTZhNDhmNGI=
13
+ YmQ4YjFhOTBjMzIwZWEwM2ZjNGM3NzczYjFhYWU5MjM2NmI2NDMxMTU0ZDI4
14
+ NzU4ZDc3NGVlNjE1MzRjNTZhOTdiZDU3OWY4OWE4NDkxNDgwZTE1NWUyOThi
15
+ NmQ1ZjI2MGRkMjk3YjY3YmY4NzczM2VkYTljOTk3YmY1ZWI1MmQ=
@@ -18,9 +18,11 @@ module Categorize
18
18
  end
19
19
 
20
20
  def build_categories(clusters)
21
- clusters_to_records = Hash[clusters.each_with_index.map do |cluster, i|
22
- [i, cluster.data_items.map { |v| @vectors.index(v) }]
23
- end]
21
+ cluster_indices = clusters.map do |cluster|
22
+ cluster.data_items.map { |v| @vectors.index(v) }
23
+ end
24
+
25
+ clusters_to_records = Hash[(0...@num_clusters).zip(cluster_indices)]
24
26
 
25
27
  @query_terms ||= @query.split.map(&:downcase)
26
28
 
@@ -31,9 +33,9 @@ module Categorize
31
33
  end
32
34
 
33
35
  records = clusters_to_records.values
34
- # merge duplicate labeled categories
35
- categories_records = []
36
36
 
37
+ # merge categories with the same label
38
+ categories_records = []
37
39
  categories.each_with_index do |category, i|
38
40
  if j = categories[0...i].index(category) && categories_records[j]
39
41
  categories_records[j].last + records.shift
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: categorize
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter Lubell-Doughtie