JuliaText / JuliaText/TextAnalysis.jl
bug in function embedding from sentiment.jl
- Dominant language
- Julia
- Stars
- 384
- Forks
- 92
- PR merge metrics
- No merged PRs in 30d
Description
The following code seems to have a bug in that it reshapes a matrix in an apparent attempt to transpose:
```
function embedding(embedding_matrix, x)
# inefficient code:
temp = embedding_matrix[:, Int64(x[1])+1]
for i=2:length(x)
temp = hcat(temp, embedding_matrix[:, Int64(x[i])+1])
end
# bug
return reshape(temp, reverse(size(temp)))
end
```
I propose the following:
```
function embedding(embedding_matrix, x)
temp = embedding_matrix[:, Int64.(x).+1]';
end
```
```
# After this change the results of the following are much improved
d_good = StringDocument("A very nice thing that everyone likes")
prepare!(d_good, strip_case | strip_punctuation )
d_bad = StringDocument("A boring long dull movie that no one likes")
prepare!(d_bad, strip_case | strip_punctuation)
s = SentimentAnalyzer()
s(d_good)
s(d_bad)
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.