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
69f3142e
Commit
69f3142e
authored
7 years ago
by
Israel Barreto Sant'Anna
Browse files
Options
Downloads
Patches
Plain Diff
Generating json with tags names on tag frequency task
Signed-off-by:
Israel Barreto Sant'Anna
<
ibsa14@inf.ufpr.br
>
parent
81bd18a3
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_frequency_hash.rake
+9
-7
9 additions, 7 deletions
lib/tasks/tag_frequency_hash.rake
with
9 additions
and
7 deletions
lib/tasks/tag_frequency_hash.rake
+
9
−
7
View file @
69f3142e
...
@@ -3,6 +3,7 @@ namespace :tag do
...
@@ -3,6 +3,7 @@ namespace :tag do
desc
'Generate tag frequency hash'
desc
'Generate tag frequency hash'
task
generate_tag_frequency_hash: :environment
do
task
generate_tag_frequency_hash: :environment
do
hash
=
{}
hash
=
{}
name
=
{}
LearningObject
.
all
.
each
do
|
lo
|
LearningObject
.
all
.
each
do
|
lo
|
# for each lo, count tags and tag pairs and add to hash
# for each lo, count tags and tag pairs and add to hash
...
@@ -10,7 +11,13 @@ namespace :tag do
...
@@ -10,7 +11,13 @@ namespace :tag do
# hash[id1][id2] will equal how many times tags with id1 and id2 appear together on a LO
# hash[id1][id2] will equal how many times tags with id1 and id2 appear together on a LO
# hash[id][id] will equal how many times tag of id appears
# hash[id][id] will equal how many times tag of id appears
lo
.
tags
.
each
.
with_index
do
|
t
,
i
|
lo
.
tags
.
each
.
with_index
do
|
t
,
i
|
name
[
t
.
id
]
=
t
.
name
hash
[
t
.
id
]
=
{}
if
hash
[
t
.
id
].
nil?
hash
[
t
.
id
]
=
{}
if
hash
[
t
.
id
].
nil?
if
hash
[
t
.
id
][
t
.
id
]
!=
nil
hash
[
t
.
id
][
t
.
id
]
+=
1
else
hash
[
t
.
id
][
t
.
id
]
=
1
end
lo
.
tags
.
drop
(
i
+
1
).
each
do
|
t2
|
lo
.
tags
.
drop
(
i
+
1
).
each
do
|
t2
|
hash
[
t2
.
id
]
=
{}
if
hash
[
t2
.
id
].
nil?
hash
[
t2
.
id
]
=
{}
if
hash
[
t2
.
id
].
nil?
...
@@ -28,13 +35,8 @@ namespace :tag do
...
@@ -28,13 +35,8 @@ namespace :tag do
File
.
open
(
"tag_frequency_hash.json"
,
"w+"
)
do
|
f
|
File
.
open
(
"tag_frequency_hash.json"
,
"w+"
)
do
|
f
|
f
<<
hash
.
to_json
f
<<
hash
.
to_json
end
end
File
.
open
(
"tag_name.json"
,
"w+"
)
do
|
f
|
File
.
open
(
"community_input.txt"
,
"w+"
)
do
|
f
|
f
<<
name
.
to_json
hash
.
each
do
|
id1
,
ids2Hash
|
ids2Hash
.
each
do
|
id2
,
value
|
f
<<
"
#{
id1
}
,
#{
id2
}
,
#{
value
}
\n
"
end
end
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