Skip to content

Commit 9db9c6f

Browse files
author
Roni Choudhury
authored
Merge pull request #485 from Kitware/sententree
Add SentenTree component
2 parents cbc653f + 65695cf commit 9db9c6f

File tree

11 files changed

+364
-3
lines changed

11 files changed

+364
-3
lines changed

app/examples/index.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,5 +119,9 @@
119119
{
120120
"title": "TreeHeatmap",
121121
"link": "tree-heatmap"
122+
},
123+
{
124+
"title": "SentenTree",
125+
"link": "sententree"
122126
}
123127
]

app/examples/sententree/index.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { goal } from '../util/datasets';
2+
import showComponent from '../util/showComponent';
3+
import SentenTree from '../../../components/SentenTree';
4+
5+
window.onload = () => {
6+
showComponent(SentenTree, {
7+
data: goal,
8+
id: 'id',
9+
text: 'text',
10+
count: 'count',
11+
graphs: 3
12+
});
13+
};
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
id text count
2+
477182317966798848 brazil's marcelo scores the first goal of the world cup ... against brazil. http://t.co/d3e1ac9e4f 3787
3+
477181994972246016 at least brazil have scored the first goal of the world cup #brazil2014 2878
4+
477134696137359360 rt @niallofficial: first game of the world cup tonight ! can't wait ! pra cima majooooorr ! cmon braziiiilllll ! 1702
5+
477182269107355649 the first goal of the world cup is an own goal! marcelo accidentally knocks it into his own net past julio cesar! croatia leads 1-0. 1689
6+
477181957348937730 goal: brazil 0-1 croatia marcelo scores an own goal in the 11th minute #joinin #worldcup #bracro – http://t.co/xxtmlp3e67 1582
7+
477181938726211584 just like we predicted, a brazilian scored the first goal in the world cup 1525
8+
477181975774519296 whoever bet that the first goal of the world cup was going to be an own goal just made a lot of money. 1405
9+
477180509240700928 rt @world: 736 players 64 matches 32 teams 12 stadiums 4 years of waiting 1 winning country the 2014 world cup has started . http://t.co/q... 1016
10+
477176771708981248 rt @5sos: watching the world cup tonight! with the tour fam :) - ash x 996
11+
477182399303135232 the first goal of the world cup was almost as bad as the opening ceremony. 960
12+
477159175081164801 rt @cocacola: live from the 2014 fifa world cup in brazil, the unveiling of the happiness flag. http://t.co/obzubmsm5g #worldscup http://t.... 935
13+
477052723050061824 rt @louis_tomlinson: world cup starts today !!!!!! amazing !!! 915
14+
477182228561022976 the first goal scored of the world cup 2014... was an own goal! 818
15+
477179277712977920 rt @espn: after 4 years, the wait is finally over. #bravscro http://t.co/bnzyexlleb 805
16+
477181874414948352 that's not in the script! own goal from marcelo puts croatia up 0-1. #brazilvscroatia 803
17+
477182570829213699 that moment when you score an own goal in the opening game of the world cup. http://t.co/zgfubk7wor 746
18+
477182066744754176 scoring on themselves in the world cup 745
19+
477181873274122240 world cup 2014 first goal is own-goal by marcelo ! 719
20+
477182690840416256 atleast brazil scored the first goal of the world cup 😂 665
21+
477180916545363968 rt @ilgdaily: bae: come over me: i'm watching the world cup ⚽️ bae: but i'm home alone me: ..uh, i'm watching the world cup ⚽️ 569
22+
477178606485905408 rt @worldstarfunny: bae: come over me: i'm watching the world cup bae: but i'm home alone me: .....i'm watching the world cup 523
23+
477182244076150786 hang on, this world cup thing's just a live-action rip-off of that playstation game isn't it? 522
24+
477182395452370945 marcelo scored the first goal of the 2014 world cup. on his own team. 483
25+
477183469790179328 the lights are out at arena de sao paulo. plenty of sunlight still, but half-lighting in some spots on the pitch. #bravscro 422
26+
477182060126162944 i would trade the us open, the world cup, & the nba finals for just one football game right now... 420
27+
477182740182630400 this is the best goal so far in the world cup 2014: marcelo's own goal: http://t.co/gw9xoamfyo 419
28+
477182045656203266 bet we're doing the same as you at home right about now yea...?!! #brazilvscroatia http://t.co/tm1lu2hmy0 398
29+
477176976067657728 rt @wesleystromberg: ahh i'm so amped to watch the start of the world cup today! wish i was in my homeland #brasil to fully experience http... 395
30+
477181737517076481 brazil own-goal: marcelo puts it in his own net. horrific start for the home team #bravscro 395
31+
477182624189132800 this was brazil's first ever own goal in world cup history #bravscro http://t.co/y32udows56 387
32+
477182378830336000 marcelo is leading the world cup in goals scored 😂🏆⚽️ 358
33+
477173496809029633 rt @espn: when the us open, world cup, and nba finals all fall on the same day, it's officially a sports holiday. http://t.co/dnlootpzit 324
34+
477182517628260353 #teambrazil wrong kind of selfie - marcelo scoring an own-goal in the world cup opener. 322
35+
477182764215975936 the moment marcelo scored. good finish from there, to be fair. #bra #cro #worldcup http://t.co/05tfdyei3k 322
36+
477181894564806656 goal! marcelo in his own net! #cro 1 - 0 #bra #worldcup 313
37+
477182500158988288 that was the first own goal for brazil in world cup history. #brazilvscroatia 310
38+
477182073917014017 even the dog is watching world cup http://t.co/drhxcjhw3j 300
39+
477182001812742145 first goal of world cup 2014 is an own goal. 🙈 296
40+
477179310206226433 rt @fifaworldcup: kick-off: brazil & croatia are underway! the wait is over. #joinin #worldcup #bracro – http://t.co/xxtmlp3e67 http://t.co... 295
41+
477179038528991232 rt @footballfunnys: 736 players 64 matches 32 teams 12 stadiums 4 years of waiting 1 winning country the 2014 world cup has started h... 291
42+
477177156334665728 rt @danielsahyounie: the world cup is back yay :) go brazil 276
43+
477178111381893123 rt @footy_jokes: rt if you are watching world cup 2014. 271
44+
477177715410223106 rt @geniusfootball: the world cup has started. http://t.co/jepb0zfw0r 266
45+
477179312454795266 rt @21lva: and the world cup begins 🏆🏆🏆!!! 262
46+
477181890516905986 1 - the first goal of world cup 2014 is an own goal by brazil's marcelo. 259
47+
477183281083858944 the \"did i do that?\" face!! #bra #cro http://t.co/pdmpzfstrb 259
48+
477183014657462274 marcelo's own goal, was brazil's first ever own goal in world cup history. #bracro 242
49+
477182262916939777 wow. hull city's striker misses, but ball still beats qpr reserve goalie. amazing scenes at the world cup 241
50+
477182127595720704 marcelo scores the first goal of the 2014 world cup............ against his own team 😂😂😂😂 239
51+
477171634269204480 rt @keatonstromberg: - game day! #worldcup2014 #brazil http://t.co/uycxnj7bxy 224
52+
477181853615816704 huge congrats to world cup leading goalscorer marcelo! 223
53+
477179119172866049 rt @fifaworldcuptm: 4 years are finally over! it's here. the world cup 2014 starts now! http://t.co/dfhavetxul 216
54+
477181708547424256 first world cup goal...own goal 😂😂😂 213
55+
477174346792706048 rt @ashofpallettown: it's impossible to not love japan when their world cup mascot is pikachu! http://t.co/m4mlwmfwiw 211
56+
477182257367900160 marcelo scores the first goal of the 2014 world cup! croatia 1-0 brazil. 210
57+
477171248670052352 rt @jasminevillegas: #bra #bra #bra #bra #bra #bra #bra #bra #bra #bra #bra #bra #bra #bra #bra #bra #bra #bra #bra #worldcup :) vamos bras... 201
58+
477181944292061186 marcelo scores the first goal of the 2014 world cup! croatia 1-0 brazil. 193
59+
477181478154293248 vaaaaaaaaaaaaaai brasil #bra #bra #bra #bra #bra #bra #bra #bra #bra #bra #bra #bra #bra #bra #bra 190
60+
477182787414282240 1 - marcelo's own goal was brazil's first ever own goal in a world cup match. 186
61+
477181060816441344 rt @geniusfootball: even the dog is watching world cup http://t.co/bf8gnjd2vj 185
62+
477173056297644033 rt @theellenshow: the l.a. galaxy wasn't allowed to participate in the world cup since galaxies aren't in the world. they're in outer space... 183
63+
477181947966672896 goal croatia! marcelo inadvertently flicks the ball into his own net after 10 minutes - disaster for the hosts. #bra 0-1 #cro. #worldcup 180
64+
477182597458853888 picture: neymar before the game http://t.co/6htqet1u9h [via @squawka] #bra 177
65+
477179089594228736 rt @soccerrproblems: ladies and gentlemen the world cup has began 🏆🙌⚽️ 168
66+
477182345884090369 scoring on your own net during the world cup #defenseprobs 168
67+
477181956028112896 hull city striker wrong foots qpr reserve keeper for opening goal in world cup. 168
68+
477181804043325442 you mad #bra 160
69+
477182359050399745 croatia score the first goal in the world cup 2014 https://t.co/hi0dpadqtg 160
70+
477181922008109058 twitter is the vuvuzela of the 2014 world cup. 158
71+
477182463022612481 first point of the world cup an own goal by brazil? ouch. 157
72+
477183065349844992 #worldcup #brazil 157
73+
477179301537005569 rt @bbcsport: the wait is over! it's kick-off in the @fifaworldcup in brazil. http://t.co/r8wj0xgkdd #bbcworldcup #bravscro http://t.co/dj6... 154
74+
477181945374203904 own goal from #marcelo. #bra 0-1 #cro 152
75+
477182452746563585 first ever own goal by a brazilian player in the world cup. 150
76+
477180881246105601 rt @motogp: #motogp the world cup is underway, who are you supporting? http://t.co/we1kqt9h5l #letsgobrazil http://t.co/xrwvg7l8a2 147
77+
477182633143582720 twitter error. spoil #worldcup2014 #brazilvscroatia http://t.co/x5h58cpmxr 143
78+
477182127667036162 the first goal of the #worldcup is an own goal by #bra. did not see that coming! https://t.co/kee9h08ydt 140
79+
477178542305054720 rt @sportscenter: the world cup kicks off now! neymar leads the favored brazilian selecao on home soil. http://t.co/9icwbqopgz 138
80+
477181272641785857 rt @squawka: photo of the world cup so far. #worldcup #bra http://t.co/4lnenfk1v8 138
81+
477182517091774464 croatia score the first goal in the world cup 2014 https://t.co/dk9ohl5ley 137
82+
477182445948002304 real madrid player scores the first 2014 world cup goal. marcelo in his debut. feel sorry for him. 135
83+
477183875089965057 it's arrived - players and staff gather to watch the opening game of the #worldcup #bravscro #3lions http://t.co/agaevd5ra0 135
84+
477183486768345091 world cup 2014 is the first edition in world cup history to open the scoring with an own goal. 133
85+
477183103103143937 away from the #bra game #por c. ronaldo has limped out of training after 15 mins with a knee injury and is a doubt for the world cup. 133
86+
477180760806658048 rt @realbobmortimer: #brazilvscroatia for the opening ceremony they should have just laid hulk down on the centre circle and slowly reveale... 126
87+
477182701158412289 dude on brazil scored on his own goal? so that means he dies if they lose right? isn't that how the world cup works? 123
88+
477182045920456704 world cup 2014 min 10 : brazil 0 - 1 croatia (marcelo own goal) #firstgoal #worldcup2014 123
89+
477182095815479296 defenders worst nightmare! welcome to the world cup. lots of time. 121
90+
477140213467447296 rt @pele: for this world cup, i wish good health to all the players, safety and enjoyment to all the fans, 120
91+
477182812324245504 an own goal to open the world cup. the only thing more catastrophic than that would be like... a safety to open the super bowl. 116
92+
477182397541535745 first goal of the 2014 world cup was an own goal, nobody saw that coming 115
93+
477181966228262914 and everyone thought brazil would destroy croatia. #cro 1-0 #bra 114
94+
477182142628130816 not a good look. http://t.co/pajmvtcng6 #bra #cro 114
95+
477183241003085824 croatia is on the board, up 1-0 vs brazil... first own goal for brazil in world cup history. #bravscro 114
96+
477181405391122432 rt if you're watching the world cup today! ⚽ 108
97+
477183080885923841 my whole timeline is watching the first match of the world cup and http://t.co/cveq7pheru 104
98+
477178510646464513 rt @samclaflin: just because i'm a norwich supporter. for this particular game i have to say it: #comeonyouyellows #brasil #brazil2014 #wor... 104
99+
477107247546638336 rt @_snape_: happy world cup day http://t.co/oufegyzuwk 102
100+
477183369512361984 louis' tweet to niall today about the world cup! http://t.co/f2gnnso4lw 101
101+
477169450437734400 rt @pattiemallettle: eu te amo #bra #worldcup 101
102+
569140211445334016 \"@bbcnewsus: kristen stewart is first us actress to win french \"#oscars\" equivalent...\" did she play an adulterous statue??? 1
103+
569140294748381184 b\\c the french hate everyone \"bbc: kristen stewart is first us actress to win french \"oscars\" equivalent http://t.co/t8qptvo89o\" 1

app/examples/util/datasets/index.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,19 @@ import simpsons_raw from './simpsons.csv';
1010
import simpsons_alternate_raw from './simpsons-alternate.csv';
1111
import stocks_raw from './stocks.csv';
1212
import bigram from './bigram.json';
13+
import goal_raw from './goal.tsv';
1314

14-
function readCSV (raw) {
15+
function readDSV (raw, type) {
1516
return dl.read(raw, {
16-
type: 'csv',
17+
type,
1718
parse: 'auto'
1819
});
1920
}
2021

22+
const readCSV = raw => readDSV(raw, 'csv');
23+
const readTSV = raw => readDSV(raw, 'tsv');
24+
25+
const goal = readTSV(goal_raw);
2126
const heatmap = readCSV(heatmap_raw);
2227
const hmohiv = readCSV(hmohiv_raw);
2328
const msft = readCSV(msft_raw);
@@ -26,6 +31,7 @@ const simpsons_alternate = readCSV(simpsons_alternate_raw);
2631
const stocks = readCSV(stocks_raw);
2732

2833
export {
34+
goal,
2935
heatmap,
3036
hmohiv,
3137
iris,

components/SentenTree/index.js

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
import { select } from 'd3-selection';
2+
3+
import VisComponent from '../../VisComponent';
4+
import { SentenTreeBuilder,
5+
SentenTreeVis } from 'sententree/dist/SentenTree';
6+
7+
export default class SentenTree extends VisComponent {
8+
static get options () {
9+
return [
10+
{
11+
name: 'data',
12+
description: 'The data table.',
13+
type: 'table',
14+
format: 'objectlist'
15+
},
16+
{
17+
name: 'id',
18+
description: 'The field containing the identifier of each row.',
19+
type: 'string',
20+
domain: {
21+
mode: 'field',
22+
from: 'data',
23+
fieldTypes: ['string', 'integer', 'number']
24+
}
25+
},
26+
{
27+
name: 'text',
28+
description: 'The field containing the text sample.',
29+
type: 'string',
30+
domain: {
31+
mode: 'field',
32+
from: 'data',
33+
fieldTypes: ['string']
34+
}
35+
},
36+
{
37+
name: 'count',
38+
description: 'The field containing the count for each text sample.',
39+
type: 'string',
40+
domain: {
41+
mode: 'field',
42+
from: 'data',
43+
fieldTypes: ['integer']
44+
}
45+
},
46+
{
47+
name: 'graphs',
48+
description: 'The number of graphs to compute and render.',
49+
type: 'integer',
50+
format: 'integer',
51+
default: 3
52+
}
53+
];
54+
}
55+
56+
constructor (el, {data, id = null, text = 'text', count = 'count', graphs = 3}) {
57+
super(el);
58+
59+
// Empty element.
60+
select(el)
61+
.selectAll('*')
62+
.remove();
63+
64+
// Transform input data into correct form.
65+
this.data = data.map((d, i) => ({
66+
id: id ? d[id] : i,
67+
text: d[text],
68+
count: d[count] !== undefined ? d[count] : 1
69+
}));
70+
71+
const model = new SentenTreeBuilder()
72+
.buildModel(this.data);
73+
74+
this.vis = new SentenTreeVis(el)
75+
.data(model.getRenderedGraphs(graphs));
76+
}
77+
78+
render () {}
79+
}

components/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import LineUp from './LineUp';
1111
import OnSet from './OnSet';
1212
import ScatterPlot from './ScatterPlot';
1313
import ScatterPlotMatrix from './ScatterPlotMatrix';
14+
import SentenTree from './SentenTree';
1415
import SimilarityGraph from './SimilarityGraph';
1516
import SurvivalPlot from './SurvivalPlot';
1617
import TrackerDash from './TrackerDash';
@@ -31,6 +32,7 @@ export default {
3132
OnSet,
3233
ScatterPlot,
3334
ScatterPlotMatrix,
35+
SentenTree,
3436
SimilarityGraph,
3537
SurvivalPlot,
3638
TrackerDash,

config/webpack-examples.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ module.exports = {
8888
loader: 'url-loader'
8989
},
9090
{
91-
test: /\.csv$/,
91+
test: /\.csv|\.tsv$/,
9292
loader: 'raw-loader'
9393
},
9494
{

0 commit comments

Comments
 (0)