Skip to content

Commit 168671e

Browse files
authored
Merge pull request #12 from JuliaText/ox/oseven
Update to 0.7
2 parents ee4a0c3 + b6d8761 commit 168671e

18 files changed

+178
-189
lines changed

.travis.yml

+3-10
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,15 @@ os:
44
- linux
55
- osx
66
julia:
7-
- 0.6
7+
- 0.7
8+
- 1.0
89
- nightly
910
notifications:
1011
email: false
11-
git:
12-
depth: 99999999
1312

1413
matrix:
1514
allow_failures:
1615
- julia: nightly
1716

18-
19-
script:
20-
- if [[ -a .git/shallow ]]; then git fetch --unshallow; fi
21-
script:
22-
- julia -e 'Pkg.clone(pwd()); Pkg.build("WordNet")'
23-
- julia -e 'Pkg.test("WordNet"; coverage=true)'
2417
after_success:
25-
- julia -e 'cd(Pkg.dir("WordNet")); Pkg.add("Coverage"); using Coverage; Coveralls.submit(Coveralls.process_folder())'
18+
- julia -e 'using Pkg; Pkg.add("Coverage"); using Coverage; Coveralls.submit(Coveralls.process_folder())'

README.md

+23-23
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
[![Coverage Status](https://coveralls.io/repos/jbn/WordNet.jl/badge.svg?branch=master&service=github)](https://coveralls.io/github/jbn/WordNet.jl?branch=master)
55
[![Build status](https://ci.appveyor.com/api/projects/status/bpqbdf24thkp6ytw/branch/master?svg=true)](https://ci.appveyor.com/project/jbn/wordnet-jl/branch/master)
66

7-
A Julia package for using Princeton's [WordNet](https://wordnet.princeton.edu/)®, heavily inspired by [Douches](https://github.com/doches)' [rwordnet](https://github.com/doches/rwordnet).
7+
A Julia package for using Princeton's [WordNet](https://wordnet.princeton.edu/)®, heavily inspired by [Doches](https://github.com/doches)' [rwordnet](https://github.com/doches/rwordnet).
88

99
## Simple Demo
1010

@@ -22,34 +22,34 @@ lemma = db['a', "glad"]
2222
```julia
2323
ss = synsets(db, lemma)
2424
```
25-
> 4-element Array{WordNet.Synset,1}:
26-
> (a) glad (showing or causing joy and pleasure; especially made happy; "glad you are here"; "glad that they succeeded"; "gave a glad shout"; "a glad smile"; "heard the glad news"; "a glad occasion")
27-
> (s) happy, glad (eagerly disposed to act or to be of service; "glad to help")
28-
> (s) glad (feeling happy appreciation; "glad of the fire's warmth")
29-
> (s) glad, beaming (cheerful and bright; "a beaming smile"; "a glad May morning")
25+
> 4-element Array{WordNet.Synset,1}:
26+
> (a) glad (showing or causing joy and pleasure; especially made happy; "glad you are here"; "glad that they succeeded"; "gave a glad shout"; "a glad smile"; "heard the glad news"; "a glad occasion")
27+
> (s) happy, glad (eagerly disposed to act or to be of service; "glad to help")
28+
> (s) glad (feeling happy appreciation; "glad of the fire's warmth")
29+
> (s) glad, beaming (cheerful and bright; "a beaming smile"; "a glad May morning")
3030
3131
```julia
3232
antonyms(db, ss[1])
3333
```
34-
> 1-element Array{WordNet.Synset,1}:
34+
> 1-element Array{WordNet.Synset,1}:
3535
> (a) sad (experiencing or showing sorrow or unhappiness; "feeling sad because his dog had died"; "Better by far that you should forget and smile / Than that you should remember and be sad"- Christina Rossetti)
3636
3737
```julia
3838
expanded_hypernyms(db, synsets(db, db['n', "DOG"])[1])
3939
```
40-
> 13-element Array{WordNet.Synset,1}:
41-
> (n) canine, canid (any of various fissiped mammals with nonretractile claws and typically long muzzles)
42-
> (n) carnivore (a terrestrial or aquatic flesh-eating mammal; "terrestrial carnivores have four or five clawed digits on each limb")
43-
> (n) eutherian mammal, placental, placental mammal, eutherian (mammals having a placenta; all mammals except monotremes and marsupials)
44-
> (n) mammalian, mammal (any warm-blooded vertebrate having the skin more or less covered with hair; young are born alive except for the small subclass of monotremes and nourished with milk)
45-
> (n) vertebrate, craniate (animals having a bony or cartilaginous skeleton with a segmented spinal column and a large brain enclosed in a skull or cranium)
46-
> (n) chordate (any animal of the phylum Chordata having a notochord or spinal column)
47-
> (n) animal, creature, animate being, brute, beast, fauna (a living organism characterized by voluntary movement)
48-
> (n) organism, being (a living thing that has (or can develop) the ability to act or function independently)
49-
> (n) living thing, animate thing (a living (or once living) entity)
50-
> (n) unit, whole (an assemblage of parts that is regarded as a single entity; "how big is that part compared to the whole?"; "the team is a unit")
51-
> (n) physical object, object (a tangible and visible entity; an entity that can cast a shadow; "it was full of rackets, balls and other objects")
52-
> (n) physical entity (an entity that has physical existence)
40+
> 13-element Array{WordNet.Synset,1}:
41+
> (n) canine, canid (any of various fissiped mammals with nonretractile claws and typically long muzzles)
42+
> (n) carnivore (a terrestrial or aquatic flesh-eating mammal; "terrestrial carnivores have four or five clawed digits on each limb")
43+
> (n) eutherian mammal, placental, placental mammal, eutherian (mammals having a placenta; all mammals except monotremes and marsupials)
44+
> (n) mammalian, mammal (any warm-blooded vertebrate having the skin more or less covered with hair; young are born alive except for the small subclass of monotremes and nourished with milk)
45+
> (n) vertebrate, craniate (animals having a bony or cartilaginous skeleton with a segmented spinal column and a large brain enclosed in a skull or cranium)
46+
> (n) chordate (any animal of the phylum Chordata having a notochord or spinal column)
47+
> (n) animal, creature, animate being, brute, beast, fauna (a living organism characterized by voluntary movement)
48+
> (n) organism, being (a living thing that has (or can develop) the ability to act or function independently)
49+
> (n) living thing, animate thing (a living (or once living) entity)
50+
> (n) unit, whole (an assemblage of parts that is regarded as a single entity; "how big is that part compared to the whole?"; "the team is a unit")
51+
> (n) physical object, object (a tangible and visible entity; an entity that can cast a shadow; "it was full of rackets, balls and other objects")
52+
> (n) physical entity (an entity that has physical existence)
5353
> (n) entity (that which is perceived or known or inferred to have its own distinct existence (living or nonliving))
5454
5555
```julia
@@ -72,7 +72,7 @@ sensekeys(db, db['n', "cat"])
7272
7373

7474
## Design consideration
75-
This package loads all of WordNet into memory. It's not terribly expensive, but it may not be suitable for all developers.
75+
This package loads all of WordNet into memory. It's not terribly expensive, but it may not be suitable for all developers.
7676

7777
## Wordnet Data
7878
The constructor `DB` can optionally take a path to a WordNet directory, containing a `dict` folder.
@@ -81,5 +81,5 @@ If you do not specify such a path, WordNet 3.0 will automatically be downloaded
8181
It will only be downloaded once.
8282
See [DataDeps.jl's readme for more information](https://github.com/oxinabox/DataDeps.jl).
8383

84-
> George A. Miller (1995). WordNet: A Lexical Database for English.
85-
> Communications of the ACM Vol. 38, No. 11: 39-41.
84+
> George A. Miller (1995). WordNet: A Lexical Database for English.
85+
> Communications of the ACM Vol. 38, No. 11: 39-41.

REQUIRE

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
julia 0.6
2-
Compat
3-
FactCheck
4-
DataDeps 0.3
1+
julia 0.7
2+
DataDeps 0.5
3+

appveyor.yml

+21-22
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
environment:
22
matrix:
3-
- JULIA_URL: "https://julialang-s3.julialang.org/bin/winnt/x86/0.6/julia-0.6-latest-win32.exe"
4-
- JULIA_URL: "https://julialang-s3.julialang.org/bin/winnt/x64/0.6/julia-0.6-latest-win64.exe"
5-
- JULIA_URL: "https://julialangnightlies-s3.julialang.org/bin/winnt/x86/julia-latest-win32.exe"
6-
- JULIA_URL: "https://julialangnightlies-s3.julialang.org/bin/winnt/x64/julia-latest-win64.exe"
3+
- julia_version: 0.7
4+
- julia_version: 1
5+
- julia_version: nightly
76

8-
## uncomment the following lines to allow failures on nightly julia
9-
## (tests will run but not make your overall status red)
7+
platform:
8+
- x86 # 32-bit
9+
- x64 # 64-bit
10+
11+
# Uncomment the following lines to allow failures on nightly julia
12+
# (tests will run but not make your overall status red)
1013
matrix:
1114
allow_failures:
12-
- JULIA_URL: "https://julialangnightlies-s3.julialang.org/bin/winnt/x86/julia-latest-win32.exe"
13-
- JULIA_URL: "https://julialangnightlies-s3.julialang.org/bin/winnt/x64/julia-latest-win64.exe"
14-
15-
15+
- julia_version: nightly
1616

1717
branches:
1818
only:
@@ -26,19 +26,18 @@ notifications:
2626
on_build_status_changed: false
2727

2828
install:
29-
- ps: "[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12"
30-
# Download most recent Julia Windows binary
31-
- ps: (new-object net.webclient).DownloadFile(
32-
$env:JULIA_URL,
33-
"C:\projects\julia-binary.exe")
34-
# Run installer silently, output to C:\projects\julia
35-
- C:\projects\julia-binary.exe /S /D=C:\projects\julia
29+
- ps: iex ((new-object net.webclient).DownloadString("https://raw.githubusercontent.com/JuliaCI/Appveyor.jl/version-1/bin/install.ps1"))
3630

3731
build_script:
38-
# Need to convert from shallow to complete for Pkg.clone to work
39-
- IF EXIST .git\shallow (git fetch --unshallow)
40-
- C:\projects\julia\bin\julia -e "versioninfo();
41-
Pkg.clone(pwd(), \"WordNet\"); Pkg.build(\"WordNet\")"
32+
- echo "%JL_BUILD_SCRIPT%"
33+
- C:\julia\bin\julia -e "%JL_BUILD_SCRIPT%"
4234

4335
test_script:
44-
- C:\projects\julia\bin\julia --check-bounds=yes -e "Pkg.test(\"WordNet\")"
36+
- echo "%JL_TEST_SCRIPT%"
37+
- C:\julia\bin\julia -e "%JL_TEST_SCRIPT%"
38+
39+
# # Uncomment to support code coverage upload. Should only be enabled for packages
40+
# # which would have coverage gaps without running on Windows
41+
# on_success:
42+
# - echo "%JL_CODECOV_SCRIPT%"
43+
# - C:\julia\bin\julia -e "%JL_CODECOV_SCRIPT%"

src/WordNet.jl

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
module WordNet
22

3-
using Compat
43
using DataDeps
54

65
include("init.jl")

src/constants.jl

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
SYNSET_TYPES = @compat Dict{Char, AbstractString}(
1+
SYNSET_TYPES = Dict{Char, String}(
22
'n' => "noun", 'v' => "verb", 'a' => "adj", 'r' => "adv"
33
)
44

5-
NOUN_POINTERS = @compat Dict{AbstractString, AbstractString}(
5+
NOUN_POINTERS = Dict{String, String}(
66
"-c" => "Member of this domain - TOPIC",
77
"+" => "Derivationally related form",
88
"%p" => "Part meronym",
@@ -23,7 +23,7 @@ NOUN_POINTERS = @compat Dict{AbstractString, AbstractString}(
2323
"@i" => "Instance Hypernym",
2424
"#m" => "Member holonym"
2525
)
26-
VERB_POINTERS = @compat Dict{AbstractString, AbstractString}(
26+
VERB_POINTERS = Dict{String, String}(
2727
"+" => "Derivationally related form",
2828
"@" => "Hypernym",
2929
";r" => "Domain of synset - REGION",
@@ -36,7 +36,7 @@ VERB_POINTERS = @compat Dict{AbstractString, AbstractString}(
3636
"*" => "Entailment"
3737
)
3838

39-
ADJECTIVE_POINTERS = @compat Dict{AbstractString, AbstractString}(
39+
ADJECTIVE_POINTERS = Dict{String, String}(
4040
";r" => "Domain of synset - REGION",
4141
"!" => "Antonym",
4242
"\\" => "Pertainym (pertains to noun)",
@@ -46,7 +46,7 @@ ADJECTIVE_POINTERS = @compat Dict{AbstractString, AbstractString}(
4646
";c" => "Domain of synset - TOPIC"
4747
)
4848

49-
ADVERB_POINTERS = @compat Dict{AbstractString, AbstractString}(
49+
ADVERB_POINTERS = Dict{String, String}(
5050
";r" => "Domain of synset - REGION",
5151
"!" => "Antonym",
5252
";u" => "Domain of synset - USAGE",

src/db.jl

+13-13
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
export DB
22

3-
immutable DB
4-
lemmas::Dict{Char, Dict{AbstractString, Lemma}}
3+
struct DB
4+
lemmas::Dict{Char, Dict{String, Lemma}}
55
synsets::Dict{Char, Dict{Int, Synset}}
6-
sensekeys::Dict{Tuple{Int, AbstractString}, AbstractString}
6+
sensekeys::Dict{Tuple{Int, String}, String}
77
end
88

99
function DB(base_dir::AbstractString=datadep"WordNet 3.0")
@@ -23,19 +23,19 @@ end
2323
Base.getindex(db::DB, word::AbstractString, pos::Char) = db[pos, word]
2424

2525
function load_lemmas(base_dir)
26-
lemmas = Dict{Char, Dict{AbstractString, Lemma}}()
26+
lemmas = Dict{Char, Dict{String, Lemma}}()
2727

2828
for pos in ['n', 'v', 'a', 'r']
29-
d = Dict{AbstractString, Lemma}()
30-
29+
d = Dict{String, Lemma}()
30+
3131
open(path_to_index_file(base_dir, pos)) do f
3232
for (i, line) in enumerate(eachline(f))
3333
i > 29 || continue # Skip Copyright.
34-
word = line[1:(search(line, ' ')-1)]
34+
word = line[1:(findfirst(isequal(' '), line) - 1)]
3535
d[word] = Lemma(line, i-29)
3636
end
3737
end
38-
38+
3939
lemmas[pos] = d
4040
end
4141

@@ -44,7 +44,7 @@ end
4444

4545
function load_synsets(base_dir)
4646
synsets = Dict{Char, Dict{Int, Synset}}()
47-
47+
4848
for pos in ('n', 'v', 'a', 'r')
4949
d = Dict{Int, Synset}()
5050

@@ -58,15 +58,15 @@ function load_synsets(base_dir)
5858

5959
synsets[pos] = d
6060
end
61-
61+
6262
synsets
6363
end
6464

6565

6666
function load_sensekeys(basedir)
6767
path=joinpath(basedir, "dict", "index.sense")
68-
sensekeys = Dict{Tuple{Int64, AbstractString}, AbstractString}()
69-
68+
sensekeys = Dict{Tuple{Int64, String}, String}()
69+
7070
for line in eachline(path)
7171
full_key, offset_str, sense_num_str, tagcount_str = split(line)
7272
lemma_name = first(split(full_key, '%'))
@@ -75,7 +75,7 @@ function load_sensekeys(basedir)
7575
@assert(!haskey(sensekeys, index))
7676
sensekeys[index] = full_key
7777
end
78-
78+
7979
sensekeys
8080
end
8181

src/lemma.jl

+10-10
Original file line numberDiff line numberDiff line change
@@ -2,29 +2,29 @@ export Lemma
22

33
const SPACE = ' '
44

5-
immutable Lemma
6-
word::AbstractString
5+
struct Lemma
6+
word::String
77
pos::Char
88
tagsense_count::Int
99
synset_offsets::Vector{Int}
1010
id::Int
11-
pointer_syms::Vector{AbstractString}
11+
pointer_syms::Vector{String}
1212
end
1313

1414
function Lemma(lexicon_line, id)
1515
parts = split(lexicon_line, SPACE)
16-
17-
word = shift!(parts)
18-
pos = shift!(parts)[1]
19-
synset_count = parse(Int, shift!(parts))
2016

21-
n_syms = parse(Int, shift!(parts))
17+
word = popfirst!(parts)
18+
pos = popfirst!(parts)[1]
19+
synset_count = parse(Int, popfirst!(parts))
20+
21+
n_syms = parse(Int, popfirst!(parts))
2222
pointer_syms = [s for s in parts[1:n_syms]]
2323
parts = parts[n_syms+2:end]
2424

25-
tagsense_count = parse(Int, shift!(parts))
25+
tagsense_count = parse(Int, popfirst!(parts))
2626
synset_offsets = [parse(Int, c) for c in parts[1:synset_count]]
27-
27+
2828
Lemma(word, pos, tagsense_count, synset_offsets, id, pointer_syms)
2929
end
3030

src/operations.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ hypernyms(db::DB, synset::Synset) = get(relation(db, synset, HYPERNYM), 1, ∅)
1414
hyponyms(db::DB, synset::Synset) = relation(db, synset, HYPONYM)
1515

1616
function expanded_hypernyms(db::DB, synset::Synset)
17-
path = @compat Vector{Synset}()
17+
path = Vector{Synset}()
1818

1919
node = hypernyms(db, synset)
2020
while !is_nothing(node)

src/pointer.jl

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
immutable Pointer
2-
sym::AbstractString
1+
struct Pointer
2+
sym::String
33
offset::UInt32
44
pos::Char
5-
source::AbstractString
6-
target::AbstractString
5+
source::String
6+
target::String
77
end
88

99
Pointer(sym, offset, pos, source) = Pointer(

0 commit comments

Comments
 (0)