Skip to content

Commit

Permalink
update documents
Browse files Browse the repository at this point in the history
  • Loading branch information
GreatYYX committed Mar 1, 2017
1 parent a5829c6 commit ab19b41
Show file tree
Hide file tree
Showing 7 changed files with 336 additions and 59 deletions.
20 changes: 19 additions & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,30 @@ Installation (need to upload to PYPI later)::

pip install rltk

Example::
Example 1::

>>> import rltk
>>> rltk.levenshtein_distance('abc', 'abd')
1

In RLTK, you can simply load the the resource you need and give it name, then reuse it by name in later methods.

Example 2::

>>> import rltk
>>>
>>> edit_distance_cost = {'insert': {'c':50}, 'insert_default':100, 'delete_default':100, 'substitute_default':100}
>>>
>>> tk = rltk.init()
>>> tk.load_edit_distance_table('A1', edit_distance_cost) # load resource
>>> tk.levenshtein_distance('a', 'abc')
>>> 2
>>> tk.levenshtein_distance('a', 'abc', name='A1')
>>> 150
>>> tk.normalized_levenshtein_distance('a', 'abc', name='A1')
>>> 50.0


API Reference
--------------

Expand Down
4 changes: 2 additions & 2 deletions docs/modules.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
similarity
RLTK
=================

.. toctree::
:maxdepth: 4

similarity
rltk
9 changes: 9 additions & 0 deletions docs/rltk.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
rltk package
=========================

.. automodule:: __init__
:members:

.. automodule:: core
.. autoclass:: Core
:members:
34 changes: 6 additions & 28 deletions rltk/__init__.py
Original file line number Diff line number Diff line change
@@ -1,32 +1,10 @@
from core import *

def init():
return RLTK()
"""
Initialization method.
# def init(init_dict):
# """
# This is the method for loading all configurations into memory. Once initialized, invoke methods without passing
# those gigantic structure again and again.
#
# Args:
# init_dict (dict):
# 'levenshtein.insert'
# 'levenshtein.delete'
# 'levenshtein.substitute'
# 'levenshtein.insert_default'
# 'levenshtein.delete_default'
# 'levenshtein.substitute_default'
# 'tf_idf.corpus_list'
#
# Returns:
# object: wrapped object
#
# Examples:
# >>> import rltk
# >>> tk = rltk.init({'tf_idf.corpus_list': [['a', 'b', 'a'], ['a', 'c'], ['a']]})
# >>> tk.levenshtein_distance('a', 'ab')
# 0.5
# >>> tk.tf_idf(['a', 'b', 'a'], ['a', 'c'])
# 0.17541160386140586
# """
# return RLTK(init_dict)
Returns:
object: RLTK object
"""
return Core()

0 comments on commit ab19b41

Please sign in to comment.