Skip to content

Commit 2c5a0c3

Browse files
committed
Fix part of speech lookup for similar adjectives
1 parent 56659be commit 2c5a0c3

File tree

4 files changed

+72
-3
lines changed

4 files changed

+72
-3
lines changed

src/operations.jl

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ synsets(db::DB, lemma::Lemma) = map(lemma.synset_offsets) do offset
55
end
66

77
relation(db::DB, synset::Synset, pointer_sym) = map(
8-
ptr -> db.synsets[synset.synset_type][ptr.offset],
8+
ptr -> db.synsets[ptr.pos][ptr.offset],
99
filter(ptr -> ptr.sym == pointer_sym, synset.pointers)
1010
)
1111

@@ -22,12 +22,12 @@ function hypernyms(db::DB, synset::Synset)
2222
end
2323
function expanded_hypernyms(db::DB, synset::Synset)
2424
path = Vector{Synset}()
25-
25+
2626
node = hypernyms(db, synset)
2727
while !is_nothing(node)
2828
push!(path, node)
2929
node = hypernyms(db, node)
3030
end
31-
31+
3232
path
3333
end

test/mock_db/dict/data.adj

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
1 This software and database is being provided to you, the LICENSEE, by
2+
2 Princeton University under the following license. By obtaining, using
3+
3 and/or copying this software and database, you agree that you have
4+
4 read, understood, and will comply with these terms and conditions.:
5+
5
6+
6 Permission to use, copy, modify and distribute this software and
7+
7 database and its documentation for any purpose and without fee or
8+
8 royalty is hereby granted, provided that you agree to comply with
9+
9 the following copyright notice and statements, including the disclaimer,
10+
10 and that the same appear on ALL copies of the software, database and
11+
11 documentation, including modifications that you make for internal
12+
12 use or for distribution.
13+
13
14+
14 WordNet 3.0 Copyright 2006 by Princeton University. All rights reserved.
15+
15
16+
16 THIS SOFTWARE AND DATABASE IS PROVIDED "AS IS" AND PRINCETON
17+
17 UNIVERSITY MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR
18+
18 IMPLIED. BY WAY OF EXAMPLE, BUT NOT LIMITATION, PRINCETON
19+
19 UNIVERSITY MAKES NO REPRESENTATIONS OR WARRANTIES OF MERCHANT-
20+
20 ABILITY OR FITNESS FOR ANY PARTICULAR PURPOSE OR THAT THE USE
21+
21 OF THE LICENSED SOFTWARE, DATABASE OR DOCUMENTATION WILL NOT
22+
22 INFRINGE ANY THIRD PARTY PATENTS, COPYRIGHTS, TRADEMARKS OR
23+
23 OTHER RIGHTS.
24+
24
25+
25 The name of Princeton University or Princeton may not be used in
26+
26 advertising or publicity pertaining to distribution of the software
27+
27 and/or database. Title to copyright in this software, database and
28+
28 any associated documentation shall at all times remain with
29+
29 Princeton University and LICENSEE agrees to preserve same.
30+
00124077 00 a 01 aquatic 0 001 & 00124353 a 0000 | operating or living or growing in water; "boats are aquatic vehicles"; "water lilies are aquatic plants"; "fish are aquatic animals"
31+
00124353 00 s 01 marine 0 001 & 00124077 a 0000 | native to or inhabiting the sea; "marine plants and animals such as seaweed and whales"

test/mock_db/dict/index.adj

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
1 This software and database is being provided to you, the LICENSEE, by
2+
2 Princeton University under the following license. By obtaining, using
3+
3 and/or copying this software and database, you agree that you have
4+
4 read, understood, and will comply with these terms and conditions.:
5+
5
6+
6 Permission to use, copy, modify and distribute this software and
7+
7 database and its documentation for any purpose and without fee or
8+
8 royalty is hereby granted, provided that you agree to comply with
9+
9 the following copyright notice and statements, including the disclaimer,
10+
10 and that the same appear on ALL copies of the software, database and
11+
11 documentation, including modifications that you make for internal
12+
12 use or for distribution.
13+
13
14+
14 WordNet 3.0 Copyright 2006 by Princeton University. All rights reserved.
15+
15
16+
16 THIS SOFTWARE AND DATABASE IS PROVIDED "AS IS" AND PRINCETON
17+
17 UNIVERSITY MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR
18+
18 IMPLIED. BY WAY OF EXAMPLE, BUT NOT LIMITATION, PRINCETON
19+
19 UNIVERSITY MAKES NO REPRESENTATIONS OR WARRANTIES OF MERCHANT-
20+
20 ABILITY OR FITNESS FOR ANY PARTICULAR PURPOSE OR THAT THE USE
21+
21 OF THE LICENSED SOFTWARE, DATABASE OR DOCUMENTATION WILL NOT
22+
22 INFRINGE ANY THIRD PARTY PATENTS, COPYRIGHTS, TRADEMARKS OR
23+
23 OTHER RIGHTS.
24+
24
25+
25 The name of Princeton University or Princeton may not be used in
26+
26 advertising or publicity pertaining to distribution of the software
27+
27 and/or database. Title to copyright in this software, database and
28+
28 any associated documentation shall at all times remain with
29+
29 Princeton University and LICENSEE agrees to preserve same.
30+
aquatic a 1 1 & 1 0 00124077
31+
marine a 1 1 & 1 0 00124353

test/test_operations.jl

+7
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,11 @@
2222
ss = synsets(mock_db, mock_db['n', "'hood"])[1]
2323
@test length(antonyms(mock_db, ss)) == 0
2424
end
25+
26+
@testset "similar tos" begin
27+
aquatic = synsets(mock_db, mock_db['a', "aquatic"])[1]
28+
marine = synsets(mock_db, mock_db['a', "marine"])[1]
29+
@test WordNet.relation(mock_db, aquatic, WordNet.SIMILAR_TO) == [marine]
30+
@test WordNet.relation(mock_db, marine, WordNet.SIMILAR_TO) == [aquatic]
31+
end
2532
end

0 commit comments

Comments
 (0)