Skip to content
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

Open
wants to merge 10 commits into
base: develop
Choose a base branch
from
Open

Conversation

gomesals
Copy link

Related to #136

Copy link

@pdw207 pdw207 left a 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);
}
Copy link

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);
Copy link

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 => {
Copy link

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);
Copy link

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)
}

Copy link
Author

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.

if (!languages[languageCode]) {
// Try to load specified language
try {
const language = require('../languages/' + languageCode + '/index');
Copy link

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;
Copy link
Owner

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?

Copy link
Author

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.

Copy link

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.

Copy link

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"],
Copy link
Owner

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.

Copy link
Author

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`);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extra spaces?

Copy link
Author

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.

Copy link
Owner

@thisandagain thisandagain left a 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.

@gomesals gomesals changed the title Rewrites code to ES6 syntax Rewrite code to ES6 syntax Jun 20, 2018
@wzhouwzhou
Copy link

Any updates on these merge conflicts?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants