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
679680d3
Commit
679680d3
authored
Mar 10, 2014
by
Steven Bird
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #642 from jskda/pull_request.unit_test_fixes
Pull request.unit test fixes
parents
7cc64b2f
ef4c50b0
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
10 deletions
+10
-10
nltk/tag/__init__.py
+1
-1
nltk/test/classify.doctest
+9
-9
No files found.
nltk/tag/__init__.py
View file @
679680d3
...
@@ -53,7 +53,7 @@ of ``None``.
...
@@ -53,7 +53,7 @@ of ``None``.
We evaluate a tagger on data that was not seen during training:
We evaluate a tagger on data that was not seen during training:
>>> tagger.evaluate(brown.tagged_sents(categories='news')[500:600])
>>> tagger.evaluate(brown.tagged_sents(categories='news')[500:600])
0.73
4
...
0.73...
For more information, please consult chapter 5 of the NLTK Book.
For more information, please consult chapter 5 of the NLTK Book.
"""
"""
...
...
nltk/test/classify.doctest
View file @
679680d3
...
@@ -13,11 +13,11 @@ implement the `ClassifyI` interface:
...
@@ -13,11 +13,11 @@ implement the `ClassifyI` interface:
>>> import nltk
>>> import nltk
>>> nltk.usage(nltk.classify.ClassifierI)
>>> nltk.usage(nltk.classify.ClassifierI)
ClassifierI supports the following operations:
ClassifierI supports the following operations:
- self.batch_classify(featuresets)
- self.batch_prob_classify(featuresets)
- self.classify(featureset)
- self.classify(featureset)
- self.classify_many(featuresets)
- self.labels()
- self.labels()
- self.prob_classify(featureset)
- self.prob_classify(featureset)
- self.prob_classify_many(featuresets)
NLTK defines several classifier classes:
NLTK defines several classifier classes:
...
@@ -62,9 +62,9 @@ Test the Naive Bayes classifier:
...
@@ -62,9 +62,9 @@ Test the Naive Bayes classifier:
>>> classifier = nltk.classify.NaiveBayesClassifier.train(train)
>>> classifier = nltk.classify.NaiveBayesClassifier.train(train)
>>> sorted(classifier.labels())
>>> sorted(classifier.labels())
['x', 'y']
['x', 'y']
>>> classifier.
batch_classif
y(test)
>>> classifier.
classify_man
y(test)
['y', 'x', 'y', 'x']
['y', 'x', 'y', 'x']
>>> for pdist in classifier.
batch_prob_classif
y(test):
>>> for pdist in classifier.
prob_classify_man
y(test):
... print('%.4f %.4f' % (pdist.prob('x'), pdist.prob('y')))
... print('%.4f %.4f' % (pdist.prob('x'), pdist.prob('y')))
0.3104 0.6896
0.3104 0.6896
0.5746 0.4254
0.5746 0.4254
...
@@ -92,9 +92,9 @@ Test the Decision Tree classifier:
...
@@ -92,9 +92,9 @@ Test the Decision Tree classifier:
a=1? ................................................ y
a=1? ................................................ y
c=1? .................................................. y
c=1? .................................................. y
<BLANKLINE>
<BLANKLINE>
>>> classifier.
batch_classif
y(test)
>>> classifier.
classify_man
y(test)
['y', 'y', 'y', 'x']
['y', 'y', 'y', 'x']
>>> for pdist in classifier.
batch_prob_classif
y(test):
>>> for pdist in classifier.
prob_classify_man
y(test):
... print('%.4f %.4f' % (pdist.prob('x'), pdist.prob('y')))
... print('%.4f %.4f' % (pdist.prob('x'), pdist.prob('y')))
Traceback (most recent call last):
Traceback (most recent call last):
. . .
. . .
...
@@ -113,10 +113,10 @@ Test SklearnClassifier, which requires the scikit-learn package.
...
@@ -113,10 +113,10 @@ Test SklearnClassifier, which requires the scikit-learn package.
>>> classif = SklearnClassifier(BernoulliNB()).train(train_data)
>>> classif = SklearnClassifier(BernoulliNB()).train(train_data)
>>> test_data = [{"a": 3, "b": 2, "c": 1},
>>> test_data = [{"a": 3, "b": 2, "c": 1},
... {"a": 0, "b": 3, "c": 7}]
... {"a": 0, "b": 3, "c": 7}]
>>> classif.
batch_classif
y(test_data)
>>> classif.
classify_man
y(test_data)
['ham', 'spam']
['ham', 'spam']
>>> classif = SklearnClassifier(SVC(), sparse=False).train(train_data)
>>> classif = SklearnClassifier(SVC(), sparse=False).train(train_data)
>>> classif.
batch_classif
y(test_data)
>>> classif.
classify_man
y(test_data)
['ham', 'spam']
['ham', 'spam']
Test the Maximum Entropy classifier training algorithms; they should all
Test the Maximum Entropy classifier training algorithms; they should all
...
@@ -179,7 +179,7 @@ Regression tests for TypedMaxentFeatureEncoding
...
@@ -179,7 +179,7 @@ Regression tests for TypedMaxentFeatureEncoding
>>> classifier = maxent.MaxentClassifier.train(
>>> classifier = maxent.MaxentClassifier.train(
... train, bernoulli=False, encoding=encoding, trace=0)
... train, bernoulli=False, encoding=encoding, trace=0)
>>> classifier.
batch_classif
y(test)
>>> classifier.
classify_man
y(test)
['y', 'x']
['y', 'x']
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