How to set Python path for NLTK in Palantir Foundry Python Transform in Code Workbook - Stack Overflow

I am attempting to create a Python transform that requires me to import nltk.When I import nltk, late

I am attempting to create a Python transform that requires me to import nltk. When I import nltk, later on I get:

Resource [93mpunkt_tab[0m not found.
Please use the NLTK Downloader to obtain the resource:
[31m>>> import nltk
>>> nltk.download('punkt_tab')   [0m   For more information see: .html
Attempted to load [93mtokenizers/punkt_tab/english/[0m

So putting the download code within Foundry doesn't seem to work even though I could do it in my local code, that is:

nltk.download()

So I was trying to download all the required files locally and then upload an nltk_data folder to the same level as my Code Workbook. Then I wanted to add the location of the nltk_data folder to the Python path but that does not seem to work. How do I do this, get the location of the newly uploaded folder into the Python path? Do I somehow use the RID for the folder? When I do a python walk for the / directory, I can't find nltk_data

As a final note, I am not an admin, so any approaches to do this have to be as a non-admin user. It seems like such a simple use case, but I guess Foundry abstracts away the file system.

I am attempting to create a Python transform that requires me to import nltk. When I import nltk, later on I get:

Resource [93mpunkt_tab[0m not found.
Please use the NLTK Downloader to obtain the resource:
[31m>>> import nltk
>>> nltk.download('punkt_tab')   [0m   For more information see: https://www.nltk./data.html
Attempted to load [93mtokenizers/punkt_tab/english/[0m

So putting the download code within Foundry doesn't seem to work even though I could do it in my local code, that is:

nltk.download()

So I was trying to download all the required files locally and then upload an nltk_data folder to the same level as my Code Workbook. Then I wanted to add the location of the nltk_data folder to the Python path but that does not seem to work. How do I do this, get the location of the newly uploaded folder into the Python path? Do I somehow use the RID for the folder? When I do a python walk for the / directory, I can't find nltk_data

As a final note, I am not an admin, so any approaches to do this have to be as a non-admin user. It seems like such a simple use case, but I guess Foundry abstracts away the file system.

Share Improve this question edited Mar 12 at 12:01 omnes_flumina asked Mar 12 at 11:51 omnes_fluminaomnes_flumina 296 bronze badges 6
  • see nltk.data.path – furas Commented Mar 12 at 12:06
  • @furas I know about that, the problem is that the path is not visible within Foundry and I am figuring out how to get that path to set nltk.data.path with – omnes_flumina Commented Mar 12 at 12:11
  • maybe nltk.data.path.append(...) ? nltk.data.path.insert(0, ...)? – furas Commented Mar 12 at 12:12
  • python - How to config nltk data directory from code? - Stack Overflow – furas Commented Mar 12 at 12:20
  • python - Change nltk.download() path directory from default \~/ntlk_data - Stack Overflow – furas Commented Mar 12 at 12:20
 |  Show 1 more comment

1 Answer 1

Reset to default 0

So if one had admin access (and as I said I don't and would like an answer as such) the best path is probably

* Configure the environment in code workbook

* Add nltk_data as a package which will have visibility. (This is the portion that has to be done by admin, making the package available)

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744754493a4591798.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信