Skip to content
This repository has been archived by the owner on Mar 3, 2024. It is now read-only.

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
CyberZHG committed Sep 13, 2018
2 parents 3041398 + dbaf3ae commit c590878
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 15 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Expand Up @@ -108,3 +108,6 @@ venv.bak/

# IDE
.idea

# Temporary files
*.swp
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -116,7 +116,7 @@ inputs, embd_layer = get_embedding_layer(

### Wrapper Class `WordCharEmbd`

There is a wrapper class that makes the things easier.
There is a wrapper class that makes things easier.

```python
from keras_wc_embd import WordCharEmbd
Expand Down
2 changes: 1 addition & 1 deletion README.rst
Expand Up @@ -139,7 +139,7 @@ A helper function that loads pre-trained embeddings for initializing the weights
Wrapper Class ``WordCharEmbd``
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

There is a wrapper class that makes the things easier.
There is a wrapper class that makes things easier.

.. code-block:: python
Expand Down
16 changes: 8 additions & 8 deletions keras_wc_embd/wrapper.py
Expand Up @@ -53,15 +53,15 @@ def get_dicts(self):
self.word_dict, self.char_dict, self.max_word_len = self.dict_generator(return_dict=True)
return self.word_dict, self.char_dict

def get_word_dicts(self):
def get_word_dict(self):
"""Get the word dictionary.
:return word_dict:
"""
word_dict, _ = self.get_dicts()
return word_dict

def get_char_dicts(self):
def get_char_dict(self):
"""Get the character dictionary.
:return char_dict:
Expand Down Expand Up @@ -98,15 +98,15 @@ def get_embedding_layer(self,
:return inputs, embd_layer: The keras layer.
"""
if word_embd_file_path is not None:
word_embd_weights = get_embedding_weights_from_file(word_dict=self.word_dict,
word_embd_weights = get_embedding_weights_from_file(word_dict=self.get_word_dict(),
file_path=word_embd_file_path,
ignore_case=self.word_ignore_case)
if char_embd_file_path is not None:
char_embd_weights = get_embedding_weights_from_file(word_dict=self.char_dict,
char_embd_weights = get_embedding_weights_from_file(word_dict=self.get_char_dict(),
file_path=char_embd_file_path,
ignore_case=self.char_ignore_case)
return get_embedding_layer(word_dict_len=len(self.word_dict),
char_dict_len=len(self.char_dict),
return get_embedding_layer(word_dict_len=len(self.get_word_dict()),
char_dict_len=len(self.get_char_dict()),
max_word_len=self.max_word_len,
word_embd_dim=word_embd_dim,
char_embd_dim=char_embd_dim,
Expand All @@ -127,7 +127,7 @@ def get_batch_input(self, sentences):
"""
return get_batch_input(sentences,
max_word_len=self.max_word_len,
word_dict=self.word_dict,
char_dict=self.char_dict,
word_dict=self.get_word_dict(),
char_dict=self.get_char_dict(),
word_ignore_case=self.word_ignore_case,
char_ignore_case=self.char_ignore_case)
6 changes: 3 additions & 3 deletions setup.py
Expand Up @@ -2,7 +2,7 @@

setup(
name='keras-word-char-embd',
version='0.12',
version='0.13',
packages=['keras_wc_embd'],
url='https://github.com/CyberZHG/keras-word-char-embd',
license='MIT',
Expand All @@ -14,8 +14,8 @@
'keras',
],
classifiers=(
"Programming Language :: Python :: 2",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 2.7",
"Programming Language :: Python :: 3.6",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
),
Expand Down
4 changes: 2 additions & 2 deletions tests/test_wrapper.py
Expand Up @@ -18,8 +18,8 @@ def test_wrapper(self):
]
for sentence in sentences:
wc_embd.update_dicts(sentence)
word_dict = wc_embd.get_word_dicts()
char_dict = wc_embd.get_char_dicts()
word_dict = wc_embd.get_word_dict()
char_dict = wc_embd.get_char_dict()
wc_embd.set_dicts(word_dict, char_dict)
current = os.path.dirname(os.path.abspath(__file__))
word_embd_file_path = os.path.join(current, 'demo_word_embd.txt')
Expand Down

0 comments on commit c590878

Please sign in to comment.