-
Notifications
You must be signed in to change notification settings - Fork 311
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rewrite code to ES6 syntax #145
base: develop
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great Job! 😃👏{score: 7, comparative: 1.75 }
Some of my feedback related to the ES6 migration and other comments that might make sense to either include in this PR or not. I think it makes it much easier to follow.
build/build.js
Outdated
return hash; | ||
} catch (e) { | ||
throw new Error(e); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you remove the try catch blocks? I think you can simplify the nesting here and right now you are just throwing the error you just caught. Also, the nested catch, throw prepends an Error:
in the message.
build/build.js
Outdated
await fs.writeFileSync(RESULT_PATH, result); | ||
return hash; | ||
} catch (e) { | ||
throw new Error(e); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove try catch block.
build/build.js
Outdated
callback(null, hash); | ||
}); | ||
} | ||
const finish = async hash => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggest we rename function to something like writeJSON
or writeEmojiHash
and move the Complete: ${Object.keys(hash).length} entries.
into this utility function. Then you don't even need to return the hash.
build/build.js
Outdated
const build = async () => { | ||
try { | ||
let hash = {}; | ||
hash = await processEmoji(hash); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like you don't really need to pass hash into the processEmoji function. Suggest something like:
try {
const hash = await processEmoji();
await finish(hash);
} catch (e) {
console.error(e)
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You right, I didn't realize this.
lib/language-processor.js
Outdated
if (!languages[languageCode]) { | ||
// Try to load specified language | ||
try { | ||
const language = require('../languages/' + languageCode + '/index'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
../languages/${languageCode}/index
.toLowerCase() | ||
.replace(/\n/g, ' ') | ||
.replace(/[.,\/#!$%\^&\*;:{}=_`\"~()]/g, '') | ||
.split(' '); | ||
}; | ||
|
||
module.exports = tokenize; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure about this change. Why move the module.exports
call down here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It follows the same style as other files. I will change if not approved.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If there is only one exported function I think its fine to have it the assignment made along with the function declaration up top. That being said, lib/index.js
should probably be done in the same way. @thisandagain should probably clarify.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@thisandagain I think this just needs one more review before its ready to be merged.
package.json
Outdated
"nlp", | ||
"sentiment analysis" | ||
], | ||
"keywords": ["sentiment", "analysis", "nlp", "sentiment analysis"], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please don't make changes in the package.json
that are simply aesthetic. It makes this diff hard to read / manage.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, sorry about that.
process.stdout.write('IMDB accuracy: ' + validate(imdb) + '\n'); | ||
process.stdout.write('Yelp accuracy: ' + validate(yelp) + '\n'); | ||
process.stdout.write(`Amazon accuracy: ${validate(amazon)}\n`); | ||
process.stdout.write(` IMDB accuracy: ${validate(imdb)}\n`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extra spaces?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's just padding text for alignment. I will remove if not approved.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! A few changes, but overall this looks really good.
Any updates on these merge conflicts? |
Related to #136