{"size": 699, "ext": "js", "max_stars_repo_path": "src/nlp/lib/chunk.js", "max_stars_repo_name": "kushkamisha/information-search-methods", "max_stars_repo_stars_event_min_datetime": "2018-10-13T04:13:29.000Z", "max_stars_repo_stars_event_max_datetime": "2021-12-28T14:56:01.000Z", "max_issues_repo_path": "src/nlp/lib/chunk.js", "max_issues_repo_name": "kushkamisha/information-search-methods", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/nlp/lib/chunk.js", "max_forks_repo_name": "kushkamisha/information-search-methods", "max_forks_repo_forks_event_min_datetime": "2018-01-27T17:16:15.000Z", "max_forks_repo_forks_event_max_datetime": "2021-01-09T17:00:15.000Z"}
{"max_stars_count": 20, "max_issues_count": null, "max_forks_count": 7, "avg_line_length": 24.1034482759, "max_line_length": 70, "alphanum_fraction": 0.6151645207}
/*
 * Functions that chunk text in 2 steps: strip non-letters first, 
 * then chunk into unigrams.
 */

module.exports = (function(){
	/**
	 * 1. Clean up sentences: all non-letters replaced with a whitespace.
	 */
	function keepOnlyLetters(sentence){
	  return sentence.replace(/[^a-z]/gi, ' ');
	};

	/**
	 * 2. Chunk text using whitespace as the separator
	 */
	function getChunks(sentence){
	  var camelCaseSplit = sentence.replace(/([a-z](?=[A-Z]))/g, '$1 ');
	  return camelCaseSplit.match(/\S+/g) || [];
	};

	return function(sentence) {
            var onlyLetters = keepOnlyLetters(sentence);
            var tokens = getChunks(onlyLetters);
            return tokens;
           };

})();
