pettarin / ipapy Goto Github PK
View Code? Open in Web Editor NEWipapy is a Python module to work with International Phonetic Alphabet (IPA) strings
License: MIT License
ipapy is a Python module to work with International Phonetic Alphabet (IPA) strings
License: MIT License
Tried installing this module through pip but got an installation error. Full trace:
PS C:\Users\bmvroy> pip install ipapy
Collecting ipapy
Using cached https://files.pythonhosted.org/packages/ae/d2/1af2bf40023d0cbc5d5cb9477938b923b8dc2eae479e5f0d1b4350db72be/ipapy-0.0.8.0.tar.gz
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:\Users\bmvroy\AppData\Local\Temp\pip-install-2wtx0rh1\ipapy\setup.py", line 28, in <module>
long_description=open("README.rst", "r").read(),
File "c:\python\python36\lib\encodings\cp1252.py", line 23, in decode
return codecs.charmap_decode(input,self.errors,decoding_table)[0]
UnicodeDecodeError: 'charmap' codec can't decode byte 0x90 in position 6127: character maps to <undefined>
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in C:\Users\bmvroy\AppData\Local\Temp\pip-install-2wtx0rh1\ipapy\
As you can see, it's an encoding error. Probably this is related to a file opening somewhere where the encoding is not explictly said to UTF-8. By default, Python uses the OS's default/the user's preferred encoding: locale.getpreferredencoding()
. I will take a look later, but I already share the bug now.
The ARPABETMapper
class seems to map some IPA phones to phones that are not part of ARPABET.
So far I've seen the following examples: {'EA', 'IA', 'OH', 'Q', 'UA'}
Code to reproduce:
from ipapy.arpabetmapper import ARPABETMapper
amapper = ARPABETMapper()
amapper.map_unicode_string('o' + 'ʔ', ignore=True, return_as_list=True)
# OUTPUT: ['OH', 'Q']
I get the following error when I try to use IPAString in new project
from ipapy.ipastring import IPAString
if __name__ == '__main__':
IPAString(unicode_string="tɛst")
Error:
Traceback (most recent call last):
File "D:\dev\tes1\main.py", line 1, in <module>
from ipapy.ipastring import IPAString
File "D:\dev\tes1\venv\lib\site-packages\ipapy\ipastring.py", line 10, in <module>
from collections import MutableSequence
ImportError: cannot import name 'MutableSequence' from 'collections' (C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.1776.0_x64__qbz5n2kfra8p0\lib\collections\__init__.py)
Resolution is to change ipastring.py:10:
from
from collections import MutableSequence
to
from collections.abc import MutableSequence
Ipapy by default shares the representation of the characters which leads to strange behaviours:
s = IPAString(unicode_string=r"pæk")
s[0].voicing = 'voiced'
print(s[0].voicing) # voiced
print(s[0].canonical_representation) # bilabial consonant plosive voiceless
print(str(s)) # p
s[2].descriptors = list(map(lambda d: 'voiced' if d in DG_C_VOICING else d, s[2].descriptors))
print(s[2].voicing) # voiced
print(s[2].canonical_representation) # consonant plosive velar voiced
print(str(s)) # k
s = IPAString(unicode_string=r"pæk")
print(s[0].voicing) # voiced
It can be workaround by copying and double-lookup of characters:
s = IPAString(unicode_string=r"pæk")
s[0] = UNICODE_TO_IPA[IPA_TO_UNICODE[IPAChar(descriptors=list(map(lambda d: 'voiced' if d in DG_C_VOICING else d, s[0].descriptors))).canonical_representation]]
print(str(s)) # bæk
But this is very verbose operation for changing a single letter.
Hi Alberto,
Thanks for making this great package.
Would it be possible to upload the latest version (with the fix from #2 ) to pip?
We use ipapy within wordkit. Apparently Windows users have problems installing this due to this encoding issue.
If not, then I'll add a work-around to Wordkit.
Thanks!
Stéphan
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.