add positive and negative sentiments

This commit is contained in:
Zeke Sikelianos 2017-06-28 10:04:02 -07:00
Родитель d6eaf68c64
Коммит 5f6bcf2d92
4 изменённых файлов: 116 добавлений и 21 удалений

Просмотреть файл

@ -20,6 +20,8 @@ class Issue {
this.commentsAfterClosure = this.getCommentsAfterClosure()
this.commentsAfterClosureCount = this.commentsAfterClosure.length
this.sentimentScore = this.getSentimentScore()
this.positiveWords = this.getPositiveWords().join(', ')
this.negativeWords = this.getNegativeWords().join(', ')
return this
}
@ -43,6 +45,27 @@ class Issue {
.reduce((a, b) => {return a + b}, 0)
return Math.round(total / this.comments.length)
}
getPositiveWords () {
let words = []
this.comments.forEach(comment => {
comment.sentiment.positive.forEach(word => {
if (!words.includes(word)) words.push(word)
})
})
return words
}
getNegativeWords () {
let words = []
this.comments.forEach(comment => {
comment.sentiment.negative.forEach(word => {
if (!words.includes(word)) words.push(word)
})
})
return words
}
}
module.exports = Issue

Просмотреть файл

@ -1,7 +1,12 @@
const sentiment = require('sentiment')
const weights = {
commit: 0,
error: 0,
commit: 0
false: 0,
like: 0,
no: 0,
true: 0,
yeah: 0
}
module.exports = function (string) {

Различия файлов скрыты, потому что одна или несколько строк слишком длинны

Просмотреть файл

@ -13,7 +13,7 @@ let datasets = {
.slice(0, MAX)
.map(issue => {
return {
number: issue.linkedNumber,
'#': issue.linkedNumber,
title: issue.linkedTitle,
commentsAfterClosure: issue.commentsAfterClosureCount
}
@ -21,16 +21,18 @@ let datasets = {
.value()
},
high_sentiment_score: {
open_issues_with_high_sentiment_score: {
data: issues
.filter('open')
.filter(issue => issue.commentCount > 3)
.sortBy('sentimentScore')
.reverse()
.slice(0, MAX)
.map(issue => {
return {
number: issue.linkedNumber,
'#': issue.linkedNumber,
title: issue.linkedTitle,
words: issue.positiveWords,
comments: issue.commentCount,
sentiment: issue.sentimentScore
}
@ -38,15 +40,17 @@ let datasets = {
.value()
},
low_sentiment_score: {
open_issues_with_low_sentiment_score: {
data: issues
.filter(issue => issue.commentCount > 3)
.filter('open')
.filter(issue => issue.commentCount > 3)
.sortBy('sentimentScore')
.slice(0, MAX)
.map(issue => {
return {
number: issue.linkedNumber,
'#': issue.linkedNumber,
title: issue.linkedTitle,
words: issue.negativeWords,
comments: issue.commentCount,
sentiment: issue.sentimentScore
}
@ -54,6 +58,44 @@ let datasets = {
.value()
},
closed_issues_with_high_sentiment_score: {
data: issues
.filter('closed')
.filter(issue => issue.commentCount > 3)
.sortBy('sentimentScore')
.reverse()
.slice(0, MAX)
.map(issue => {
return {
'#': issue.linkedNumber,
title: issue.linkedTitle,
words: issue.positiveWords,
comments: issue.commentCount,
sentiment: issue.sentimentScore
}
})
.value()
},
closed_issues_with_low_sentiment_score: {
data: issues
.filter('closed')
.filter(issue => issue.commentCount > 3)
.sortBy('sentimentScore')
.slice(0, MAX)
.map(issue => {
return {
'#': issue.linkedNumber,
title: issue.linkedTitle,
words: issue.negativeWords,
comments: issue.commentCount,
sentiment: issue.sentimentScore
}
})
.value()
},
oldest_open_issues: {
data: issues
.filter('open')
@ -77,7 +119,7 @@ let datasets = {
.slice(0, MAX)
.map(issue => {
return {
number: issue.linkedNumber,
'#': issue.linkedNumber,
title: issue.linkedTitle,
comments: issue.commentCount
}
@ -93,7 +135,7 @@ let datasets = {
.slice(0, MAX)
.map(issue => {
return {
number: issue.linkedNumber,
'#': issue.linkedNumber,
title: issue.linkedTitle,
comments: issue.commentCount
}
@ -102,8 +144,14 @@ let datasets = {
}
}
console.log('# Electron Issues\n\n')
Object.keys(datasets).forEach(slug => {
console.log(`\n\n## ${titleCase(slug)}`)
console.log(`- [${titleCase(slug)}](#${slug})`)
})
Object.keys(datasets).forEach(slug => {
console.log(`\n\n<h2 id="${slug}">${titleCase(slug)}</h2>`)
const dataset = datasets[slug]
console.log(tableify(dataset.data))