Skip to content

Commit

Permalink
drop python 2.5 support
Browse files Browse the repository at this point in the history
  • Loading branch information
kmike committed May 18, 2012
1 parent c06789d commit a4eea01
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 50 deletions.
13 changes: 3 additions & 10 deletions nltk/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@
Natural Language Processing with Python. O'Reilly Media Inc.
http://nltk.org/book
"""

# python2.5 compatibility
from __future__ import with_statement, print_function, absolute_import
from __future__ import print_function, absolute_import

import os

Expand Down Expand Up @@ -52,7 +50,7 @@
# Description of the toolkit, keywords, and the project's primary URL.
__longdescr__ = """\
The Natural Language Toolkit (NLTK) is a Python package for
natural language processing. NLTK requires Python 2.5 or higher."""
natural language processing. NLTK requires Python 2.6 or higher."""
__keywords__ = ['NLP', 'CL', 'natural language processing',
'computational linguistics', 'parsing', 'tagging',
'tokenizing', 'syntax', 'linguistics', 'language',
Expand All @@ -74,7 +72,6 @@
'Intended Audience :: Science/Research',
'License :: OSI Approved :: Apache Software License',
'Operating System :: OS Independent',
'Programming Language :: Python :: 2.5',
'Programming Language :: Python :: 2.6',
'Programming Language :: Python :: 2.7',
'Topic :: Scientific/Engineering',
Expand Down Expand Up @@ -111,11 +108,7 @@
from .tree import *
from .util import *
from .yamltags import *

# Modules that require Python 2.6
from sys import version_info as vi
if vi[0] == 2 and vi[1] >= 6:
from .align import *
from .align import *

# don't import contents into top-level namespace:

Expand Down
2 changes: 0 additions & 2 deletions nltk/corpus/reader/lin.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
# URL: <http://www.nltk.org/>
# For license information, see LICENSE.txt

from __future__ import with_statement

import re
from collections import defaultdict

Expand Down
2 changes: 1 addition & 1 deletion nltk/downloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
python nltk/downloader.py [-d DATADIR] [-q] [-f] [-k] PACKAGE_IDS
or with py2.5+:
or::
python -m nltk.downloader [-d DATADIR] [-q] [-f] [-k] PACKAGE_IDS
"""
Expand Down
53 changes: 20 additions & 33 deletions nltk/sem/chat80.py
Original file line number Diff line number Diff line change
Expand Up @@ -384,27 +384,23 @@ def cities2table(filename, rel_name, dbname, verbose=False, setup=False):
:param dbname: filename of persistent store
:type schema: str
"""
try:
import sqlite3
records = _str2records(filename, rel_name)
connection = sqlite3.connect(dbname)
cur = connection.cursor()
if setup:
cur.execute('''CREATE TABLE city_table
(City text, Country text, Population int)''')

table_name = "city_table"
for t in records:
cur.execute('insert into %s values (?,?,?)' % table_name, t)
if verbose:
print "inserting values into %s: " % table_name, t
connection.commit()
import sqlite3
records = _str2records(filename, rel_name)
connection = sqlite3.connect(dbname)
cur = connection.cursor()
if setup:
cur.execute('''CREATE TABLE city_table
(City text, Country text, Population int)''')

table_name = "city_table"
for t in records:
cur.execute('insert into %s values (?,?,?)' % table_name, t)
if verbose:
print "Committing update to %s" % dbname
cur.close()
except ImportError:
import warnings
warnings.warn("To run this function, first install pysqlite, or else use Python 2.5 or later.")
print "inserting values into %s: " % table_name, t
connection.commit()
if verbose:
print "Committing update to %s" % dbname
cur.close()

def sql_query(dbname, query):
"""
Expand All @@ -422,10 +418,6 @@ def sql_query(dbname, query):
connection.text_factory = sqlite3.OptimizedUnicode
cur = connection.cursor()
return cur.execute(query)
except ImportError:
import warnings
warnings.warn("To run this function, first install pysqlite, or else use Python 2.5 or later.")
raise
except ValueError:
import warnings
warnings.warn("Make sure the database file %s is installed and uncompressed." % dbname)
Expand Down Expand Up @@ -777,15 +769,10 @@ def sql_demo():
"""
Print out every row from the 'city.db' database.
"""
try:
import sqlite3
print
print "Using SQL to extract rows from 'city.db' RDB."
for row in sql_query('corpora/city_database/city.db', "SELECT * FROM city_table"):
print row
except ImportError:
import warnings
warnings.warn("To run the SQL demo, first install pysqlite, or else use Python 2.5 or later.")
print
print "Using SQL to extract rows from 'city.db' RDB."
for row in sql_query('corpora/city_database/city.db', "SELECT * FROM city_table"):
print row


if __name__ == '__main__':
Expand Down
1 change: 0 additions & 1 deletion nltk/tag/hunpos.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ class HunposTagger(TaggerI):
.. doctest::
:options: +SKIP
>>> from __future__ import with_statement # python2.5 compat
>>> with HunposTagger('english.model') as ht:
... ht.tag('What is the airspeed of an unladen swallow ?'.split())
...
Expand Down
1 change: 0 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@
'Intended Audience :: Science/Research',
'License :: OSI Approved :: Apache Software License',
'Operating System :: OS Independent',
'Programming Language :: Python :: 2.5',
'Programming Language :: Python :: 2.6',
'Programming Language :: Python :: 2.7',
'Topic :: Scientific/Engineering',
Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[tox]
envlist = py25,py26,py27,py32,pypy
envlist = py26,py27,py32,pypy

[testenv]

Expand Down
2 changes: 1 addition & 1 deletion web/install.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Installing NLTK
===============

NLTK requires Python versions 2.5-2.7.
NLTK requires Python versions 2.6-2.7.

Mac/Unix
--------
Expand Down

0 comments on commit a4eea01

Please sign in to comment.