{"id":2741,"date":"2021-09-28T14:18:41","date_gmt":"2021-09-28T05:18:41","guid":{"rendered":"http:\/\/int-info.com\/?page_id=2741"},"modified":"2024-02-23T16:08:07","modified_gmt":"2024-02-23T07:08:07","slug":"google_collab_mecab","status":"publish","type":"page","link":"http:\/\/int-info.com\/index.php\/google_collab_mecab\/","title":{"rendered":"Google Colab \u3067\u81ea\u7136\u8a00\u8a9e\u51e6\u7406\uff08\uff20\u5927\u524d\u7814\u7a76\u5ba4\uff09"},"content":{"rendered":"<p><b>Google collab\u3067\u306e\u52d5\u4f5c\u78ba\u8a8d: 2024\u5e742\u670823\u65e5\u6642\u70b9<\/b><br \/>\n\u30b3\u30e9\u30dc\u5074\u306e\u30d0\u30fc\u30b8\u30e7\u30f3\u30a2\u30c3\u30d7\u306b\u3088\u308a\u30de\u30a4\u30ca\u30fc\u30c1\u30a7\u30f3\u30b8\u304c\u8981\u6c42\u3055\u308c\u308b\u5834\u5408\u304c\u3042\u308b<br \/>\n\u30a8\u30e9\u30fc\u304c\u51fa\u3066\u52d5\u304b\u306a\u3044\u5834\u5408\u306f\u3001\u5927\u524d\u307e\u3067\u9023\u7d61<\/p>\n<div style=\"margin: 30px\">\n<h3> \u5f62\u614b\u7d20\u89e3\u6790: \u6587\u7ae0\u3092\u54c1\u8a5e\u30ec\u30d9\u30eb\u306b\u5206\u89e3<\/h3>\n<p><b>\u6e96\u5099\uff1a<\/b><br \/>\n\u307e\u305a\u3001\u4ee5\u4e0b\u3092<b>1\u56de\u3060\u3051<\/b>\u5b9f\u884c\u3057\u307e\u3059\u3002<\/p>\n<pre>\r\n### MeCab\u8f9e\u66f8\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\r\n!sudo apt install mecab\r\n!sudo apt install libmecab-dev\r\n!sudo apt install mecab-ipadic-utf8\r\n\r\n### \u8f9e\u66f8\u3092\u4f7f\u3048\u308b\u5834\u6240\u306b\u79fb\u3059\r\n!mv \/etc\/mecabrc \/usr\/local\/etc\/\r\n\r\n### pip\u3067\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\r\n!pip3 install mecab-python3\r\n\r\n### \u30a4\u30f3\u30dd\u30fc\u30c8\r\nimport MeCab\r\ndic = MeCab.Tagger(\"-Ochasen\")\r\n<\/pre>\n<p><b>\u4f7f\u3044\u65b9\uff1a<\/b><br \/>\n\u4ee5\u4e0b\u3001\u5f62\u614b\u7d20\u89e3\u6790\u306e\u6700\u5c0f\u9650\u306e\u30b3\u30fc\u30c9\u3067\u3059\u3002<\/p>\n<pre>\r\nSentence = \"\u4eca\u65e5\u306f\u3044\u3044\u5929\u6c17\u3067\u3059\u3002\"\r\n\r\n######\r\nnode = dic.parseToNode(Sentence)\r\ninfo01, info02, word = [], [], []\r\nwhile node:\r\n    info01.append(node.feature.split(\",\")[0]) # \u54c1\u8a5e\u60c5\u58311\r\n    info02.append(node.feature.split(\",\")[1]) # \u54c1\u8a5e\u60c5\u58312\r\n    word.append(node.surface.split(\",\")[0]) # \u5358\u8a9e\r\n    node=node.next\r\n######\r\n\r\nprint(info01)\r\nprint(info02)\r\nprint(word)\r\n<\/pre>\n<p><b>Tips:<\/b><br \/>\ninfo01\u3001word\u306f\u30ea\u30b9\u30c8\u306a\u306e\u3067\u3001for\u6587\u30671\u3064\u305a\u3064\u89e3\u6790\u53ef\u80fd<br \/>\ninfo01\u306b\u54c1\u8a5e\u60c5\u5831\u304c\u683c\u7d0d\u3055\u308c\u3066\u3044\u308b\u306e\u3067\u3001if\u6587\u3092\u5229\u7528\u3059\u308b\u3068\u3001\u5f62\u5bb9\u8a5e\u3084\u540d\u8a5e\u3060\u3051\u3092\u53d6\u308a\u51fa\u3059\u3053\u3068\u304c\u3067\u304d\u308b<br \/>\n\u3053\u308c\u5358\u4f53\u3067\u4f7f\u3046\u3068\u3044\u3046\u3088\u308a\u3082\u3001\u4ee5\u4e0b\u306eword2vec\u306a\u3069\u3068\u7d44\u307f\u5408\u308f\u305b\u308b\u3068\u52b9\u679c\u7684\n<\/div>\n<div style=\"margin: 30px\">\n<h3>Word2Vec: \u5358\u8a9e\u540c\u58eb\u306e\u985e\u4f3c\u5ea6\u3092\u6e2c\u5b9a<\/h3>\n<p><b>\u6e96\u5099:<\/b><br \/>\n\u4ee5\u4e0b\u306f\u3001<b>1\u56de\u3060\u3051<\/b>\u5b9f\u884c\u3059\u308c\u3070\u826f\u3044\u3002<b>2\u5206\u304f\u3089\u3044<\/b>\u304b\u304b\u308b\u306e\u3067\u3001\u3050\u308b\u3050\u308b\u3057\u3066\u3044\u3066\u3082\u3001\u6c17\u9577\u306b\u5f85\u3061\u307e\u3059\u3002<\/p>\n<pre>\r\n!pip3 install gensim\r\n!wget http:\/\/int-info.com\/PyLearn\/usedat\/model.vec\r\nimport gensim\r\nmodel = gensim.models.KeyedVectors.load_word2vec_format('model.vec', binary=False)\r\n<\/pre>\n<p><b>\u4f7f\u3044\u65b9\uff1a<\/b><\/p>\n<pre>\r\nw1 = \"\u308a\u3093\u3054\"\r\nw2 = \"\u307f\u304b\u3093\"\r\ndist = model.similarity(w1, w2)\r\nprint(dist)\r\n<\/pre>\n<p><b>Tips:<\/b><br \/>\n\u5185\u90e8\u8f9e\u66f8\u306b\u5b58\u5728\u3057\u306a\u3044\u5358\u8a9e\u3092\u5165\u308c\u308b\u3068\u30a8\u30e9\u30fc\u304c\u51fa\u308b\u306e\u3067\u3001\u6ce8\u610f\u3002\u4f8b\u3048\u3070\u3001\u300c\u308a\u3093\u3054\u3093\u300d\u306a\u3069\u3002<br \/>\n\u6700\u5c0f0\u301c\u6700\u59271\u306e\u30ec\u30f3\u30b8<br \/>\n\u4f53\u611f\u7684\u306b\u3001\u95a2\u4fc2\u304c\u3042\u308b2\u5358\u8a9e\u3092\u5165\u308c\u308b\u3068\u30010.4\u4ee5\u4e0a\u304c\u51fa\u308b\u3002<br \/>\n\u7121\u95a2\u4fc2\u306a2\u5358\u8a9e\u3092\u5165\u308c\u308b\u3068\u30010.2\u672a\u6e80\u304f\u3089\u3044\u306e\u5024\u304c\u51fa\u308b\u3002<br \/>\n\u4f55\u304b\u95be\u5024\u304c\u3042\u308b\u308f\u3051\u3067\u306f\u306a\u3044\u306e\u3067\u3001\u81ea\u5206\u3067\u89e3\u91c8\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u3002\n<\/div>\n<div style=\"margin: 30px\">\n<h3>\u6975\u6027\u5224\u5b9a\uff08\u30cd\u30ac\u30dd\u30b8\u5224\u5b9a\uff09: \u5358\u8a9e\u3084\u6587\u7ae0\u306e\u30dd\u30b8\u3092\u6e2c\u5b9a<\/h3>\n<p><b>\u6e96\u5099:<\/b><br \/>\n\u4ee5\u4e0b\u306f<b>1\u56de\u3060\u3051<\/b>\u5b9f\u884c\u3059\u308c\u3070\u826f\u3044\u3002\u4f55\u5ea6\u3082\u3084\u3089\u306a\u3044\u3053\u3068\u3002<\/p>\n<pre>\r\n!pip install oseti\r\nimport oseti\r\nanalyzer = oseti.Analyzer()\r\n<\/pre>\n<p><b>\u4f7f\u3044\u65b9\uff1a<\/b><\/p>\n<pre>\r\nte = \"\u4eca\u65e5\u306e\u8a66\u5408\u3067\u52dd\u3061\u307e\u3057\u305f\u3002\"\r\nre = analyzer.analyze(te)\r\nprint(re[0])\r\n<\/pre>\n<p><b>Tips:<\/b><br \/>\n-1\u3060\u3068\u30cd\u30ac\u30c6\u30a3\u30d6\u3001+1\u3060\u3068\u30dd\u30b8\u30c6\u30a3\u30d6\u30010\u3060\u3068\u3069\u3061\u3089\u3067\u3082\u306a\u3044\u3002<br \/>\n\u30cd\u30ac\u30dd\u30b8\u304c\u6df7\u3056\u3063\u305f\u6587\u7ae0\u3060\u3068\u30010.333\u306a\u3069\u306b\u306a\u308b\u3002<br \/>\nanalyzer\u95a2\u6570\u306f\u3001\u30ea\u30b9\u30c8\u3067\u30cd\u30ac\u30dd\u30b8\u7d50\u679c\u3092\u8fd4\u5374\u3057\u3066\u304f\u308b\u305f\u3081\u30010\u756a\u76ee\u306e\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u306b\u30a2\u30af\u30bb\u30b9\u3057\u3066\u53d6\u308a\u51fa\u3057\u305f\u65b9\u304c\u826f\u3044<br \/>\n\u6587\u7ae0\u30ec\u30d9\u30eb\u3067\u5165\u308c\u3066\u3082\u826f\u3044\u3057\u3001\u5358\u8a9e\u30ec\u30d9\u30eb\u3067\u5165\u308c\u3066\u3082\u826f\u3044\u3002\u5f8c\u8005\u306e\u5834\u5408\u3001\u5f62\u614b\u7d20\u89e3\u6790\u3068\u7d44\u307f\u5408\u308f\u308b\u5fc5\u8981\u304c\u3042\u308b<\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Google collab\u3067\u306e\u52d5\u4f5c\u78ba\u8a8d: 2024\u5e742\u670823\u65e5\u6642\u70b9 \u30b3\u30e9\u30dc\u5074\u306e\u30d0\u30fc\u30b8\u30e7\u30f3\u30a2\u30c3\u30d7\u306b\u3088\u308a\u30de\u30a4\u30ca\u30fc\u30c1\u30a7\u30f3\u30b8\u304c\u8981\u6c42\u3055\u308c\u308b\u5834\u5408\u304c\u3042\u308b \u30a8\u30e9\u30fc\u304c\u51fa\u3066\u52d5\u304b\u306a\u3044\u5834\u5408\u306f\u3001\u5927\u524d\u307e\u3067\u9023\u7d61 \u5f62\u614b\u7d20\u89e3\u6790: \u6587\u7ae0\u3092\u54c1\u8a5e\u30ec\u30d9\u30eb\u306b\u5206\u89e3 <\/p><\/div>\n<div class=\"blog-btn\"><a href=\"http:\/\/int-info.com\/index.php\/google_collab_mecab\/\" class=\"home-blog-btn\">\u7d9a\u304d\u3092\u8aad\u3080<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-2741","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"http:\/\/int-info.com\/index.php\/wp-json\/wp\/v2\/pages\/2741","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/int-info.com\/index.php\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"http:\/\/int-info.com\/index.php\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"http:\/\/int-info.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/int-info.com\/index.php\/wp-json\/wp\/v2\/comments?post=2741"}],"version-history":[{"count":15,"href":"http:\/\/int-info.com\/index.php\/wp-json\/wp\/v2\/pages\/2741\/revisions"}],"predecessor-version":[{"id":3801,"href":"http:\/\/int-info.com\/index.php\/wp-json\/wp\/v2\/pages\/2741\/revisions\/3801"}],"wp:attachment":[{"href":"http:\/\/int-info.com\/index.php\/wp-json\/wp\/v2\/media?parent=2741"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}