Skip to content

Commit

Permalink
Merge branch 'master' of github.com:JuliaText/TextAnalysis.jl
Browse files Browse the repository at this point in the history
  • Loading branch information
aviks committed Nov 10, 2020
2 parents ad23371 + d7d8105 commit 998083f
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 7 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ A Julia package for working with text.

## Introduction

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.
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.

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

Expand Down
12 changes: 6 additions & 6 deletions src/corpus.jl
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,12 @@ Base.length(crps::Corpus) = length(crps.documents)
function Base.convert(::Type{DataFrame}, crps::Corpus)
df = DataFrame()
n = length(crps)
df[:Language] = Array{Union{String,Missing}}(n)
df[:Title] = Array{Union{String,Missing}}(n)
df[:Author] = Array{Union{String,Missing}}(n)
df[:TimeStamp] = Array{Union{String,Missing}}(n)
df[:Length] = Array{Union{Int,Missing}}(n)
df[:Text] = Array{Union{String,Missing}}(n)
df[!, :Language] = Array{Union{String,Missing}}(undef, n)
df[!, :Title] = Array{Union{String,Missing}}(undef, n)
df[!, :Author] = Array{Union{String,Missing}}(undef, n)
df[!, :TimeStamp] = Array{Union{String,Missing}}(undef, n)
df[!, :Length] = Array{Union{Int,Missing}}(undef, n)
df[!, :Text] = Array{Union{String,Missing}}(undef, n)
for i in 1:n
d = crps.documents[i]
df[i, :Language] = string(language(d))
Expand Down
12 changes: 12 additions & 0 deletions test/corpus.jl
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,15 @@

@test answer == lexicon(crps)
end

using DataFrames

@testset "Convert Corpus to DataFrames" begin
crps = Corpus([StringDocument("hello world"), StringDocument("goodbye world")])
df = convert(DataFrame, crps)
@test typeof(df) == DataFrames.DataFrame
@test df[1, :Text] == "hello world"
@test df[1, :Length] == 11
@test df[2, :Text] == "goodbye world"
@test df[2, :Length] == 13
end

2 comments on commit 998083f

@aviks
Copy link
Member Author

@aviks aviks commented on 998083f Nov 10, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/24443

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.7.1 -m "<description of version>" 998083f5a9f470bfa17636bac4bfd836fce9844d
git push origin v0.7.1

Please sign in to comment.