Skip to content

Commit 014a52b

Browse files
committed
fix definition of input scitype: NGram -> ScientificNGram
1 parent 05a89bd commit 014a52b

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

src/MLJText.jl

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -155,13 +155,17 @@ MMI.metadata_pkg(TfidfTransformer,
155155
is_wrapper=false
156156
)
157157

158+
const ScientificNGram{N} = NTuple{<:Any,STB.Textual}
159+
158160
MMI.metadata_model(TfidfTransformer,
159161
input_scitype = Union{
160-
AbstractVector{<:AbstractVector{STB.Textual}}, AbstractVector{<:STB.Multiset{<:NGram}}, AbstractVector{<:STB.Multiset{STB.Textual}}
162+
AbstractVector{<:AbstractVector{STB.Textual}},
163+
AbstractVector{<:STB.Multiset{<:ScientificNGram}},
164+
AbstractVector{<:STB.Multiset{STB.Textual}}
161165
},
162-
output_scitype = AbstractMatrix{STB.Continuous},# ie, a classifier
163-
docstring = "Build TF-IDF matrix from raw documents", # brief description
166+
output_scitype = AbstractMatrix{STB.Continuous},
167+
docstring = "Build TF-IDF matrix from raw documents",
164168
path = "MLJText.TfidfTransformer"
165169
)
166170

167-
end # module
171+
end # module

test/runtests.jl

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ using TextAnalysis
1212

1313
# train transformer
1414
tfidf_transformer = MLJText.TfidfTransformer()
15-
test_machine = machine(tfidf_transformer, ngram_vec)
15+
test_machine = @test_logs machine(tfidf_transformer, ngram_vec)
1616
MLJBase.fit!(test_machine)
1717

1818
# test
@@ -39,7 +39,6 @@ using TextAnalysis
3939
@test sum(test4, dims=2)[1] == 0.0
4040
@test sum(test4, dims=2)[2] > 0.0
4141
@test size(test4) == (2, 11)
42-
4342
# test with bag of words
4443
bag_of_words = Dict(
4544
"cat in" => 1,
@@ -53,7 +52,7 @@ using TextAnalysis
5352
)
5453
bag = Dict{MLJText.NGram, Int}(Tuple(String.(split(k))) => v for (k, v) in bag_of_words)
5554
tfidf_transformer2 = MLJText.TfidfTransformer()
56-
test_machine2 = machine(tfidf_transformer2, [bag])
55+
test_machine2 = @test_logs machine(tfidf_transformer2, [bag])
5756
MLJBase.fit!(test_machine2)
5857

5958
test_doc5 = ["How about a cat in a hat"]

0 commit comments

Comments
 (0)