Created
May 8, 2012 01:45
-
-
Save aileron/2631920 to your computer and use it in GitHub Desktop.
javascriptでなんとなく単語を抽出する
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function() { | |
var tags = []; | |
var _tags = {}; | |
var words = document.documentElement.innerText.match(/[\u3400-\u4DBF\u4E00-\u9FFF\uF900-\uFAFF]|[\uD840-\uD87F][\uDC00-\uDFFF]+|[\u12449-\u12531\u12540;]+|[a-zA-Z0-9!]+|[a-zA-Z>0-9]+/g); | |
words.forEach(function(word) { | |
if (word.length <= 3 || _tags[word]) { return ; } | |
_tags[ word ] = 0; | |
tags.push( word ); }); | |
delete _tags; | |
return tags; | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment