Added Url skipping features
This commit is contained in:
parent
5b901e51a9
commit
68602f3942
@ -11,6 +11,10 @@
|
|||||||
|
|
||||||
(defn parse-int [s] (Integer/parseInt s))
|
(defn parse-int [s] (Integer/parseInt s))
|
||||||
|
|
||||||
|
(def url-pattern
|
||||||
|
#"(?i)\b((?:https?://|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}/)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:'\".,<>?«»“”‘’]))")
|
||||||
|
|
||||||
|
|
||||||
(defn tokenize-line [line]
|
(defn tokenize-line [line]
|
||||||
(let [non-char-pattern (re-pattern "[\\p{Z}\\p{C}\\p{P}]+")
|
(let [non-char-pattern (re-pattern "[\\p{Z}\\p{C}\\p{P}]+")
|
||||||
tokenize
|
tokenize
|
||||||
@ -211,7 +215,7 @@
|
|||||||
min-sentence-length
|
min-sentence-length
|
||||||
max-sentence-length)]
|
max-sentence-length)]
|
||||||
(println ">> Sending message:" sentence)
|
(println ">> Sending message:" sentence)
|
||||||
(send-message bot channel sentence)))) ]
|
(send-message bot channel sentence))))]
|
||||||
(try
|
(try
|
||||||
(swap! msg-count inc)
|
(swap! msg-count inc)
|
||||||
(cond
|
(cond
|
||||||
@ -241,21 +245,24 @@
|
|||||||
:else
|
:else
|
||||||
(do
|
(do
|
||||||
(doseq [line (sentencize-text message)]
|
(doseq [line (sentencize-text message)]
|
||||||
(when-not (= 1 (count (tokenize-line line)))
|
(let [urls (map first (re-seq url-pattern line))]
|
||||||
(do
|
(if (not (empty? urls))
|
||||||
(println ">" sender ":" line)
|
(doseq [url urls] (println "Url Found >" url))
|
||||||
(process-line
|
(when-not (= 1 (count (tokenize-line line)))
|
||||||
line
|
(do
|
||||||
trained-map-atom
|
(println ">" sender ":" line)
|
||||||
startphrase-list-atom
|
(process-line
|
||||||
endphrase-set-atom
|
line
|
||||||
line-list-atom
|
trained-map-atom
|
||||||
key-size
|
startphrase-list-atom
|
||||||
history-size)
|
endphrase-set-atom
|
||||||
(when (and
|
line-list-atom
|
||||||
@bot-talking?
|
key-size
|
||||||
(<= (rand) (/ 1 speak-interval)))
|
history-size)
|
||||||
(create-statement-and-send)))))
|
(when (and
|
||||||
|
@bot-talking?
|
||||||
|
(<= (rand) (/ 1 speak-interval)))
|
||||||
|
(create-statement-and-send)))))))
|
||||||
(when (zero? (mod @msg-count save-interval))
|
(when (zero? (mod @msg-count save-interval))
|
||||||
(println "Saving memory")
|
(println "Saving memory")
|
||||||
(save-memory bot @line-list-atom))))
|
(save-memory bot @line-list-atom))))
|
||||||
@ -334,6 +341,5 @@
|
|||||||
(parse-int min-sentence-length)
|
(parse-int min-sentence-length)
|
||||||
(parse-int max-sentence-length)))
|
(parse-int max-sentence-length)))
|
||||||
|
|
||||||
;;filter out links
|
|
||||||
;;switch to pircbotx
|
;;switch to pircbotx
|
||||||
;;pronoun substitution
|
;;pronoun substitution
|
||||||
|
Loading…
Reference in New Issue
Block a user