[PYTHON] Create a Hatena dictionary for SKK (additional)

I want to create a Hatena dictionary for SKK

The day before yesterday, I met SKK and was impressed. (User life 3rd day w) I don't want to use Google-based CGI Server, so I chose dictionary life. Hatena dictionary seems to be good.

Ruby? Python

No Ruby environment ...

--There are many sources in ruby, but there is no python --The python code was created in less than 10 minutes -~~ Read with CorvusSKK → Character code error → Suffering ~~ -~~ I built it at home and brought the Dictionary, but there was an error ~~ --~~ CorvusSKK? Windows? Problems ~~ ――SKK FEP seems to be easy to make a dictionary --I was able to register with SKKFEP! --Living with SKKFEP!

Postscript (2017/3/3)

--Tell me about the import in CurvusSKK --Thank you, @corvussolis.

By the way, I have never dealt with it, but the source

make_skk_dic.py


# coding=utf-8
import pandas as pd
import numpy as np
import codecs
import re


def furi_del_norm(txt):
    r = re.match(r"[A-Month]", txt)
    if r:
        return np.Nan
    return txt


def main():
    df = pd.DataFrame()
    with codecs.open("keywordlist_furigana.csv", 'r', "euc_jp", "ignore") as file:
        df = pd.read_table(file, delimiter="\t")
    df.columns = ["furi", "word"]

    df = df.dropna()
    df["word"] = df["word"].replace('\r')
    df["furi"] = df["furi"].replace('\r')
    df["furi"] = df["furi"].apply(furi_del_norm)
    df = df.dropna()

    df = df.sort(columns=["furi"], ascending=True)

    # to_csv no good
    TMP_FILE_PATH = "SKK-JISHO.hatena"
    with codecs.open(TMP_FILE_PATH, 'w', "utf-8", "ignore") as file:
        #With Corvus SKK, enable the following(Postscript:2017/03/03)
        # file.write(";; okuri-ari entries.")
        # file.write(";; okuri-nasi entries.")
        for i, row in df.iterrows():
            file.write("%s /%s/" % (str(row["furi"]), str(row["word"])))
            file.write("\n")


if __name__ == "__main__":
    main()

Recommended Posts

Create a Hatena dictionary for SKK (additional)
Create a dictionary in Python
Create a nested dictionary using defaultdict
Create a model for your Django schedule
Various ways to create a dictionary (memories)
Script to create a Mac dictionary file
I made a python dictionary file for Neocomplete
Create a LINE BOT with Minette for Python
Create a dashboard for Network devices with Django!
How to create a shortcut command for LINUX
Automatically generate a polarity dictionary used for sentiment analysis
Create a QR code for the URL on Linux
[Go] How to create a custom error for Sentry
How to create a local repository for Linux OS
Create a Layer for AWS Lambda Python with Docker
Create a dictionary by searching the table using sqlalchemy
Create a Django schedule
Create a Python module
Create a Bootable LV
Create a Python environment
Create a slack bot
Let's create a function for parametrized test using frame object
Create a child account for connect with Stripe in Python
[Python] Create a date and time list for a specified period
[Django] Create a model suitable for phone numbers / zip codes
Create a Twitter BOT with the GoogleAppEngine SDK for Python
Create a Python script for Wake on LAN (NAT traversal Wake on LAN [5])
How to create a SAS token for Azure IoT Hub
I tried to create a bot for PES event notification
Create a virtual environment for python on mac [Very easy]
Create a social integration API for smartphone apps with Django
I want to create a Dockerfile for the time being.
[Python] Create a screen for HTTP status code 403/404/500 with Django