summaryrefslogtreecommitdiff
path: root/scraper/client/paper/paper.info.js
blob: 25f4472f09ccb09d8666f75a1e35d236dc9291b9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
import React, { Component } from 'react'
import { bindActionCreators } from 'redux'
import { connect } from 'react-redux'

import * as actions from '../actions'
import { TableObject } from '../common'
import { USES_DATASET } from '../types'

import PaperChart from './paper.chart'

class PaperInfo extends Component {
  render() {
    const { paperInfo, sortedCitations, unknownCitations } = this.props.api
    const { dataset, paper, address } = paperInfo
    if (!dataset) return null

    let counts = {}
    const citationLabels = ['Uses Dataset', 'Doesn\'t Use Dataset', 'Not Enough Information', 'Unknown']
    const citationCountOrder = [ USES_DATASET.YES, USES_DATASET.NO, USES_DATASET.UNKNOWN, USES_DATASET.NO_DATA ]
    citationCountOrder.forEach(v => counts[v] = 0)

    sortedCitations.forEach(c => counts[c.verified] += 1)

    let citationCounts = {}
    let citationRows = []
    citationCountOrder.forEach((v, i) => {
      const count = counts[v]
      const label = citationLabels[i]
      citationCounts[label] = count
      citationRows.push([ label, count ])
    })

    return (
      <div className='paperInfo'>
        <h2>{dataset.name_full}</h2>
        <PaperChart
          rows={citationRows}
          title={'Dataset coverage'}
        />
        <TableObject summary
          tag="Dataset"
          object={dataset}
          order={'key name_full purpose comment created_by funded_by funded_by_short license'.split(' ')}
        />
        <TableObject summary
          tag="Paper"
          object={paper}
          order={"paper_id title year doi address".split(" ")}
        />
        <TableObject summary
          tag="Statistics"
          object={dataset}
          order={['year_published', 'purpose_short',
            'wild', 'indoor', 'outdoor', 'cyberspace',
            'names', 'downloaded',
            'year_published', 'year_start', 'year_end', 'ongoing', 'images', 'videos',
            'faces_unique', 'total_faces', 'img_per_person', 'num_cameras', 'faces_persons', 'female', 'male',
            'landmarks', 'width', 'height',
            'comment',
          ]}
        />
        <TableObject
          tag="Address"
          object={address}
          order={['address', 'type', 'lat', 'lng']}
        />
        <TableObject summary
          tag="Citations"
          object={citationCounts}
        />
      </div>
    )
  }
}

const mapStateToProps = state => ({
  api: state.api
})
const mapDispatchToProps = dispatch => ({
  actions: bindActionCreators({ ...actions }, dispatch),
})

export default connect(mapStateToProps, mapDispatchToProps)(PaperInfo)