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
5a45a43c
Commit
5a45a43c
authored
May 11, 2017
by
Romain Loth
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
WIP bipart: comments on refactoring strategy for categories and minor fixes in parseCustom
parent
562de2a2
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
53 additions
and
28 deletions
+53
-28
main.js
tinawebJS/main.js
+30
-6
methods.js
tinawebJS/methods.js
+1
-1
sigma.parseCustom.js
tinawebJS/sigma.parseCustom.js
+22
-21
No files found.
tinawebJS/main.js
View file @
5a45a43c
...
...
@@ -333,15 +333,39 @@ else {
if
(
inData
.
clusters
)
TW
.
Clusters
=
inData
.
clusters
// relations already copied in TW.Relations at this point
// £TODO also test with comex2 for bipart case
// TW.nodes1 = dicts.n1;//not used
var
catDict
=
dicts
.
catDict
// <= FIXME was already available at scanFile time...
console
.
log
(
"CategoriesDict: "
)
console
.
log
(
catDict
)
// a posteriori categories diagnostic
// ----------------------------------
// by default TW.categories now match user-suggested catSoc/Sem if present
// so we just need to handle mismatches here (when user-suggested cats were absent)
if
(
TW
.
categories
.
length
==
2
)
{
console
.
log
(
"== 'bipartite' case =="
)
if
(
TW
.
catSoc
!=
TW
.
categories
[
0
])
{
console
.
warn
(
`Observed social category "
${
TW
.
categories
[
0
]}
" overwrites user-suggested TW.catSoc ("
${
TW
.
catSoc
}
")`
)
TW
.
catSoc
=
TW
.
categories
[
0
]
}
if
(
TW
.
catSem
!=
TW
.
categories
[
1
])
{
console
.
warn
(
`Observed semantic category "
${
TW
.
categories
[
1
]}
" overwrites user-suggested TW.catSem "(
${
TW
.
catSem
}
)"`
)
TW
.
catSem
=
TW
.
categories
[
1
]
}
}
else
if
(
TW
.
categories
.
length
==
1
)
{
console
.
log
(
"== monopartite case =="
)
// FIXME it would be more coherent with all tina usecases (like gargantext or tweetoscope) for the default category to by catSem instead of Soc
if
(
TW
.
catSoc
!=
TW
.
categories
[
0
])
{
console
.
warn
(
`Observed unique category "
${
TW
.
categories
[
0
]}
" overwrites user-suggested TW.catSoc ("
${
TW
.
catSoc
}
")`
)
TW
.
catSoc
=
TW
.
categories
[
0
]
}
}
else
{
console
.
error
(
"== currently unhandled categorization of node types =="
,
TW
.
categories
)
}
TW
.
categoriesIndex
=
categories
;
//to_remove
TW
.
cat
Soc
=
categories
[
0
];
//to_remove
TW
.
cat
Sem
=
(
categories
[
1
])?
categories
[
1
]:
false
;
//to_remove
// FIXME generalize the use of these two TW.* variants instead of window-scoped 'categories' and 'catDict'
TW
.
cat
egories
=
categories
;
TW
.
cat
egoriesIndex
=
catDict
;
for
(
var
i
in
categories
)
{
TW
.
Filters
[
i
]
=
{}
...
...
tinawebJS/methods.js
View file @
5a45a43c
...
...
@@ -467,7 +467,7 @@ function updateRelatedNodesPanel( sels , same, oppos ) {
$
(
"#information"
).
html
(
informationDIV
);
$
(
"#tips"
).
html
(
""
);
if
(
TW
.
categories
Index
.
length
==
1
)
getTopPapers
(
"semantic"
);
if
(
TW
.
categories
.
length
==
1
)
getTopPapers
(
"semantic"
);
else
getTopPapers
(
swclickActual
);
}
...
...
tinawebJS/sigma.parseCustom.js
View file @
5a45a43c
...
...
@@ -4,15 +4,23 @@
// Level-01
ParseCustom
=
function
(
format
,
data
)
{
this
.
data
=
data
;
console
.
debug
(
"ParseCustom init format, data"
,
format
,
data
)
if
(
format
==
'gexf'
)
{
this
.
data
=
$
.
parseXML
(
data
)
}
else
{
this
.
data
=
data
}
this
.
format
=
format
;
this
.
nbCats
=
0
;
// input = GEXFstring
this
.
getGEXFCategories
=
function
(
aGexfFile
)
{
this
.
data
=
$
.
parseXML
(
aGexfFile
)
// <===================== (XML parse)
this
.
getGEXFCategories
=
function
()
{
return
scanGexf
(
this
.
data
);
}
// output =
[ "cat1" , "cat2" , ...]
}
// output =
{'cats':[ "cat1" , "cat2" , ...], 'rev': {cat1: 0, cat2: 1...}}
// input = [ "cat1" , "cat2" , ...]
...
...
@@ -24,9 +32,8 @@ ParseCustom = function ( format , data ) {
// input = JSONstring
this
.
getJSONCategories
=
function
(
json
)
{
this
.
data
=
json
;
return
scanJSON
(
this
.
data
);
}
// output =
[ "cat1" , "cat2" , ...]
}
// output =
{'cats':[ "cat1" , "cat2" , ...], 'rev': {cat1: 0, cat2: 1...}}
// input = [ "cat1" , "cat2" , ...]
...
...
@@ -199,13 +206,10 @@ function scanGexf(gexfContent) {
}
}
// console.warn("observed categoriesDict in scanGexf", categoriesDict)
// sorting observed json node types into Sem (=> 1)/Soc (=> 0)
result
=
sortNodeTypes
(
categoriesDict
)
// var catDict = result.reverse_dict
return
result
.
cats_pair
;
return
result
;
}
// sorting observed node types into Sem/Soc (factorized 11/05/2017)
...
...
@@ -216,8 +220,8 @@ function scanGexf(gexfContent) {
// (current expected structure in 'categories' can only accomodate 2 types
// 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
// - the way default cat is handled...)
// - the
effect on 'swclickActual'
// - the way default cat is handled
as 0
...)
// -------------------
// expected content: usually a just a few cats over all nodes
// ex: terms
...
...
@@ -240,6 +244,8 @@ function sortNodeTypes(observedTypesDict) {
}
if
(
nTypes
>
1
)
{
var
newcats
=
[]
// POSSible: allow more than 2 cats
for
(
var
i
in
observedTypes
)
{
c
=
observedTypes
[
i
]
if
(
c
==
TW
.
catSoc
||
(
c
!=
TW
.
catSem
&&
c
.
indexOf
(
"term"
)
==-
1
))
{
// NOT a term-category
...
...
@@ -253,7 +259,7 @@ function sortNodeTypes(observedTypesDict) {
}
observedTypes
=
newcats
;
}
return
{
'cat
s_pair
'
:
observedTypes
,
'reverse_dict'
:
catDict
}
return
{
'cat
egories
'
:
observedTypes
,
'reverse_dict'
:
catDict
}
}
// Level-00
...
...
@@ -841,17 +847,12 @@ function scanJSON( data ) {
for
(
var
i
in
nodes
)
{
n
=
nodes
[
i
];
if
(
n
.
type
)
categoriesDict
[
n
.
type
]
=
n
.
type
;
if
(
i
<
10
)
console
.
debug
(
"scanJSON node:"
,
n
)
}
// console.warn("observed categoriesDict in scanJSON", categoriesDict)
// sorting observed json node types into Sem/Soc
// sorting observed json node types into Sem (=> 1)/Soc (=> 0)
result
=
sortNodeTypes
(
categoriesDict
)
var
catDict
=
result
.
reverse_dict
return
result
.
cats_pair
;
return
result
;
}
// 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