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
Harbor 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
5343b99a
Commit
5343b99a
authored
7 years ago
by
bfs15
Browse files
Options
Downloads
Patches
Plain Diff
Parsing infomap ftree output
parent
12421110
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
lib/tasks/tag_clustering.rake
+39
-3
39 additions, 3 deletions
lib/tasks/tag_clustering.rake
with
39 additions
and
3 deletions
lib/tasks/tag_clustering.rake
+
39
−
3
View file @
5343b99a
...
...
@@ -2,9 +2,12 @@ require 'json'
namespace
:tag
do
desc
'Generate tag clusters'
task
generate_clusters: :environment
do
outDIR
=
"tmp"
fileName
=
"tags"
hash
=
{}
edges_total
=
0
filep
ath
=
Rails
.
root
.
join
(
"tmp"
,
"pajek
.net"
)
graphP
ath
=
Rails
.
root
.
join
(
outDir
,
fileName
+
"
.net"
)
def
swap
(
a
,
b
)
tmp
=
a
...
...
@@ -40,7 +43,7 @@ namespace :tag do
end
end
File
.
open
(
filep
ath
,
"w+"
)
do
|
f
|
File
.
open
(
graphP
ath
,
"w+"
)
do
|
f
|
f
<<
"*Vertices
#{
Tag
.
all
.
size
}
\n
"
# tags = Tag.all.to_ary
tag_index
=
{}
...
...
@@ -60,6 +63,39 @@ namespace :tag do
end
end
system
(
"infomap --ftree
#{
filepath
}
#{
Rails
.
root
.
join
(
"tmp"
)
}
"
)
system
(
"infomap --ftree
#{
graphPath
}
#{
Rails
.
root
.
join
(
outDIR
)
}
"
)
clusters
=
{
childs:
[],
parent:
nil
}
tags
=
{}
File
.
open
(
Rails
.
root
.
join
(
outDIR
,
fileName
+
".ftree"
),
"r"
)
do
|
f
|
f
.
gets
f
.
gets
while
line
=
f
.
gets
break
if
!
line
.
include?
':'
tmp
=
line
.
split
(
' '
)
ftree
=
tmp
[
0
].
split
(
':'
)[
0
..-
2
]
leafId
=
tmp
[
0
].
split
(
':'
)[
-
1
].
to_i
tagId
=
tmp
[
-
1
].
to_i
rank
=
tmp
[
1
].
to_f
name
=
tmp
[
2
..-
2
].
join
(
' '
)[
1
..-
2
]
it
=
clusters
ftree
.
each
do
|
clusterId
|
# p it
clusterId
=
clusterId
.
to_i
if
it
[
:childs
][
clusterId
].
nil?
it
[
:childs
][
clusterId
]
=
{
childs:
[],
parent:
nil
}
it
[
:childs
][
clusterId
][
:parent
]
=
it
end
it
=
it
[
:childs
][
clusterId
]
end
it
[
:childs
][
leafId
]
=
{
id:
tagId
,
rank:
rank
,
name:
name
,
parent:
it
}
tags
[
tagId
]
=
it
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