뭔가 작업을해야합니다 :
는
function countWordFrequency() {
var freq={};
// Traverse the DOM looking for text nodes.
recurseTextNodes(function(textNode) {
// Split the text into words, removing punctuation.
var words = textNode.data.replace(/[^\w\s]/g, '').split(/\s+/)
, len = words.length;
// Count the word frequency.
for (var i=0; i<len; i++) {
// if (freq[words[i]]) { bug if one of the words is "constructor"!
if (typeof freq[words[i]] === 'number') {
freq[words[i]] += 1;
} else {
freq[words[i]] = 1;
}
}
});
return freq;
}
이 솔루션은 방법으로 지나치게 간단 할 수는 구두점을 제거하고 단어의 구문을 분석하지만, 아이디어를 설명해야한다고. 또한 recurseTextNodes
함수는 독자에게 연습 문제로 남아 있습니다. 이 루틴을 북마크릿으로 저장하는 방법 (예 : 결과를 최종 사용자에게 표시하는 방법)의 의미도 있지만, 다시 한 번 수행 할 방법에 대한 아이디어가 있다고 가정합니다.
https://www.squarefree.com/bookmarklets/seo.html을보고 싶을 수도 있습니다. 거기에 단어 빈도 북마크 렛이 꽤 잘 작동합니다. –
귀하의 google-fu가 실패하고 있습니다. 'bookmarklet word frequency'와'seo bookmarklet word frequency '를 검색하십시오. 나는 많은 좋은 안타를 본다. –