RS
using UrlDownload
using BenchmarkTools
txt = @_ urldownload("https://www.linguistik.uzh.ch/dam/jcr:169bff5c-ac13-457b-9acb-4fe7f1ad5cb0/Harry%20Potter%20and%20the%20Sorcerer.txt", parser=String) |> replace(__, r"[^0-9A-Za-z\n\. ]" => "") |> split(__, "\n") |> split.(__, ".") |> collect(Iterators.flatten(__)) |> strip.(__) |> filter(!isempty, __)
deleteat!(txt, 278)
txt2 = txt[1:500]
function sentiments(tb, x)
@_ tb.(x) |> map(_.sentiment, __) |> first.(__)
end
@btime sentiments($tb, $txt2)
187.112 ms (10508 allocations: 309.17 KiB)
500-element Array{Float64,1}:
То есть 500 предложений обработались за 0.2 секунды... Вроде неплохо. Правда там предложения короткие, но всё равно, выглядит как вполне обычная скорость для работы с текстом.


