Returns the relevant words in a given text.

@param {string} text The text to retrieve the relevant words of.
@param {string} locale The paper's locale.
@returns {WordCombination[]} All relevant words sorted and filtered for this text.
function getRelevantWords( text, locale ) {
	let language = getLanguage( locale );
	if ( ! functionWordLists.hasOwnProperty( language ) ) {
		language = "en";
	}

	const functionWords = functionWordLists[ language ];

	const words = getWordCombinations( text, 1, functionWords.all );
	const wordCount = words.length;

	let oneWordCombinations = getRelevantCombinations(
		calculateOccurrences( words )
	);

	sortCombinations( oneWordCombinations );
	oneWordCombinations = take( oneWordCombinations, 100 );

	const oneWordRelevanceMap = {};

	forEach( oneWordCombinations, function( combination ) {
		oneWordRelevanceMap[ combination.getCombination() ] = combination.getRelevance();
	} );

	const twoWordCombinations = calculateOccurrences( getWordCombinations( text, 2, functionWords.all ) );
	const threeWordCombinations = calculateOccurrences( getWordCombinations( text, 3, functionWords.all ) );
	const fourWordCombinations = calculateOccurrences( getWordCombinations( text, 4, functionWords.all ) );
	const fiveWordCombinations = calculateOccurrences( getWordCombinations( text, 5, functionWords.all ) );

	let combinations = oneWordCombinations.concat(
		twoWordCombinations,
		threeWordCombinations,
		fourWordCombinations,
		fiveWordCombinations
	);

	combinations = filterCombinations( combinations, functionWords, language );

	forEach( combinations, function( combination ) {
		combination.setRelevantWords( oneWordRelevanceMap );
	} );

	combinations = getRelevantCombinations( combinations );
	sortCombinations( combinations );

	if ( wordCount >= wordCountLowerLimit ) {
		combinations = filterOnDensity( combinations, wordCount, densityLowerLimit, densityUpperLimit );
	}

	return take( combinations, relevantWordLimit );
}