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
562de2a2
Commit
562de2a2
authored
May 11, 2017
by
Romain Loth
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
factorize cats creation from nodetypes (todo inspect extensively later)
parent
4531abfb
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
68 additions
and
70 deletions
+68
-70
main.js
tinawebJS/main.js
+4
-3
sigma.parseCustom.js
tinawebJS/sigma.parseCustom.js
+64
-67
No files found.
tinawebJS/main.js
View file @
562de2a2
...
@@ -316,8 +316,7 @@ else {
...
@@ -316,8 +316,7 @@ else {
var
initialState
=
buildInitialState
(
categories
)
//[true,false]//
var
initialState
=
buildInitialState
(
categories
)
//[true,false]//
// XML parsing from ParseCustom
// XML parsing from ParseCustom
var
dicts
=
start
.
makeDicts
(
categories
);
// > parseGexf, dictfyGexf
var
dicts
=
start
.
makeDicts
(
categories
);
// > parse json or gexf, dictfy
console
.
warn
(
"parsing result:"
,
dicts
)
console
.
warn
(
"parsing result:"
,
dicts
)
TW
.
Nodes
=
dicts
.
nodes
;
TW
.
Nodes
=
dicts
.
nodes
;
...
@@ -336,7 +335,7 @@ else {
...
@@ -336,7 +335,7 @@ else {
// relations already copied in TW.Relations at this point
// relations already copied in TW.Relations at this point
// TW.nodes1 = dicts.n1;//not used
// TW.nodes1 = dicts.n1;//not used
var
catDict
=
dicts
.
catDict
var
catDict
=
dicts
.
catDict
// <= FIXME was already available at scanFile time...
console
.
log
(
"CategoriesDict: "
)
console
.
log
(
"CategoriesDict: "
)
console
.
log
(
catDict
)
console
.
log
(
catDict
)
...
@@ -562,6 +561,7 @@ else {
...
@@ -562,6 +561,7 @@ else {
if
(
TW
.
filterSliders
)
{
if
(
TW
.
filterSliders
)
{
// £TODO test with comex2
if
(
typestring
==
"0|1"
)
{
if
(
typestring
==
"0|1"
)
{
$
(
"#category0"
).
hide
();
$
(
"#category0"
).
hide
();
$
(
"#category1"
).
show
();
$
(
"#category1"
).
show
();
...
@@ -670,6 +670,7 @@ else {
...
@@ -670,6 +670,7 @@ else {
// if (TW.catSem && TW.catSoc) {
// if (TW.catSem && TW.catSoc) {
setTimeout
(
function
()
{
setTimeout
(
function
()
{
// tabneigh: show "Related" tab
document
.
querySelector
(
'.etabs a[href="#tabs2"]'
).
click
()
document
.
querySelector
(
'.etabs a[href="#tabs2"]'
).
click
()
},
500
);
},
500
);
// }
// }
...
...
tinawebJS/sigma.parseCustom.js
View file @
562de2a2
...
@@ -160,8 +160,7 @@ function gexfCheckAttributesMap (someXMLContent) {
...
@@ -160,8 +160,7 @@ function gexfCheckAttributesMap (someXMLContent) {
// Level-00
// Level-00
function
scanGexf
(
gexfContent
)
{
function
scanGexf
(
gexfContent
)
{
console
.
log
(
"ParseCustom : scanGexf ======= "
)
console
.
log
(
"ParseCustom : scanGexf ======= "
)
var
categoriesDict
=
{},
categories
=
[];
var
categoriesDict
=
{};
// adding gexfCheckAttributesMap call
// adding gexfCheckAttributesMap call
// to create a map from nodes/node/@for values to declared attribute name (title)
// to create a map from nodes/node/@for values to declared attribute name (title)
...
@@ -200,42 +199,61 @@ function scanGexf(gexfContent) {
...
@@ -200,42 +199,61 @@ function scanGexf(gexfContent) {
}
}
}
}
for
(
var
cat
in
categoriesDict
)
// console.warn("observed categoriesDict in scanGexf", categoriesDict)
// usually a just a few cats over entire node set
// ex: terms
// ex: ISItermsriskV2_140 & ISItermsriskV2_140
console
.
debug
(
'>>> tr: cat'
,
cat
)
categories
.
push
(
cat
);
var
catDict
=
{}
result
=
sortNodeTypes
(
categoriesDict
)
if
(
categories
.
length
==
0
)
{
categories
[
0
]
=
"Document"
;
catDict
[
"Document"
]
=
0
;
}
if
(
categories
.
length
==
1
)
{
// if we have only one category, it gets the same code 0 as Document
// but in practice it's more often terms. anyways doesn't affect much
catDict
[
categories
[
0
]]
=
0
;
// console.log("-----cat unique =>0")
}
// £TODO here should use TW.catSem and TW.catSoc
// var catDict = result.reverse_dict
if
(
categories
.
length
>
1
)
{
var
newcats
=
[]
return
result
.
cats_pair
;
for
(
var
i
in
categories
)
{
}
c
=
categories
[
i
]
if
(
c
.
indexOf
(
"term"
)
==-
1
)
{
// NOT a term-category
// sorting observed node types into Sem/Soc (factorized 11/05/2017)
newcats
[
0
]
=
c
;
// --------------------
catDict
[
c
]
=
0
;
// FIXME this factorizes what we had twice (json & gexf scanFile workflows),
}
// and we just added missing TW.catSoc/Sem comparisons
else
{
// *but it doesn't fix the underlying logic*
newcats
[
1
]
=
c
;
// IS a term-category
// (current expected structure in 'categories' can only accomodate 2 types
catDict
[
c
]
=
1
;
// and the way it and catDict are used is not entirely coherent throughout
}
// the project, cf. among others: - the effect on 'typestring'
}
// - the way catDict recreated in dictfy
categories
=
newcats
;
// - the way default cat is handled...)
}
// -------------------
return
categories
;
// expected content: usually a just a few cats over all nodes
// ex: terms
// ex: ISItermsriskV2_140 & ISItermsriskV2_140
function
sortNodeTypes
(
observedTypesDict
)
{
var
observedTypes
=
Object
.
keys
(
observedTypesDict
)
var
catDict
=
{}
var
nTypes
=
observedTypes
.
length
if
(
nTypes
==
0
)
{
observedTypes
[
0
]
=
"Document"
;
catDict
[
"Document"
]
=
0
;
}
if
(
nTypes
==
1
)
{
// if we have only one category, it gets the same code 0 as Document
// but in practice it's more often terms. anyways doesn't affect much
catDict
[
observedTypes
[
0
]]
=
0
;
console
.
log
(
"-----cat unique =>0"
)
}
if
(
nTypes
>
1
)
{
var
newcats
=
[]
for
(
var
i
in
observedTypes
)
{
c
=
observedTypes
[
i
]
if
(
c
==
TW
.
catSoc
||
(
c
!=
TW
.
catSem
&&
c
.
indexOf
(
"term"
)
==-
1
))
{
// NOT a term-category
newcats
[
0
]
=
c
;
catDict
[
c
]
=
0
;
}
else
{
newcats
[
1
]
=
c
;
// IS a term-category
catDict
[
c
]
=
1
;
}
}
observedTypes
=
newcats
;
}
return
{
'cats_pair'
:
observedTypes
,
'reverse_dict'
:
catDict
}
}
}
// Level-00
// Level-00
...
@@ -367,6 +385,8 @@ function dictfyGexf( gexf , categories ){
...
@@ -367,6 +385,8 @@ function dictfyGexf( gexf , categories ){
}
}
node
.
attributes
=
atts
;
node
.
attributes
=
atts
;
// £TODO copy this logic in json case
// nodew=parseInt(attributes["weight"]);
// nodew=parseInt(attributes["weight"]);
if
(
atts
[
"category"
]
)
{
if
(
atts
[
"category"
]
)
{
node_cat
=
atts
[
"category"
];
node_cat
=
atts
[
"category"
];
...
@@ -446,7 +466,7 @@ function dictfyGexf( gexf , categories ){
...
@@ -446,7 +466,7 @@ function dictfyGexf( gexf , categories ){
// clusters and other facets => type => name => [{label,val/range,nodeids}]
// clusters and other facets => type => name => [{label,val/range,nodeids}]
TW
.
Clusters
=
{}
TW
.
Clusters
=
{}
// sorting out properties in n.attributes
// sorting out properties in n.attributes
==> £TODO shared function up to classvalues_fin
// --------------------------------------
// --------------------------------------
if
(
gotClusters
)
{
if
(
gotClusters
)
{
...
@@ -815,46 +835,23 @@ function dictfyGexf( gexf , categories ){
...
@@ -815,46 +835,23 @@ function dictfyGexf( gexf , categories ){
// Level-00
// Level-00
function
scanJSON
(
data
)
{
function
scanJSON
(
data
)
{
var
categoriesDict
=
{}
,
categories
=
[]
;
var
categoriesDict
=
{};
var
nodes
=
data
.
nodes
;
var
nodes
=
data
.
nodes
;
for
(
var
i
in
nodes
)
{
for
(
var
i
in
nodes
)
{
n
=
nodes
[
i
];
n
=
nodes
[
i
];
if
(
i
<
10
)
console
.
log
(
n
)
if
(
n
.
type
)
categoriesDict
[
n
.
type
]
=
n
.
type
;
if
(
n
.
type
)
categoriesDict
[
n
.
type
]
=
n
.
type
;
if
(
i
<
10
)
console
.
debug
(
"scanJSON node:"
,
n
)
}
}
for
(
var
cat
in
categoriesDict
)
// console.warn("observed categoriesDict in scanJSON", categoriesDict)
categories
.
push
(
cat
);
var
catDict
=
{}
// sorting observed json node types into Sem/Soc
if
(
categories
.
length
==
0
)
{
result
=
sortNodeTypes
(
categoriesDict
)
categories
[
0
]
=
"Document"
;
catDict
[
"Document"
]
=
0
;
}
if
(
categories
.
length
==
1
)
{
catDict
[
categories
[
0
]]
=
0
;
}
// £TODO here also should USE TW.catSem TW.catSoc
var
catDict
=
result
.
reverse_dict
if
(
categories
.
length
>
1
)
{
var
newcats
=
[]
for
(
var
i
in
categories
)
{
c
=
categories
[
i
]
if
(
c
.
indexOf
(
"term"
)
==-
1
)
{
// NOT a term-category
newcats
[
0
]
=
c
;
catDict
[
c
]
=
0
;
}
else
{
newcats
[
1
]
=
c
;
// IS a term-category
catDict
[
c
]
=
1
;
}
}
categories
=
newcats
;
}
return
categories
;
return
result
.
cats_pair
;
}
}
// Level-00
// Level-00
...
...
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