You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mxnet.apache.org by GitBox <gi...@apache.org> on 2018/01/12 21:00:12 UTC

[GitHub] szha commented on a change in pull request #9406: Text API (Resubmit #8763 #9394)

szha commented on a change in pull request #9406: Text API (Resubmit #8763 #9394)
URL: https://github.com/apache/incubator-mxnet/pull/9406#discussion_r161324044
 
 

 ##########
 File path: python/mxnet/contrib/text/embedding.py
 ##########
 @@ -88,18 +87,25 @@ def __init__(self, **kwargs):
         super(TokenEmbedding, self).__init__(**kwargs)
 
     @classmethod
-    def _get_pretrained_file_path_from_url(cls, url, embedding_root,
-                                           pretrained_file_name):
-        """Get the local path to the pre-trained token embedding file from url.
+    def _get_download_file_name(cls, pretrained_file_name):
+        return pretrained_file_name
 
+    @classmethod
+    def _get_pretrained_file_url(cls, pretrained_file_name):
+        repo_url = os.environ.get('MXNET_GLUON_REPO', C.APACHE_REPO_URL)
+        embedding_cls = cls.__name__.lower()
 
-        The pre-trained embedding file will be downloaded from url if it has not
-        been downloaded yet or the existing file fails to match its expected
-        SHA-1 hash.
-        """
+        url_format = '{repo_url}gluon/embeddings/{cls}/{file_name}'
+        return url_format.format(repo_url=repo_url,
+                                 cls=embedding_cls,
+                                 file_name=cls._get_download_file_name(pretrained_file_name))
 
+    @classmethod
+    def _get_pretrained_file(cls, embedding_root, pretrained_file_name):
+        from ...gluon.utils import check_sha1, download
 
 Review comment:
   This is one minor additional change to avoid changing the mxnet import chain in `__init__`

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services