Skip to content

Commit

Permalink
remove useless argument in word hashing unnit
Browse files Browse the repository at this point in the history
  • Loading branch information
bwanglzu committed Jul 23, 2018
1 parent 2ef5fd5 commit 8cfc56f
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions matchzoo/preprocessor/process_units.py
Original file line number Diff line number Diff line change
Expand Up @@ -317,8 +317,7 @@ class WordHashingUnit(ProcessorUnit):
Examples:
>>> tri_letters = ['#te', 'tes','est', 'st#']
>>> word_hashing = WordHashingUnit(
... term_index={'': 0,'st#': 1, '#te': 2, 'est': 3, 'tes': 4},
... dim_triletter=5)
... term_index={'': 0,'st#': 1, '#te': 2, 'est': 3, 'tes': 4})
>>> hashing = word_hashing.transform(tri_letters)
>>> hashing[0]
0.0
Expand All @@ -332,30 +331,28 @@ class WordHashingUnit(ProcessorUnit):
def __init__(
self,
term_index: dict,
dim_triletter: int
):
"""
Class initialization.
:param term_index: term-index mapping generated by
:class:`VocabularyUnit`.
:class:`VocabularyUnit`.
:param dim_triletter: dimensionality of tri_leltters.
"""
self._term_index = term_index
self._dim_triletter = dim_triletter

def transform(
self,
tri_letters: list
) -> np.ndarray:
"""
Transform list of tri-letters into word hashing layer.
Transform list of :attr:`tri-letters` into word hashing layer.
:param tri_letters: list of `tri_letters` generated by
:class:`NgramLetterUnit`.
:return: Word hashing representation of `tri-letters`.
"""
hashing = np.zeros(self._dim_triletter)
hashing = np.zeros(len(self._term_index))
counted_tri_letters = dict(collections.Counter(tri_letters))
for key, value in counted_tri_letters.items():
# get index.
Expand Down

0 comments on commit 8cfc56f

Please sign in to comment.