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
1ec1680f
Commit
1ec1680f
authored
Nov 02, 2014
by
Steven Bird
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
normalise whitespace
parent
bc687466
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
60 additions
and
59 deletions
+60
-59
nltk/test/data.doctest
+1
-1
nltk/test/gluesemantics.doctest
+12
-12
nltk/test/semantics.doctest
+19
-19
nltk/test/wsd.doctest
+28
-27
No files found.
nltk/test/data.doctest
View file @
1ec1680f
...
...
@@ -91,7 +91,7 @@ to format names is specified by `nltk.data.AUTO_FORMATS`:
.cfg -> cfg
.fcfg -> fcfg
.fol -> fol
.json -> json
.json -> json
.logic -> logic
.pcfg -> pcfg
.pickle -> pickle
...
...
nltk/test/gluesemantics.doctest
View file @
1ec1680f
...
...
@@ -70,9 +70,9 @@ Test BindingDict
>>> all12.sort()
>>> print(all12)
['F: f', 'G: f', 'H: h']
>>> BindingDict([(F,f),(G,g),(H,h)]) == BindingDict({F:f, G:g, H:h})
True
>>> BindingDict([(F,f),(G,g),(H,h)]) == BindingDict({F:f, G:g, H:h})
True
>>> d4 = BindingDict({F: f})
>>> try: d4[F] = g
...
...
@@ -87,37 +87,37 @@ Test Unify
Cannot unify f with g given {}
>>> f.unify(G, BindingDict()) == BindingDict({G: f})
True
True
>>> try: f.unify(G, BindingDict({G: h}))
... except UnificationException as e: print(e)
...
Cannot unify f with G given {G: h}
>>> f.unify(G, BindingDict({G: f})) == BindingDict({G: f})
True
True
>>> f.unify(G, BindingDict({H: f})) == BindingDict({G: f, H: f})
True
True
>>> G.unify(f, BindingDict()) == BindingDict({G: f})
True
True
>>> try: G.unify(f, BindingDict({G: h}))
... except UnificationException as e: print(e)
...
Cannot unify G with f given {G: h}
>>> G.unify(f, BindingDict({G: f})) == BindingDict({G: f})
True
True
>>> G.unify(f, BindingDict({H: f})) == BindingDict({G: f, H: f})
True
True
>>> G.unify(F, BindingDict()) == BindingDict({G: F})
True
True
>>> try: G.unify(F, BindingDict({G: H}))
... except UnificationException as e: print(e)
...
Cannot unify G with F given {G: H}
>>> G.unify(F, BindingDict({G: F})) == BindingDict({G: F})
True
True
>>> G.unify(F, BindingDict({H: F})) == BindingDict({G: F, H: F})
True
True
Test Compile
...
...
nltk/test/semantics.doctest
View file @
1ec1680f
...
...
@@ -425,43 +425,43 @@ Satisfier Tests
... g.purge()
... print("Satisfiers of '%s':\n\t%s" % (p, sorted(m.satisfiers(p, 'x', g))))
Satisfiers of 'boy(x)':
['b1', 'b2']
['b1', 'b2']
Satisfiers of '(x = x)':
['b1', 'b2', 'd1', 'g1', 'g2']
['b1', 'b2', 'd1', 'g1', 'g2']
Satisfiers of '(boy(x) | girl(x))':
['b1', 'b2', 'g1', 'g2']
['b1', 'b2', 'g1', 'g2']
Satisfiers of '(boy(x) & girl(x))':
[]
[]
Satisfiers of 'love(adam,x)':
['g1']
['g1']
Satisfiers of 'love(x,adam)':
['g1', 'g2']
['g1', 'g2']
Satisfiers of '-(x = adam)':
['b2', 'd1', 'g1', 'g2']
['b2', 'd1', 'g1', 'g2']
Satisfiers of 'exists z22.love(x,z22)':
['b1', 'b2', 'g1', 'g2']
['b1', 'b2', 'g1', 'g2']
Satisfiers of 'exists y.love(y,x)':
['b1', 'g1', 'g2']
['b1', 'g1', 'g2']
Satisfiers of 'all y.(girl(y) -> love(x,y))':
[]
[]
Satisfiers of 'all y.(girl(y) -> love(y,x))':
['b1']
['b1']
Satisfiers of 'all y.(girl(y) -> (boy(x) & love(y,x)))':
['b1']
['b1']
Satisfiers of '(boy(x) & all y.(girl(y) -> love(x,y)))':
[]
[]
Satisfiers of '(boy(x) & all y.(girl(y) -> love(y,x)))':
['b1']
['b1']
Satisfiers of '(boy(x) & exists y.(girl(y) & love(y,x)))':
['b1']
['b1']
Satisfiers of '(girl(x) -> dog(x))':
['b1', 'b2', 'd1']
['b1', 'b2', 'd1']
Satisfiers of 'all y.(dog(y) -> (x = y))':
['d1']
['d1']
Satisfiers of '-exists y.love(y,x)':
['b2', 'd1']
['b2', 'd1']
Satisfiers of 'exists y.(love(adam,y) & love(y,x))':
['b1']
['b1']
Tests based on the Blackburn & Bos testsuite
...
...
nltk/test/wsd.doctest
View file @
1ec1680f
...
...
@@ -20,33 +20,34 @@ a Synset with the highest number of overlapping words between the context
sentence and different definitions from each Synset.
>>> from nltk.wsd import lesk
>>> from nltk import word_tokenize
>>> sent = word_tokenize("I went to the bank to deposit money.")
>>> word = "bank"
>>> pos = "n"
>>> print(lesk(sent, word, pos))
Synset('depository_financial_institution.n.01')
>>> from nltk import word_tokenize
>>> sent = word_tokenize("I went to the bank to deposit money.")
>>> word = "bank"
>>> pos = "n"
>>> print(lesk(sent, word, pos))
Synset('depository_financial_institution.n.01')
The definitions for "bank" are:
>>> from nltk.corpus import wordnet as wn
>>> for ss in wn.synsets('bank'):
... print(ss, ss.definition())
Synset('bank.n.01') sloping land (especially the slope beside a body of water)
Synset('depository_financial_institution.n.01') a financial institution that accepts deposits and channels the money into lending activities
Synset('bank.n.03') a long ridge or pile
Synset('bank.n.04') an arrangement of similar objects in a row or in tiers
Synset('bank.n.05') a supply or stock held in reserve for future use (especially in emergencies)
Synset('bank.n.06') the funds held by a gambling house or the dealer in some gambling games
Synset('bank.n.07') a slope in the turn of a road or track; the outside is higher than the inside in order to reduce the effects of centrifugal force
Synset('savings_bank.n.02') a container (usually with a slot in the top) for keeping money at home
Synset('bank.n.09') a building in which the business of banking transacted
Synset('bank.n.10') a flight maneuver; aircraft tips laterally about its longitudinal axis (especially in turning)
Synset('bank.v.01') tip laterally
Synset('bank.v.02') enclose with a bank
Synset('bank.v.03') do business with a bank or keep an account at a bank
Synset('bank.v.04') act as the banker in a game or in gambling
Synset('bank.v.05') be in the banking business
Synset('deposit.v.02') put into a bank account
Synset('bank.v.07') cover with ashes so to control the rate of burning
Synset('trust.v.01') have confidence or faith in
>>> from nltk.corpus import wordnet as wn
>>> for ss in wn.synsets('bank'):
... print(ss, ss.definition())
...
Synset('bank.n.01') sloping land (especially the slope beside a body of water)
Synset('depository_financial_institution.n.01') a financial institution that accepts deposits and channels the money into lending activities
Synset('bank.n.03') a long ridge or pile
Synset('bank.n.04') an arrangement of similar objects in a row or in tiers
Synset('bank.n.05') a supply or stock held in reserve for future use (especially in emergencies)
Synset('bank.n.06') the funds held by a gambling house or the dealer in some gambling games
Synset('bank.n.07') a slope in the turn of a road or track; the outside is higher than the inside in order to reduce the effects of centrifugal force
Synset('savings_bank.n.02') a container (usually with a slot in the top) for keeping money at home
Synset('bank.n.09') a building in which the business of banking transacted
Synset('bank.n.10') a flight maneuver; aircraft tips laterally about its longitudinal axis (especially in turning)
Synset('bank.v.01') tip laterally
Synset('bank.v.02') enclose with a bank
Synset('bank.v.03') do business with a bank or keep an account at a bank
Synset('bank.v.04') act as the banker in a game or in gambling
Synset('bank.v.05') be in the banking business
Synset('deposit.v.02') put into a bank account
Synset('bank.v.07') cover with ashes so to control the rate of burning
Synset('trust.v.01') have confidence or faith in
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