Skip to content

Commit

Permalink
Changed the directory structure
Browse files Browse the repository at this point in the history
  • Loading branch information
akutuzov committed Sep 14, 2020
1 parent e5b335b commit 9855405
Show file tree
Hide file tree
Showing 9 changed files with 32 additions and 4 deletions.
25 changes: 25 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import setuptools

with open("README.md", "r") as fh:
long_description = fh.read()

setuptools.setup(
name="simple_elmo",
version="0.1.0",
author="Andrey Kutuzov",
author_email="[email protected]",
description="Useful library to work with pre-trained ELMo embeddings in TensorFlow ",
long_description=long_description,
long_description_content_type="text/markdown",
url="https://github.com/ltgoslo/simple_elmo",
packages=setuptools.find_packages(),
python_requires='>=3.6',
install_requires=["tensorflow>1.15", "h5py", "numpy", "smart_open>1.8.1", "pandas", "scikit-learn"],
classifiers=[
"Programming Language :: Python :: 3",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
"Topic :: Scientific/Engineering :: Artifical Intelligence ",
"Topic :: Utilities"
],
)
2 changes: 2 additions & 0 deletions simple_elmo/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
name = "simple_elmo"
from simple_elmo.elmo_helpers import ElmoModel
9 changes: 5 additions & 4 deletions data.py → simple_elmo/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from smart_open import open
import numpy as np
from typing import List
import logging


class Vocabulary(object):
Expand Down Expand Up @@ -338,7 +339,7 @@ def __init__(self, filepattern, vocab, reverse=False, test=False,
"""
self._vocab = vocab
self._all_shards = glob.glob(filepattern + '*.gz')
print(f'Found {len(self._all_shards)} shards at {filepattern}', file=sys.stderr)
logging.info(f'Found {len(self._all_shards)} shards at {filepattern}')
self._shards_to_choose = []

self._reverse = reverse
Expand Down Expand Up @@ -383,7 +384,7 @@ def _load_shard(self, shard_name):
Returns:
list of (id, char_id) tuples.
"""
print(f'Loading data from: {shard_name}', file=sys.stderr)
logging.info(f'Loading data from: {shard_name}')
with open(shard_name, 'r') as f:
sentences_raw = f.readlines()

Expand All @@ -407,8 +408,8 @@ def _load_shard(self, shard_name):
else:
chars_ids = [None] * len(ids)

print(f'Loaded {len(ids)} sentences', file=sys.stderr)
print('Finished loading', file=sys.stderr)
logging.info(f'Loaded {len(ids)} sentences')
logging.info('Finished loading')
return list(zip(ids, chars_ids))

def get_sentence(self):
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 9855405

Please sign in to comment.