Skip to content

Commit

Permalink
Merge commit '565f768' into skip_broken_tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dimazest committed Sep 8, 2014
2 parents e6d2423 + 565f768 commit 511ac10
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 32 deletions.
4 changes: 2 additions & 2 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Version 3.0b1 2013-07-11
Version 3.0b1 2014-07-11
* Added SentiWordNet corpus and corpus reader
* Fixed support for 10-column dependency file format
* Changed Tree initialization to use fromstring
Expand All @@ -16,7 +16,7 @@ Roberts, Alex Rudnick, Nathan Schneider, Geraldine Sim Wei Ying, Lynn
Soe, Liling Tan, Louis Tiao, Marcus Uneson, Yu Usami, Steven Xu, Zhe
Wang, Chuck Wooters, isnowfy, onesandzeros, pquentin, wvanlint

Version 3.0a4 2013-05-25
Version 3.0a4 2014-05-25
* IBM Models 1-3, BLEU, Gale-Church aligner
* Lesk algorithm for WSD
* Open Multilingual WordNet
Expand Down
4 changes: 2 additions & 2 deletions nltk/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -666,7 +666,7 @@ def retrieve(resource_url, filename=None, verbose=True):
'fol': "A list of first order logic expressions, parsed with "
"nltk.sem.logic.Expression.fromstring.",
'logic': "A list of first order logic expressions, parsed by "
"nltk.sem.logic._LogicParser. Requires an additional logic_parser "
"nltk.sem.logic.LogicParser. Requires an additional logic_parser "
"parameter",
'val': "A semantic valuation, parsed by nltk.sem.parse_valuation().",
'raw': "The raw (byte string) contents of a file.",
Expand Down Expand Up @@ -813,7 +813,7 @@ def load(resource_url, format='auto', cache=True, verbose=False,
fstruct_reader=fstruct_reader, encoding=encoding)
elif format == 'fol':
resource_val = nltk.sem.parse_logic(
string_data, logic_parser=nltk.sem.logic._LogicParser(),
string_data, logic_parser=nltk.sem.logic.LogicParser(),
encoding=encoding)
elif format == 'logic':
resource_val = nltk.sem.parse_logic(
Expand Down
4 changes: 2 additions & 2 deletions nltk/featstruct.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@

from nltk.internals import read_str, raise_unorderable_types
from nltk.sem.logic import (Variable, Expression, SubstituteBindingsI,
_LogicParser, LogicalExpressionException)
LogicParser, LogicalExpressionException)
from nltk.compat import (string_types, integer_types, total_ordering,
python_2_unicode_compatible, unicode_repr)

Expand Down Expand Up @@ -1958,7 +1958,7 @@ def __init__(self, features=(SLASH, TYPE), fdict_class=FeatStruct,
self._features_with_defaults = [feature for feature in features
if feature.default is not None]
if logic_parser is None:
logic_parser = _LogicParser()
logic_parser = LogicParser()
self._logic_parser = logic_parser

def fromstring(self, s, fstruct=None):
Expand Down
12 changes: 6 additions & 6 deletions nltk/sem/boxer.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
UnexpectedTokenException, Variable)

from nltk.sem.drt import (DRS, DrtApplicationExpression, DrtEqualityExpression,
DrtNegatedExpression, DrtOrExpression, _DrtParser,
DrtNegatedExpression, DrtOrExpression, DrtParser,
DrtProposition, DrtTokens, DrtVariableExpression)

from nltk.compat import python_2_unicode_compatible
Expand Down Expand Up @@ -262,21 +262,21 @@ def _parse_drs(self, drs_string, discourse_id, use_disc_id):
return BoxerOutputDrsParser([None,discourse_id][use_disc_id]).parse(drs_string)


class BoxerOutputDrsParser(_DrtParser):
class BoxerOutputDrsParser(DrtParser):
def __init__(self, discourse_id=None):
"""
This class is used to parse the Prolog DRS output from Boxer into a
hierarchy of python objects.
"""
_DrtParser.__init__(self)
DrtParser.__init__(self)
self.discourse_id = discourse_id
self.sentence_id_offset = None
self.quote_chars = [("'", "'", "\\", False)]
self._label_counter = None

def parse(self, data, signature=None):
self._label_counter = Counter(-1)
return _DrtParser.parse(self, data, signature)
return DrtParser.parse(self, data, signature)

def get_all_symbols(self):
return ['(', ')', ',', '[', ']',':']
Expand Down Expand Up @@ -615,12 +615,12 @@ def _sent_and_word_indices(self, indices):
return [(None, word_indices)]


class BoxerDrsParser(_DrtParser):
class BoxerDrsParser(DrtParser):
"""
Reparse the str form of subclasses of ``AbstractBoxerDrs``
"""
def __init__(self, discourse_id=None):
_DrtParser.__init__(self)
DrtParser.__init__(self)
self.discourse_id = discourse_id

def get_all_symbols(self):
Expand Down
8 changes: 4 additions & 4 deletions nltk/sem/drt.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
EventVariableExpression, ExistsExpression, Expression,
FunctionVariableExpression, ImpExpression,
IndividualVariableExpression, LambdaExpression, Tokens,
_LogicParser, NegatedExpression, OrExpression, Variable,
LogicParser, NegatedExpression, OrExpression, Variable,
is_eventvar, is_funcvar, is_indvar, unique_variable)

# Import Tkinter-based modules if they are available
Expand Down Expand Up @@ -47,10 +47,10 @@ class DrtTokens(Tokens):
TOKENS = Tokens.TOKENS + [DRS] + PUNCT


class _DrtParser(_LogicParser):
class DrtParser(LogicParser):
"""A lambda calculus expression parser."""
def __init__(self):
_LogicParser.__init__(self)
LogicParser.__init__(self)

self.operator_precedence = dict(
[(x,1) for x in DrtTokens.LAMBDA_LIST] + \
Expand Down Expand Up @@ -177,7 +177,7 @@ class DrtExpression(object):
Expression extends.
"""

_drt_parser = _DrtParser()
_drt_parser = DrtParser()

@classmethod
def fromstring(cls, s):
Expand Down
8 changes: 4 additions & 4 deletions nltk/sem/linearlogic.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

from nltk.internals import Counter
from nltk.compat import string_types, python_2_unicode_compatible
from nltk.sem.logic import _LogicParser, APP
from nltk.sem.logic import LogicParser, APP

_counter = Counter()

Expand All @@ -24,10 +24,10 @@ class Tokens(object):
PUNCT = [OPEN, CLOSE]
TOKENS = PUNCT + [IMP]

class _LinearLogicParser(_LogicParser):
class LinearLogicParser(LogicParser):
"""A linear logic expression parser."""
def __init__(self):
_LogicParser.__init__(self)
LogicParser.__init__(self)

self.operator_precedence = {APP: 1, Tokens.IMP: 2, None: 3}
self.right_associated_operations += [Tokens.IMP]
Expand Down Expand Up @@ -73,7 +73,7 @@ def make_VariableExpression(self, name):
@python_2_unicode_compatible
class Expression(object):

_linear_logic_parser = _LinearLogicParser()
_linear_logic_parser = LinearLogicParser()

@classmethod
def fromstring(cls, s):
Expand Down
16 changes: 10 additions & 6 deletions nltk/sem/logic.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def binding_ops():


@python_2_unicode_compatible
class _LogicParser(object):
class LogicParser(object):
"""A lambda calculus expression parser."""

def __init__(self, type_check=False):
Expand Down Expand Up @@ -532,7 +532,7 @@ def parse_logic(s, logic_parser=None, encoding=None):
:param s: the contents of the file
:type s: str
:param logic_parser: The parser to be used to parse the logical expression
:type logic_parser: _LogicParser
:type logic_parser: LogicParser
:param encoding: the encoding of the input string, if it is binary
:type encoding: str
:return: a list of parsed formulas.
Expand All @@ -541,7 +541,7 @@ def parse_logic(s, logic_parser=None, encoding=None):
if encoding is not None:
s = s.decode(encoding)
if logic_parser is None:
logic_parser = _LogicParser()
logic_parser = LogicParser()

statements = []
for linenum, line in enumerate(s.splitlines()):
Expand Down Expand Up @@ -864,11 +864,15 @@ def variables(self):
class Expression(SubstituteBindingsI):
"""This is the base abstract object for all logical expressions"""

_logic_parser = _LogicParser()
_logic_parser = LogicParser()
_type_checking_logic_parser = LogicParser(type_check=True)

@classmethod
def fromstring(cls, s):
return cls._logic_parser.parse(s)
def fromstring(cls, s, type_check=False):
if type_check:
return cls._type_checking_logic_parser.parse(s)
else:
return cls._logic_parser.parse(s)

def __call__(self, other, *additional):
accum = self.applyto(other)
Expand Down
12 changes: 6 additions & 6 deletions web/news.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ NLTK 3.0b1 released : July 2014
FrameNet, SentiWordNet, universal tagset, misc efficiency improvements and bugfixes
Several API changes, see https://github.com/nltk/nltk/wiki/Porting-your-code-to-NLTK-3.0
For full details see:
https://raw.github.com/nltk/nltk/master/ChangeLog
https://github.com/nltk/nltk/blob/develop/ChangeLog

NLTK 3.0a4 released : June 2014
FrameNet, universal tagset, misc efficiency improvements and bugfixes
Several API changes, see https://github.com/nltk/nltk/wiki/Porting-your-code-to-NLTK-3.0
For full details see:
https://raw.github.com/nltk/nltk/master/ChangeLog
https://github.com/nltk/nltk/blob/develop/ChangeLog
http://nltk.org/nltk3-alpha/

NLTK Book Updates : October 2013
Expand All @@ -24,7 +24,7 @@ NLTK Book Updates : October 2013

NLTK 3.0a2 released : July 2013
Misc efficiency improvements and bugfixes; for details see
https://raw.github.com/nltk/nltk/master/ChangeLog
https://github.com/nltk/nltk/blob/develop/ChangeLog
http://nltk.org/nltk3-alpha/

NLTK 3.0a1 released : February 2013
Expand All @@ -46,13 +46,13 @@ NLTK 2.0.4 released : November 2012
Minor fix to remove numpy dependency.

NLTK 2.0.3 released : September 2012
This release contains minor improvements and bugfixes. This is the final release compatible with Python 2.5. For details see https://raw.github.com/nltk/nltk/master/ChangeLog
This release contains minor improvements and bugfixes. This is the final release compatible with Python 2.5. For details see https://github.com/nltk/nltk/blob/develop/ChangeLog

NLTK 2.0.2 released : July 2012
This release contains minor improvements and bugfixes. For details see https://raw.github.com/nltk/nltk/master/ChangeLog
This release contains minor improvements and bugfixes. For details see https://github.com/nltk/nltk/blob/develop/ChangeLog

NLTK 2.0.1 released : May 2012
The final release of NLTK 2. For details see https://raw.github.com/nltk/nltk/master/ChangeLog
The final release of NLTK 2. For details see https://github.com/nltk/nltk/blob/develop/ChangeLog

NLTK 2.0.1rc4 released : February 2012
The fourth release candidate for NLTK 2.
Expand Down

0 comments on commit 511ac10

Please sign in to comment.