Merge pull request 'v0.1.1-dev' (#1) from v0.1.1-dev into main
Reviewed-on: #1
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
name = "GeneralUtils"
|
||||
uuid = "c6c72f09-b708-4ac8-ac7c-2084d70108fe"
|
||||
authors = ["tonaerospace <tonaerospace.etc@gmail.com>"]
|
||||
version = "0.1.0"
|
||||
version = "0.1.1"
|
||||
|
||||
[deps]
|
||||
CSV = "336ed68f-0bac-5ca0-87d4-7b16caf5d00b"
|
||||
|
||||
@@ -117,7 +117,7 @@ end
|
||||
julia> using Revise
|
||||
julia> using GeneralUtils, Dates, JSON3, UUIDs
|
||||
julia> mqttMsgReceiveTopic = ["/receivetopic_1", "/receivetopic_2"]
|
||||
julia> mqttMsgReceiveChannel = (ch1=Channel(8), ch2=Channel(32))
|
||||
julia> mqttMsgReceiveChannel = (ch1=Channel(8), ch2=Channel(32)) # single channel Ex. (ch1=Channel(8),)
|
||||
julia> keepaliveChannel = Channel(8)
|
||||
julia> function onMsgCallback(topic, payload)
|
||||
jobj = JSON3.read(String(payload))
|
||||
|
||||
25
src/util.jl
25
src/util.jl
@@ -4,7 +4,7 @@ export timedifference, showstracktrace, findHighestIndexKey, uuid4snakecase, rep
|
||||
findMatchingDictKey, textToDict, randstring, randstrings, timeout,
|
||||
dataframeToCSV, dfToVectorDict, disintegrate_vectorDict, getDataFrameValue, dfRowtoString,
|
||||
dfToString, dataframe_to_json_list, dict_to_string, extract_triple_backtick_text,
|
||||
countGivenWords, remove_french_accents
|
||||
countGivenWords, remove_french_accents, detect_keyword
|
||||
|
||||
using JSON3, DataStructures, Distributions, Random, Dates, UUIDs, MQTTClient, DataFrames
|
||||
|
||||
@@ -284,7 +284,10 @@ function textToDict(text::String, keywords::Vector{String};
|
||||
kw = []
|
||||
# use for loop and detect_keyword function to get the exact variation of each keyword in the text then push to kw list
|
||||
for keyword in keywords
|
||||
push!(kw, detect_keyword(keyword, text))
|
||||
detected = detect_keyword(keyword, text)
|
||||
if detected !== nothing
|
||||
push!(kw, detected)
|
||||
end
|
||||
end
|
||||
|
||||
od1, od2 =
|
||||
@@ -798,19 +801,19 @@ Count the occurrences of each word in the given list within the provided text.
|
||||
- `words::Vector{String}`: A vector of words whose occurrences need to be counted.
|
||||
|
||||
# Returns
|
||||
- `Dict{String, Int}`: A dictionary where keys are the words from the `words` list and values are their respective counts in the `text`.
|
||||
- `Vector{Int64}`: Their respective counts in the `text`.
|
||||
|
||||
# Examples
|
||||
```julia
|
||||
julia> countGivenWords("hello world hello", ["hello", "world"])
|
||||
Dict{String,Int64} with 2 entries:
|
||||
"hello" => 2
|
||||
"world" => 1
|
||||
julia> GeneralUtils.countGivenWords("hello world hello", ["hello", "world"])
|
||||
2-element Vector{Int64}:
|
||||
2
|
||||
1
|
||||
|
||||
julia> countGivenWords("foo bar baz foo", ["foo", "qux"])
|
||||
Dict{String,Int64} with 2 entries:
|
||||
"foo" => 2
|
||||
"qux" => 0
|
||||
julia> GeneralUtils.countGivenWords("foo bar baz foo", ["foo", "qux"])
|
||||
2-element Vector{Int64}:
|
||||
2
|
||||
0
|
||||
```
|
||||
|
||||
# Signature
|
||||
|
||||
Reference in New Issue
Block a user