Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nltk
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
nltk
Commits
3ca1cc68
Commit
3ca1cc68
authored
Apr 27, 2015
by
Steven Bird
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #933 from sadovnychyi/develop
Add support for Google App Engine
parents
35cbe3f5
48dbd02e
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
2 deletions
+16
-2
nltk/__init__.py
+11
-0
nltk/data.py
+1
-1
nltk/downloader.py
+4
-1
No files found.
nltk/__init__.py
View file @
3ca1cc68
...
@@ -94,6 +94,17 @@ try:
...
@@ -94,6 +94,17 @@ try:
except
ImportError
:
except
ImportError
:
pass
pass
# Override missing methods on environments where it cannot be used like GAE.
import
subprocess
if
not
hasattr
(
subprocess
,
'PIPE'
):
def
_fake_PIPE
(
*
args
,
**
kwargs
):
raise
NotImplementedError
(
'subprocess.PIPE is not supported.'
)
subprocess
.
PIPE
=
_fake_PIPE
if
not
hasattr
(
subprocess
,
'Popen'
):
def
_fake_Popen
(
*
args
,
**
kwargs
):
raise
NotImplementedError
(
'subprocess.Popen is not supported.'
)
subprocess
.
Popen
=
_fake_Popen
###########################################################
###########################################################
# TOP-LEVEL MODULES
# TOP-LEVEL MODULES
###########################################################
###########################################################
...
...
nltk/data.py
View file @
3ca1cc68
...
@@ -73,7 +73,7 @@ path = []
...
@@ -73,7 +73,7 @@ path = []
# User-specified locations:
# User-specified locations:
path
+=
[
d
for
d
in
os
.
environ
.
get
(
'NLTK_DATA'
,
str
(
''
))
.
split
(
os
.
pathsep
)
if
d
]
path
+=
[
d
for
d
in
os
.
environ
.
get
(
'NLTK_DATA'
,
str
(
''
))
.
split
(
os
.
pathsep
)
if
d
]
if
os
.
path
.
expanduser
(
'~/'
)
!=
'~/'
:
if
'APPENGINE_RUNTIME'
not
in
os
.
environ
and
os
.
path
.
expanduser
(
'~/'
)
!=
'~/'
:
path
.
append
(
os
.
path
.
expanduser
(
str
(
'~/nltk_data'
)))
path
.
append
(
os
.
path
.
expanduser
(
str
(
'~/nltk_data'
)))
if
sys
.
platform
.
startswith
(
'win'
):
if
sys
.
platform
.
startswith
(
'win'
):
...
...
nltk/downloader.py
View file @
3ca1cc68
...
@@ -924,6 +924,10 @@ class Downloader(object):
...
@@ -924,6 +924,10 @@ class Downloader(object):
permission: ``/usr/share/nltk_data``, ``/usr/local/share/nltk_data``,
permission: ``/usr/share/nltk_data``, ``/usr/local/share/nltk_data``,
``/usr/lib/nltk_data``, ``/usr/local/lib/nltk_data``, ``~/nltk_data``.
``/usr/lib/nltk_data``, ``/usr/local/lib/nltk_data``, ``~/nltk_data``.
"""
"""
# Check if we are on GAE where we cannot write into filesystem.
if
'APPENGINE_RUNTIME'
in
os
.
environ
:
return
# Check if we have sufficient permissions to install in a
# Check if we have sufficient permissions to install in a
# variety of system-wide locations.
# variety of system-wide locations.
for
nltkdir
in
nltk
.
data
.
path
:
for
nltkdir
in
nltk
.
data
.
path
:
...
@@ -2267,4 +2271,3 @@ if __name__ == '__main__':
...
@@ -2267,4 +2271,3 @@ if __name__ == '__main__':
downloader
.
download
(
download_dir
=
options
.
dir
,
downloader
.
download
(
download_dir
=
options
.
dir
,
quiet
=
options
.
quiet
,
force
=
options
.
force
,
quiet
=
options
.
quiet
,
force
=
options
.
force
,
halt_on_error
=
options
.
halt_on_error
)
halt_on_error
=
options
.
halt_on_error
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment