update
This commit is contained in:
@@ -496,7 +496,7 @@ function sendMqttMsg(outgoingMsg::Dict{Symbol, T})::NamedTuple where {T<:Any}
|
|||||||
)
|
)
|
||||||
|
|
||||||
response = sendMqttMsg(mqttInstance, outgoingMsg)
|
response = sendMqttMsg(mqttInstance, outgoingMsg)
|
||||||
disconnect(mqttInstance.client)
|
try disconnect(mqttInstance.client) catch end
|
||||||
|
|
||||||
return response
|
return response
|
||||||
end
|
end
|
||||||
@@ -576,7 +576,7 @@ function sendReceiveMqttMsg(outgoingMsg::Dict{Symbol, T};
|
|||||||
)
|
)
|
||||||
|
|
||||||
response = sendReceiveMqttMsg(mqttInstance, :ch1, outgoingMsg; timeout=timeout, maxattempt=maxattempt)
|
response = sendReceiveMqttMsg(mqttInstance, :ch1, outgoingMsg; timeout=timeout, maxattempt=maxattempt)
|
||||||
disconnect(mqttInstance.client)
|
try disconnect(mqttInstance.client) catch end
|
||||||
|
|
||||||
return response
|
return response
|
||||||
end
|
end
|
||||||
|
|||||||
48
src/util.jl
48
src/util.jl
@@ -5,7 +5,7 @@ export timedifference, showstracktrace, findHighestIndexKey, uuid4snakecase, rep
|
|||||||
dataframeToCSV, dfToVectorDict, disintegrate_vectorDict, getDataFrameValue, dfRowtoString,
|
dataframeToCSV, dfToVectorDict, disintegrate_vectorDict, getDataFrameValue, dfRowtoString,
|
||||||
dfToString, dataframe_to_json_list, dictToString, dictToString_noKey,
|
dfToString, dataframe_to_json_list, dictToString, dictToString_noKey,
|
||||||
dictToString_numbering, extract_triple_backtick_text,
|
dictToString_numbering, extract_triple_backtick_text,
|
||||||
countGivenWords, remove_french_accents, detect_keyword
|
countGivenWords, remove_french_accents, detect_keyword, extractTextBetweenCharacter
|
||||||
|
|
||||||
using JSON3, DataStructures, Distributions, Random, Dates, UUIDs, MQTTClient, DataFrames
|
using JSON3, DataStructures, Distributions, Random, Dates, UUIDs, MQTTClient, DataFrames
|
||||||
|
|
||||||
@@ -747,7 +747,7 @@ Extracts text enclosed within triple backticks (```) from the given string.
|
|||||||
- `Vector{String}`: A vector of strings, each representing a block of text enclosed within triple backticks found in the input string.
|
- `Vector{String}`: A vector of strings, each representing a block of text enclosed within triple backticks found in the input string.
|
||||||
|
|
||||||
# Examples:
|
# Examples:
|
||||||
```julia
|
```jldoctest
|
||||||
julia> extract_triple_backtick_text("Here is some text ```with a code block``` and more text.")
|
julia> extract_triple_backtick_text("Here is some text ```with a code block``` and more text.")
|
||||||
1-element Vector{String}:
|
1-element Vector{String}:
|
||||||
"with a code block"
|
"with a code block"
|
||||||
@@ -779,7 +779,7 @@ Detects if a keyword exists in the text in different case variations (lowercase,
|
|||||||
- `Union{Nothing, String}`: Returns the matched keyword variation if found, otherwise returns nothing
|
- `Union{Nothing, String}`: Returns the matched keyword variation if found, otherwise returns nothing
|
||||||
|
|
||||||
# Examples:
|
# Examples:
|
||||||
```julia
|
```jldoctest
|
||||||
julia> detect_keyword("test", "This is a Test case")
|
julia> detect_keyword("test", "This is a Test case")
|
||||||
"Test"
|
"Test"
|
||||||
|
|
||||||
@@ -821,7 +821,7 @@ Count the occurrences of each word in the given list within the provided text.
|
|||||||
- `Vector{Int64}`: Their respective counts in the `text`.
|
- `Vector{Int64}`: Their respective counts in the `text`.
|
||||||
|
|
||||||
# Examples
|
# Examples
|
||||||
```julia
|
```jldoctest
|
||||||
julia> GeneralUtils.countGivenWords("hello world hello", ["hello", "world"])
|
julia> GeneralUtils.countGivenWords("hello world hello", ["hello", "world"])
|
||||||
2-element Vector{Int64}:
|
2-element Vector{Int64}:
|
||||||
2
|
2
|
||||||
@@ -863,7 +863,7 @@ Remove French accents from the given text.
|
|||||||
- `String`: The input string with all French accents removed.
|
- `String`: The input string with all French accents removed.
|
||||||
|
|
||||||
# Examples
|
# Examples
|
||||||
```julia
|
```jldoctest
|
||||||
julia> remove_french_accents("Café")
|
julia> remove_french_accents("Café")
|
||||||
"Cafe"
|
"Cafe"
|
||||||
|
|
||||||
@@ -907,6 +907,44 @@ function remove_french_accents(text::AbstractString)::AbstractString
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
"""
|
||||||
|
extractTextBetweenCharacters(text::String, start_char::Char, end_char::Char)::String
|
||||||
|
|
||||||
|
Extracts and returns the text that is enclosed between two specified characters within a given string.
|
||||||
|
|
||||||
|
# Arguments:
|
||||||
|
- `text::String`: The input string from which to extract the text.
|
||||||
|
- `startchar::Char`: The starting character that marks the beginning of the desired text.
|
||||||
|
- `endchar::Char`: The ending character that marks the end of the desired text.
|
||||||
|
|
||||||
|
# Returns:
|
||||||
|
- `String`: The substring enclosed between `start_char` and `end_char`.
|
||||||
|
|
||||||
|
# Examples:
|
||||||
|
```jldoctest
|
||||||
|
julia> text = "Hello [World]!"
|
||||||
|
julia> extracted_text = extractTextBetweenCharacter(text, '[', ']')
|
||||||
|
println(extracted_text) # Output: "World"
|
||||||
|
"""
|
||||||
|
function extractTextBetweenCharacter(text::String, startchar::Char, endchar::Char)
|
||||||
|
result = []
|
||||||
|
start_index = 0
|
||||||
|
in_braces = false
|
||||||
|
|
||||||
|
for (i, c) in enumerate(text)
|
||||||
|
if c == startchar
|
||||||
|
start_index = i + 1
|
||||||
|
in_braces = true
|
||||||
|
elseif c == endchar
|
||||||
|
if in_braces
|
||||||
|
push!(result, text[start_index:i-1])
|
||||||
|
in_braces = false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return result
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user