Skip to content

Commit 998083f

Browse files
committed
Merge branch 'master' of github.com:JuliaText/TextAnalysis.jl
2 parents ad23371 + d7d8105 commit 998083f

File tree

3 files changed

+19
-7
lines changed

3 files changed

+19
-7
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ A Julia package for working with text.
88

99
## Introduction
1010

11-
TextAnalysis provides support for standard tools and models for working with textual data and natural languages in the Julia langauges. Please see the [documentation](https://juliahub.com/docs/TextAnalysis/5Mwett) for more.
11+
TextAnalysis provides support for standard tools and models for working with textual data and natural languages in the Julia langauges. Please see the [documentation](https://juliahub.com/docs/TextAnalysis/5Mwet) for more.
1212

1313
- **License** : [MIT License](https://github.com/JuliaText/TextAnalysis.jl/blob/master/LICENSE.md)
1414

src/corpus.jl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -90,12 +90,12 @@ Base.length(crps::Corpus) = length(crps.documents)
9090
function Base.convert(::Type{DataFrame}, crps::Corpus)
9191
df = DataFrame()
9292
n = length(crps)
93-
df[:Language] = Array{Union{String,Missing}}(n)
94-
df[:Title] = Array{Union{String,Missing}}(n)
95-
df[:Author] = Array{Union{String,Missing}}(n)
96-
df[:TimeStamp] = Array{Union{String,Missing}}(n)
97-
df[:Length] = Array{Union{Int,Missing}}(n)
98-
df[:Text] = Array{Union{String,Missing}}(n)
93+
df[!, :Language] = Array{Union{String,Missing}}(undef, n)
94+
df[!, :Title] = Array{Union{String,Missing}}(undef, n)
95+
df[!, :Author] = Array{Union{String,Missing}}(undef, n)
96+
df[!, :TimeStamp] = Array{Union{String,Missing}}(undef, n)
97+
df[!, :Length] = Array{Union{Int,Missing}}(undef, n)
98+
df[!, :Text] = Array{Union{String,Missing}}(undef, n)
9999
for i in 1:n
100100
d = crps.documents[i]
101101
df[i, :Language] = string(language(d))

test/corpus.jl

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,15 @@
4141

4242
@test answer == lexicon(crps)
4343
end
44+
45+
using DataFrames
46+
47+
@testset "Convert Corpus to DataFrames" begin
48+
crps = Corpus([StringDocument("hello world"), StringDocument("goodbye world")])
49+
df = convert(DataFrame, crps)
50+
@test typeof(df) == DataFrames.DataFrame
51+
@test df[1, :Text] == "hello world"
52+
@test df[1, :Length] == 11
53+
@test df[2, :Text] == "goodbye world"
54+
@test df[2, :Length] == 13
55+
end

0 commit comments

Comments
 (0)