ikegami-yukino / jaconv Goto Github PK
View Code? Open in Web Editor NEWPure-Python Japanese character interconverter for Hiragana, Katakana, Hankaku, and Zenkaku
Home Page: https://ikegami-yukino.github.io/jaconv/jaconv.html
License: MIT License
Pure-Python Japanese character interconverter for Hiragana, Katakana, Hankaku, and Zenkaku
Home Page: https://ikegami-yukino.github.io/jaconv/jaconv.html
License: MIT License
Nice to get started.
Thank you for providing a great library.
In ver.0.3, when I pass "えっっ" to a function as follows, the function freezes.
jaconv.kana2alphabet("えっっ")
Hi!
Pretty lucky to get to use this convenient tool for handling Japanese script.
Keyword argument ignore
comes handy in some circumstances where you don't want some of the characters to stay unchanged. I just found ignore
was not used in jaconv.normalize
. It'd be an easy fix though.
ありがとうございます〜
※日本語で申し訳ないですが、これを英語でというのも若干罰ゲーム感漂い、だったらスルーしちゃおうって流れになるところからのIssue作成なのでどうかご容赦を。
以下の部分の日本語が間違っていないでしょうか?
# ASCII以外の半角文字 to 全角文字
jaconv.h2z(u'abc', ascii=True)
# => u'abc'
# 数字以外の半角文字 to 全角文字
jaconv.h2z(u'123', digit=True)
# => u'123'
なお、使う側からすると、混ざっている文字列に対して操作をするケースがあることを考えるとASCII以外→ASCIIのみという言い換えも良くないと思います。
というのは、kanaはデフォルトTrueで、いまのロジックだと以下のようになり、カナは常に変換されます。
>>> import jaconv
>>> jaconv.h2z(u'123abcティロ・フィナーレ', digit=True)
'123abcティロ・フィナーレ'
>>> jaconv.h2z(u'123abcティロ・フィナーレ', ascii=True)
'123abcティロ・フィナーレ'
>>>
これに関しては、英語のコメントを修正するのか、ロジックの修正なのか判断つきませんが、合わせてご判断頂ければと思います。
OS: Arch Linux
jaconv version: 0.3.4
jaconv
as a system package, README.rst
and CHANGES.rst
get installed to /usr/README.rst
and /usr/CHANGES.rst
.$HOME/.local/README.rst
and $HOME/.local/CHANGES.rst
.This happens with both python setup.py install
and pip install
.
The issue seems to be the data_files
argument to setup
in setup.py. This keyword is deprecated according to the documentation and removing it fixes the problem.
su
is converted before tsu
leading to words like 'atsui' being converted to 「あっすい」oh
is converted too soon leaving words like 'itoh' as 「いっおお」oh
replacements should be done after other replacements, current placement causes words like toho
to become 「っおおお」m
remains unconverted and becomes 「っ」, e.g., namba => なっば
dzu
is not converted, e.g. tsudsuku => っすっずく
>>> from jaconv import alphabet2kana as a2k
>>> a2k('tsudzuku')
'っすっずく'
>>> a2k('namba')
'なっば'
>>> a2k('itoh')
'いっおお'
>>> a2k('toho')
'っおおお'
As it says on the title, it would be nice to be able to automatically change ゑ to え, even を to お (as in をとこ). As well as be able to automatically transform けふ to きょう, くわ to か, げう to ぎょう etc.
I'm sure you know this very well, but there is also a convenient list here if it is helpful: https://www.bunka.go.jp/kokugo_nihongo/sisaku/joho/joho/kijun/naikaku/gendaikana/index.html
This is mostly useful for OCR purposes, but being able to change っ to つ, ぃ to い, etc. would be helpful when standardizing texts for search.
I found a bug in your code when I tried to convert a sentence that ends with 'っ' . (example : 'あっ' , 'ぐっ')
IMO, Cause is clear, list variable 'text' must be cast to str
In [2]: jaconv.kana2alphabet('あっ')
TypeError Traceback (most recent call last)
in ()
----> 1 jaconv.kana2alphabet('あっ')C:\ProgramData\Anaconda3\lib\site-packages\jaconv\jaconv.py in kana2alphabet(text)
211 tsu_pos = text.index('っ')
212 if len(text) <= tsu_pos + 1:
--> 213 return text[:-1] + 'xtsu'
214 text[tsu_pos] = text[tsu_pos + 1]
215 text = ''.join(text)TypeError: can only concatenate list (not "str") to list
Python3.4以下もサポートされているようですが、typingモジュールはPython3.5で追加されたようです。
https://docs.python.org/ja/3/library/typing.html
Python3.4の環境で検証ができなかったのですが、とりあえず型ヒントのある記法はPython2.7ではinvalid syntaxになるようです…(Wandboxで確認)
enlargesmallkana()
にある型ヒントは<=3.4の環境で邪魔にならないのでしょうか?
いまいち確証が持てていなくて申し訳ないです。よろしくお願いします。
Hi, i want to know that is there any api to convert romaji or alpha to kanji?
It would be nice for standardizing text inputs to be able to switch a string from shin to kyuu (or vice-versa).
Could you please tag the source again? This allows distributions to get the complete source from GitHub if they want.
This was done in the past but not for 0.3.3.
Thanks
The git tag for version v0.4.0
is missing. Could it be added please?
See also #27.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.