Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
cleaning-portalmec
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Richard Fernando Heise Ferreira
cleaning-portalmec
Commits
6590821a
Commit
6590821a
authored
7 years ago
by
bfs15
Browse files
Options
Downloads
Patches
Plain Diff
Added comments
parent
a5cd92d9
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
lib/tasks/tag_clustering.rake
+10
-11
10 additions, 11 deletions
lib/tasks/tag_clustering.rake
with
10 additions
and
11 deletions
lib/tasks/tag_clustering.rake
+
10
−
11
View file @
6590821a
...
@@ -22,12 +22,14 @@ namespace :tag do
...
@@ -22,12 +22,14 @@ namespace :tag do
task
:generate_clusters
=>
[
:environment
]
do
task
:generate_clusters
=>
[
:environment
]
do
# DEBUG = true
# DEBUG = true
graph_path
=
TagSearchService
.
file_path
+
".net"
graph_path
=
TagSearchService
.
file_path
+
".net"
# Create hash of tag co occurrence
hash
=
create_hash
()
hash
=
create_hash
()
# Create a graph infomap can read
create_pajek_net_graph
(
hash
,
graph_path
)
create_pajek_net_graph
(
hash
,
graph_path
)
infomap_ftree
(
graph_path
,
TagSearchService
.
root_dir
)
infomap_ftree
(
graph_path
,
TagSearchService
.
root_dir
)
# Cluster needs to be read from disk again, so clear cache of TagSearchService
Rails
.
cache
.
delete
(
TagSearchService
::
CACHE_KEY
)
Rails
.
cache
.
delete
(
TagSearchService
::
CACHE_KEY
)
end
# task
end
# task
...
@@ -42,28 +44,25 @@ namespace :tag do
...
@@ -42,28 +44,25 @@ namespace :tag do
# for each lo, count tags and tag pairs and add to hash
# for each lo, count tags and tag pairs and add to hash
# if id1 <= id2
# if id1 <= id2
lo
.
tags
.
each
.
with_index
do
|
t
,
i
|
lo
.
tags
.
each
.
with_index
do
|
t
,
i
|
# initialize value
# initialize value
s
hash
[
t
.
id
]
=
{}
if
hash
[
t
.
id
].
nil?
hash
[
t
.
id
]
=
{}
if
hash
[
t
.
id
].
nil?
hash
[
t
.
id
][
t
.
id
]
=
0
if
hash
[
t
.
id
][
t
.
id
].
nil?
hash
[
t
.
id
][
t
.
id
]
=
0
if
hash
[
t
.
id
][
t
.
id
].
nil?
hash
[
t
.
id
][
t
.
id
]
+=
1
hash
[
t
.
id
][
t
.
id
]
+=
1
# add self occurrence
# for each next tags (with higher index)
# for each next tags (with higher index
than t
)
lo
.
tags
.
drop
(
i
+
1
).
each
do
|
t2
|
lo
.
tags
.
drop
(
i
+
1
).
each
do
|
t2
|
# [t1][t2], t1 should always
b
e lower
#
swap if necessary (
[t1][t2], t1 should always
hav
e lower
id)
if
t
.
id
>
t2
.
id
if
t
.
id
>
t2
.
id
# swaps
# swaps
t with t2
t
,
t2
=
t2
,
t
t
,
t2
=
t2
,
t
# check nil
# check nil
hash
[
t
.
id
]
=
{}
if
hash
[
t
.
id
].
nil?
hash
[
t
.
id
]
=
{}
if
hash
[
t
.
id
].
nil?
end
end
# initialize value
# initialize value
if
hash
[
t
.
id
][
t2
.
id
].
nil?
hash
[
t
.
id
][
t2
.
id
]
=
0
if
hash
[
t
.
id
][
t2
.
id
].
nil?
hash
[
t
.
id
][
t2
.
id
]
=
0
end
hash
[
t
.
id
][
t2
.
id
]
+=
1
hash
[
t
.
id
][
t2
.
id
]
+=
1
# add co occurrence
end
end
end
end
end
end
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment