Skip to content

Commit

Permalink
lexc2dix: First version release
Browse files Browse the repository at this point in the history
lexc2dix-0.1 release!!!

lexc2dix: First version release

lexc2dix-0.1 release!!!
  • Loading branch information
Techievena committed Apr 11, 2018
1 parent 1bd5c85 commit c2e530a
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 22 deletions.
22 changes: 15 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,20 @@
# lexc2dix
A software that parses over the existing lttoolbox format and generates the corresponding monolingual dictionary in lttoolbox format. The package is modular and is user-friendly with proper help message and usage instructions. This was done as a part of coding challenge for the project `Extend lttoolbox to have the power of HFST`.

INSTALLATION
------------
If you are a user and are simply looking to install the package, just type the command given below in your terminal window.

```
$ pip3 install lexc2dix
```

To get proper usage instructions for the package, type the command given below.

```
$ lexc2dix -e
```

GETTING STARTED
---------------
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.
Expand Down Expand Up @@ -44,12 +58,6 @@ optional arguments:
$ lexc2dix tests/test_files/apertium-kaz.kaz.lexc
```

As the package is currently buggy and can't handle all the entries present in the lexc files we are not writing the results into a dix file, but that be easily done manually with the help of this command:

```
$ lexc2dix tests/test_files/apertium-kaz.kaz.lexc | tee tests/test_files/apertium-kaz.kaz.dix
```

EXTERNAL LIBRARIES USED
-----------------------
* regex 2018.02.21 (Python 3)
Expand Down Expand Up @@ -79,4 +87,4 @@ The GNU GENERAL PUBLIC LICENSE - [Abinash Senapati](http://github.com/Techievena

ACKNOWLEDGEMENTS
----------------
I would like to thank mentors at [Apertium](https://github.com/Apertium) for helping me in the development and maintenance of this package.
I would like to thank mentors at [Apertium](https://github.com/Apertium) for helping me with the development and maintenance of this package.
7 changes: 3 additions & 4 deletions api/lexc2dix_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,7 @@ def detailed_usage():
"is user-friendly with proper help message and usage instructions. \nThis was done as a " +
"part of coding challenge for the project `Extend lttoolbox to have the power of HFST`." +
"\n\nUSAGE INSTRUCTIONS:\n\n" +
"\t$ lexc2dix tests/test_files/apertium-kaz.kaz.lexc\n\n" +
"For printing results to a file execute the command,\n\n" +
"\t$ lexc2dix tests/test_files/apertium-kaz.kaz.lexc | tee tests/test_files/apertium-kaz.kaz.dix\n")
"\t$ lexc2dix tests/test_files/apertium-kaz.kaz.lexc\n")

def file_read(filename):
"""Read the dictionary file parsed as arguement"""
Expand All @@ -47,7 +45,8 @@ def file_read(filename):
line = line.rstrip('\n').strip(' ').strip('\t')
nline += (line+'\n') if (len(line) and not line.startswith('!')) else ''
lines.close()
lp.main(nline)
filename = filename[:-4] + 'dix'
lp.main(nline, filename)

if __name__ == '__main__':
main()
9 changes: 6 additions & 3 deletions lexc2dix/dix_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ def escape_xml(string_val):
return string_val

class DixGenerator(object):
"""docstring for dix_generator"""
"""The class for generating dix file from the dictionaries constructed after parsing
through the lexc files."""
def __init__(self):
self.serializer = Py2XML()
self.sdef_module = ""
Expand Down Expand Up @@ -119,9 +120,11 @@ def section_module_generator(self, root_lexicon_dict):
self.section_module = self.section_module.replace('<es>', '<section id=\"main\" type=\"standard\">').replace('</es>', '</section>')
self.section_module = self.section_module.split('\n', 1)[1]

def all_module_merger(self):
def all_module_merger(self, filename):
"""The module to join all the generated sections to yeild the final dix file"""
dix_file = [self.sdef_module, self.pardef_module, self.section_module]
separator = '\n'
dix_file = separator.join(dix_file)
print(dix_file)
with open(filename, 'w+') as d_file:
d_file.write(dix_file)
d_file.close()
4 changes: 2 additions & 2 deletions lexc2dix/lexc_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@

D_G = DixGenerator()

def main(nline):
def main(nline, filename):
"""Main function"""
dict_split(nline)
D_G.all_module_merger()
D_G.all_module_merger(filename)

def dict_split(fileread):
"""The module to separate multichar symbols and lexicons"""
Expand Down
8 changes: 4 additions & 4 deletions lexc2dix/release.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
"""Release file for lexc2dix"""

name = 'lexc2dix'
major = '0'
minor = '1'
major = '1'
minor = '0'

__version__ = major + '.' + minor

__date__ = '2018-03-01' ## YYYY-MM-DD

__description__ = 'The python module for converting lexc to dix files'
__description__ = 'The python module for converting lexc to dix files format'

__author__ = 'Abinash Senapati(@Techievena)'
__email__ = '[email protected]'
__email__ = '[email protected]'

__url__= 'https://github.com/Techievena/lexc2dix'
__download_url__ = 'https://github.com/Techievena/lexc2dix/archive/master.zip'
26 changes: 24 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
description=release.__description__,
url=release.__url__,
download_url=release.__download_url__,
keywords=['lexc', 'twolc', 'monodix'],
keywords=['lexc', 'twolc', 'monodix', 'Apertium', 'HFST'],
packages=find_packages(exclude=["build.*", "tests", "tests.*"]),
install_requires=required,
tests_require=test_required,
Expand All @@ -43,5 +43,27 @@
'console_scripts': [
'lexc2dix = lexc2dix_api:main'
]
}
},
python_requires='>=3',
classifiers=[
# How mature is this project? Common values are
# 3 - Alpha
# 4 - Beta
# 5 - Production/Stable
'Development Status :: 3 - Alpha',

# Indicate who your project is intended for
'Intended Audience :: Developers',
'Topic :: Software Development :: Build Tools',

# Pick your license as you wish (should match "license" above)
'License :: OSI Approved :: GNU General Public License v3 (GPLv3)',

# Specify the Python versions you support here. In particular, ensure
# that you indicate whether you support Python 2, Python 3 or both.
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.2',
'Programming Language :: Python :: 3.3',
'Programming Language :: Python :: 3.4',
],
)

0 comments on commit c2e530a

Please sign in to comment.