-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Alberto Pettarin
committed
May 21, 2016
1 parent
ad12e4e
commit 3bd0698
Showing
13 changed files
with
44 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
0.0.1 | ||
0.0.2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,7 +14,7 @@ from ipapy.__main__ import main as package_main | |
__author__ = "Alberto Pettarin" | ||
__copyright__ = "Copyright 2016, Alberto Pettarin (www.albertopettarin.it)" | ||
__license__ = "MIT" | ||
__version__ = "0.0.1" | ||
__version__ = "0.0.2" | ||
__email__ = "[email protected]" | ||
__status__ = "Production" | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,7 +18,7 @@ | |
__author__ = "Alberto Pettarin" | ||
__copyright__ = "Copyright 2016, Alberto Pettarin (www.albertopettarin.it)" | ||
__license__ = "MIT" | ||
__version__ = "0.0.1" | ||
__version__ = "0.0.2" | ||
__email__ = "[email protected]" | ||
__status__ = "Production" | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,7 +23,7 @@ | |
__author__ = "Alberto Pettarin" | ||
__copyright__ = "Copyright 2016, Alberto Pettarin (www.albertopettarin.it)" | ||
__license__ = "MIT" | ||
__version__ = "0.0.1" | ||
__version__ = "0.0.2" | ||
__email__ = "[email protected]" | ||
__status__ = "Production" | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,16 +9,22 @@ | |
from __future__ import print_function | ||
|
||
from ipapy.compatibility import hex_to_unichr | ||
from ipapy.data import load_csv_file | ||
from ipapy.data import load_data_file | ||
from ipapy.ipastring import IPAString | ||
|
||
__author__ = "Alberto Pettarin" | ||
__copyright__ = "Copyright 2016, Alberto Pettarin (www.albertopettarin.it)" | ||
__license__ = "MIT" | ||
__version__ = "0.0.1" | ||
__version__ = "0.0.2" | ||
__email__ = "[email protected]" | ||
__status__ = "Production" | ||
|
||
ASCII_IPA_DATA_FILE_FIELD_SEPARATOR = u"," | ||
""" Field separator for the data file """ | ||
|
||
ASCII_IPA_DATA_FILE_COMMENT = u"#" | ||
""" Ignore lines starting with this character """ | ||
|
||
ASCII_IPA_DATA_FILE_PATH = "asciiipa.dat" | ||
""" | ||
Path of the built-in IPA database, | ||
|
@@ -34,7 +40,12 @@ def load_ascii_ipa_data(): | |
""" | ||
ascii_ipa_signs = [] | ||
ipa_descriptors_to_ascii_ipa = {} | ||
for line in load_csv_file(ASCII_IPA_DATA_FILE_PATH, 4): | ||
for line in load_data_file( | ||
relative_file_path=ASCII_IPA_DATA_FILE_PATH, | ||
comment_string=ASCII_IPA_DATA_FILE_COMMENT, | ||
field_separator=ASCII_IPA_DATA_FILE_FIELD_SEPARATOR, | ||
values_per_line=4 | ||
): | ||
# unpack line | ||
i_type, i_desc, i_unicode, i_ascii = line | ||
# if i_ascii is given as 4 hex chars (e.g., 00A1), convert it to unicode | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,7 +15,7 @@ | |
__author__ = "Alberto Pettarin" | ||
__copyright__ = "Copyright 2016, Alberto Pettarin (www.albertopettarin.it)" | ||
__license__ = "MIT" | ||
__version__ = "0.0.1" | ||
__version__ = "0.0.2" | ||
__email__ = "[email protected]" | ||
__status__ = "Production" | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,28 +23,28 @@ | |
__author__ = "Alberto Pettarin" | ||
__copyright__ = "Copyright 2016, Alberto Pettarin (www.albertopettarin.it)" | ||
__license__ = "MIT" | ||
__version__ = "0.0.1" | ||
__version__ = "0.0.2" | ||
__email__ = "[email protected]" | ||
__status__ = "Production" | ||
|
||
DATA_FILE_FIELD_SEPARATOR = u"," | ||
""" Field separator for the data file """ | ||
|
||
DATA_FILE_COMMENT = u"#" | ||
""" Ignore lines starting with this character """ | ||
|
||
IPA_DATA_FILE_CODEPOINT_SEPARATOR = u" " | ||
""" | ||
Separator between Unicode codepoints or | ||
Unicode compound strings for a given IPAChar | ||
""" | ||
|
||
IPA_DATA_FILE_COMMENT = u"#" | ||
""" Ignore lines starting with this character """ | ||
|
||
IPA_DATA_FILE_COMPOUND_OPERATOR = u"+" | ||
""" | ||
Operator to specify Unicode compound strings, | ||
e.g. 0070+032A = LATIN SMALL LETTER P + COMBINING BRIDGE BELOW | ||
""" | ||
|
||
IPA_DATA_FILE_FIELD_SEPARATOR = u"," | ||
""" Field separator for the data file """ | ||
|
||
IPA_DATA_FILE_NOT_AVAILABLE = u"N/A" | ||
""" Placeholder for an IPAChar not encoded in Unicode """ | ||
|
||
|
@@ -54,7 +54,7 @@ | |
relative to the ``data/`` directory | ||
""" | ||
|
||
def load_csv_file(relative_file_path, values_per_line=None): | ||
def load_data_file(relative_file_path, comment_string, field_separator, values_per_line=None): | ||
""" | ||
Load a comma-separated file, returning a list of tuples. | ||
|
@@ -73,9 +73,9 @@ def load_csv_file(relative_file_path, values_per_line=None): | |
with io.open(file_path, "r", encoding="utf-8") as f: | ||
for line in f: | ||
line = line.strip() | ||
if (len(line) > 0) and (not line.startswith(DATA_FILE_COMMENT)): | ||
if (len(line) > 0) and (not line.startswith(comment_string)): | ||
# unpack line | ||
values = line.split(DATA_FILE_FIELD_SEPARATOR) | ||
values = line.split(field_separator) | ||
if (values_per_line is not None) and (len(values) != values_per_line): | ||
raise ValueError("Data file '%s' contains a bad line: '%s'" % (file_path, line)) | ||
tuples.append(tuple(values)) | ||
|
@@ -94,7 +94,12 @@ def load_ipa_data(): | |
unicode_to_ipa = {} | ||
ipa_to_unicode = {} | ||
max_key_length = 0 | ||
for line in load_csv_file(IPA_DATA_FILE_PATH, 3): | ||
for line in load_data_file( | ||
relative_file_path=IPA_DATA_FILE_PATH, | ||
comment_string=IPA_DATA_FILE_COMMENT, | ||
field_separator=IPA_DATA_FILE_FIELD_SEPARATOR, | ||
values_per_line=3 | ||
): | ||
# unpack data | ||
i_type, i_desc, i_unicode = line | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,7 +13,7 @@ | |
__author__ = "Alberto Pettarin" | ||
__copyright__ = "Copyright 2016, Alberto Pettarin (www.albertopettarin.it)" | ||
__license__ = "MIT" | ||
__version__ = "0.0.1" | ||
__version__ = "0.0.2" | ||
__email__ = "[email protected]" | ||
__status__ = "Production" | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,7 +20,7 @@ | |
__author__ = "Alberto Pettarin" | ||
__copyright__ = "Copyright 2016, Alberto Pettarin (www.albertopettarin.it)" | ||
__license__ = "MIT" | ||
__version__ = "0.0.1" | ||
__version__ = "0.0.2" | ||
__email__ = "[email protected]" | ||
__status__ = "Production" | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,7 +13,7 @@ | |
__author__ = "Alberto Pettarin" | ||
__copyright__ = "Copyright 2016, Alberto Pettarin (www.albertopettarin.it)" | ||
__license__ = "MIT" | ||
__version__ = "0.0.1" | ||
__version__ = "0.0.2" | ||
__email__ = "[email protected]" | ||
__status__ = "Production" | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,15 +10,15 @@ | |
__author__ = "Alberto Pettarin" | ||
__copyright__ = "Copyright 2016, Alberto Pettarin (www.albertopettarin.it)" | ||
__license__ = "MIT" | ||
__version__ = "0.0.1" | ||
__version__ = "0.0.2" | ||
__email__ = "[email protected]" | ||
__status__ = "Production" | ||
|
||
setup( | ||
name="ipapy", | ||
packages=["ipapy", "ipapy.data"], | ||
package_data={"ipapy.data": ["*.dat"]}, | ||
version="0.0.1.0", | ||
version="0.0.2.0", | ||
description="ipapy is a Python module to work with IPA strings", | ||
author="Alberto Pettarin", | ||
author_email="[email protected]", | ||
|