Commits

Mikhail Korobov committed afe18aa

initial import

Comments (0)

Files changed (10)

+#projects
+\.idea
+
+#temp files
+\.pyc
+\.orig
+
+#os files
+\.DS_Store
+Thumbs.db
+
+#project-specific files
+\.tox
+stuff
+MANIFEST$
+^pymorphy2_dicts/data
+^build
+^dict.xml
+^dist
+include README.rst
+recursive-include pymorphy2_dicts/data *.json
+recursive-include pymorphy2_dicts/data *.dawg
+recursive-include pymorphy2_dicts/data *.array
+pymorphy2-dicts
+===============
+
+This is a package with pre-compiled OpenCorpora.org dictionary
+data for pymorphy2 (https://github.com/kmike/pymorphy2).
+
+Installation
+------------
+
+Install::
+
+    $ pip install pymorphy2-data
+
+Update::
+
+    $ pip install --update 'pymorphy2-data < 2.0'
+
+Remove::
+
+    $ pip uninstall pymorphy2-data
+
+Usage
+-----
+
+You can get a path to the installed dataset using
+``pymorphy2_dicts.get_path()`` method. Usually you don't have to do so,
+because if all of the following apply:
+
+a) this package is installed;
+b) dictionary path is not passed to ``pymorphy2.MorphAnalyzer`` constructor;
+c) ``PYMORPHY2_DICTIONARY_PATH`` environment variable is not set,
+
+then ``pymorphy2.MorphAnalyzer()`` uses dictionaries from this
+package automatically.
+
+
+Development
+-----------
+
+The main repo is https://github.com/kmike/pymorphy2-dicts/. The repository
+doesn't contain the data itself: only package template and update
+scripts are stored in VCS.
+
+There is a hg/bitbucket mirror at https://bitbucket.org/kmike/pymorphy2-dicts/.
+
+License for Python code in this package is MIT. The data
+is licensed under `Creative Commons Attribution-Share Alike`_.
+
+.. _Creative Commons Attribution-Share Alike: http://creativecommons.org/licenses/by-sa/3.0/
+#!/bin/sh
+
+./setup.py sdist --formats=gztar,zip,bztar upload

pymorphy2_dicts/__init__.py

+# -*- coding: utf-8 -*-
+from __future__ import absolute_import
+import os
+
+def get_path():
+    """
+    Return path to dictionary.
+    """
+    return os.path.join(os.path.dirname(__file__), 'data')

pymorphy2_dicts/version.py

+__version__ = "1.0.389299"
+#!/usr/bin/env python
+from distutils.core import setup
+
+def get_version():
+    with open("pymorphy2_dicts/version.py", "rt") as f:
+        return f.readline().split("=")[1].strip(' "')
+
+setup(
+    name = 'pymorphy2-dicts',
+    version = get_version(),
+    author = 'Mikhail Korobov',
+    author_email = 'kmike84@gmail.com',
+    url = 'https://github.com/kmike/pymorphy2-dicts/',
+
+    description = 'OpenCorpora.org dictionaries pre-compiled for pymorphy2',
+    long_description = open('README.rst').read(),
+
+    license = 'MIT license',
+    packages = ['pymorphy2_dicts'],
+    package_data = {'pymorphy2_dicts': ['data/*']},
+
+    classifiers=[
+          'Development Status :: 4 - Beta',
+          'Intended Audience :: Developers',
+          'Intended Audience :: Science/Research',
+          'License :: OSI Approved :: MIT License',
+          'Natural Language :: Russian',
+          'Programming Language :: Python',
+          'Programming Language :: Python :: 2',
+          'Programming Language :: Python :: 2.6',
+          'Programming Language :: Python :: 2.7',
+          'Programming Language :: Python :: 3',
+          'Programming Language :: Python :: 3.2',
+          'Programming Language :: Python :: 3.3',
+          'Programming Language :: Python :: Implementation :: CPython',
+          'Programming Language :: Python :: Implementation :: PyPy',
+          'Topic :: Software Development :: Libraries :: Python Modules',
+          'Topic :: Scientific/Engineering :: Information Analysis',
+          'Topic :: Text Processing :: Linguistic',
+    ],
+)
+# -*- coding: utf-8 -*-
+from __future__ import absolute_import
+import unittest
+import os
+
+class TestInstall(unittest.TestCase):
+
+    def test_dict_exists(self):
+        import pymorphy2_dicts
+        path = pymorphy2_dicts.get_path()
+
+        # path exists
+        self.assertTrue(os.path.isdir(path))
+
+        # and has some files
+        self.assertTrue(os.listdir(path))
+
+
+if __name__ == '__main__':
+    unittest.main()
+[tox]
+envlist = py26,py27,py32,py33,pypy
+
+[testenv]
+
+commands=
+    python tests.py
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+"""
+Script for updating dictionary data.
+"""
+
+from __future__ import absolute_import, unicode_literals
+import logging
+import os
+import datetime
+import shutil
+
+from pymorphy2 import opencorpora_dict
+from pymorphy2.cli import download_xml, compile_dict, logger, show_dict_meta
+from pymorphy2.opencorpora_dict.storage import CURRENT_FORMAT_VERSION
+
+ROOT = os.path.dirname(__file__)
+
+OUT_PATH = os.path.join(ROOT, 'pymorphy2_dicts', 'data')
+XML_NAME = os.path.join(ROOT, 'dict.xml')
+VERSION_FILE_PATH = os.path.join(ROOT, 'pymorphy2_dicts', 'version.py')
+
+def rebuild_dictionary():
+    download_xml(XML_NAME, True)
+    shutil.rmtree(OUT_PATH)
+    compile_dict(XML_NAME, OUT_PATH)
+    os.unlink(XML_NAME)
+
+def write_version():
+    dct = opencorpora_dict.load(OUT_PATH)
+    contents = '__version__ = "{format_version}.{source_revision}"'.format(
+        format_version=CURRENT_FORMAT_VERSION,
+        source_revision=dct.meta['source_revision']
+    )
+    with open(VERSION_FILE_PATH, 'wb') as f:
+        f.write(contents.encode('utf8'))
+
+
+if __name__ == '__main__':
+    logger.setLevel(logging.DEBUG)
+
+    start = datetime.datetime.now()
+    rebuild_dictionary()
+
+    print('-'*20)
+    print("Done in %s\n" % (datetime.datetime.now() - start))
+
+    write_version()
+    show_dict_meta(OUT_PATH)
+
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.