Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
clinicaltrials
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
david Chavalarias
clinicaltrials
Commits
7b091348
Commit
7b091348
authored
Jun 30, 2017
by
Romain Loth
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
choose node0 by most populated cat
parent
d5ebd7ae
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
41 additions
and
16 deletions
+41
-16
sigma.parseCustom.js
twmain/sigma.parseCustom.js
+41
-16
No files found.
twmain/sigma.parseCustom.js
View file @
7b091348
...
...
@@ -195,7 +195,10 @@ function scanGexf(gexfContent) {
// console.log('attr', attr)
// THIS WILL BECOME catDict (if ncats == 1 => monopart)
if
(
attr
==
"category"
)
categoriesDict
[
val
]
=
val
;
if
(
attr
==
"category"
||
attr
==
"type"
)
{
if
(
!
categoriesDict
[
val
])
categoriesDict
[
val
]
=
0
categoriesDict
[
val
]
++
;
}
}
}
}
...
...
@@ -213,6 +216,8 @@ function scanGexf(gexfContent) {
// ex: ISItermsriskV2_140 & ISItermsriskV2_140
function
sortNodeTypes
(
observedTypesDict
)
{
var
observedTypes
=
Object
.
keys
(
observedTypesDict
)
observedTypes
.
sort
(
function
(
a
,
b
)
{
return
observedTypesDict
[
b
]
-
observedTypesDict
[
a
]})
var
catDict
=
{}
var
nTypes
=
observedTypes
.
length
...
...
@@ -231,22 +236,39 @@ function sortNodeTypes(observedTypesDict) {
if
(
nTypes
>
1
)
{
var
newcats
=
[]
// NB: only 2 cat labels are allowed by this
// allows multiple node types, with an "all the rest" node1
// try stipulated cats, then fallbacks
if
(
observedTypesDict
[
TW
.
conf
.
catSem
])
{
newcats
[
0
]
=
c
;
catDict
[
c
]
=
0
;
}
if
(
observedTypesDict
[
TW
.
conf
.
catSoc
])
{
newcats
[
1
]
=
c
;
catDict
[
c
]
=
1
;
}
// NB: type for nodes0 will be the majoritary by default, unless taken
if
(
!
newcats
[
0
])
{
if
(
observedTypes
[
0
]
!=
newcats
[
1
])
newcats
[
0
]
=
observedTypes
[
0
]
else
newcats
[
0
]
=
observedTypes
[
1
]
}
// all the rest
for
(
var
i
in
observedTypes
)
{
let
c
=
observedTypes
[
i
]
if
(
c
==
TW
.
conf
.
catSoc
)
{
// conf says that it's not a term-category
newcats
[
1
]
=
c
;
catDict
[
c
]
=
1
;
}
// else: term-category is the new default
else
{
newcats
[
0
]
=
c
;
catDict
[
c
]
=
0
;
}
let
c
=
observedTypes
[
i
]
// or c is in "all the rest" group
// (POSS extend to multitypes)
if
(
c
!=
newcats
[
0
]
&&
c
!=
newcats
[
1
])
{
if
(
!
newcats
[
1
])
newcats
[
1
]
=
c
;
else
newcats
[
1
]
+=
'/'
+
c
catDict
[
c
]
=
1
;
}
}
observedTypes
=
newcats
;
}
return
{
'categories'
:
observedType
s
,
'lookup_dict'
:
catDict
}
return
{
'categories'
:
newcat
s
,
'lookup_dict'
:
catDict
}
}
...
...
@@ -981,8 +1003,11 @@ function scanJSON( data ) {
var
nodes
=
data
.
nodes
;
for
(
var
i
in
nodes
)
{
let
n
=
nodes
[
i
];
if
(
n
.
type
)
categoriesDict
[
n
.
type
]
=
n
.
type
;
let
ntype
=
nodes
[
i
].
type
;
if
(
ntype
)
{
if
(
!
categoriesDict
[
ntype
])
categoriesDict
[
ntype
]
=
0
categoriesDict
[
ntype
]
++
;
}
}
// sorting observed json node types into Sem (=> 1)/Soc (=> 0)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment