Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationEventAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
2
Help us understand the problem. What are the problem?

More than 5 years have passed since last update.

Macの辞書ファイルを作るスクリプト

githubで使える絵文字のmarkdown形式でサジェスト?してくれる、辞書ファイルを作るくそみたいなスクリプト
作ったファイルを設定で取り込めば"えじ"で変換すると:hoge:みたいな感じでgithubで使える絵文字がでてくれます。

http://www.emoji-cheat-sheet.com
から絵文字を持ってきてます。

create_emoji_dictionary.sh

#!/bin/sh
EMOJI_DIR=/tmp/emoji_`date +"%Y%m%d_%H%M%S"`
mkdir -p $EMOJI_DIR
python emoji_to_dic.py > $EMOJI_DIR/mardkdown_utf8.txt
iconv -f utf-8 -t utf-16 $EMOJI_DIR/mardkdown_utf8.txt > $EMOJI_DIR/mardkdown.txt
open $EMOJI_DIR

emoji_to_dic.py

#!/usr/bin/env python
# -*- coding: utf-8 -*-
import argparse
import codecs
import sys
import urllib
from HTMLParser import HTMLParser

'''
Fixed variables
'''
url = 'http://www.emoji-cheat-sheet.com/'

'''
Parser
'''
class EmojiParser(HTMLParser):
  def __init__(self):
    HTMLParser.__init__(self)
    self.isToken = False
    self.token = ''

    '''
    ' Find software version tag.
    '''
  def handle_starttag(self, tag, attrs):
    self.isToken = False 
    attrs = dict(attrs)
    if tag != 'span':
      return
    if 'class' not in attrs:
      return
    if attrs['class'] != 'name':
      return
    self.isToken = True

  '''
  ' Extraction version data.
  '''
  def handle_data(self, data):
    data = data.strip('\ \n:')
    if not self.isToken:
      return
    if not data:
      return
    print u'"えじ",":' + data + u':","普通名詞"'

def GetParser():
  return EmojiParser()

'''
Main.
'''
if __name__ == "__main__":
  parser = GetParser()
  if not parser:
    print 'none parser.'
    sys.exit(1)
  sys.stdout = codecs.getwriter('utf_8')(sys.stdout)
  parser.feed(urllib.urlopen(url).read())
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
2
Help us understand the problem. What are the problem?