👨‍💻 dev rail chatbot

development

owly

闇の伝説
Staff member
戦闘 コーダー
rail_cb{k,refreshq} priority (5)

q_rail_cb: inputfilter(questions)refreshq
last_output
timegate(5)

*friend filter
*******
*input*
*******
// learn
learn(q)
learn(rail)
//toggle
activate:
tg.open;ret
deactivate:
tg.close;ret
// convo
active?
""->(drip)q
!""->(drip)rail[ear].getResponse();setContext(response)//for learn
################################################################

{k,refreshQ}
context:str = default
setContext(str1){}
getResponse()->str{ret dic[context] or ""}
learn(ear){dic[context].add(ear)}
*stream()
 

ZORO

Member
🦈 VIP 🦈
Python:
class RailChatBot:
    def __init__(self):
        self.dic = {}
        self.context = "default"
        self.dic[self.context] = RefreshQ()

    def setContext(self, context):
        if context == "":
            return
        self.context = context

    def respond(self, ear):
        if ear == "":
            return ""
        if ear not in self.dic:
            self.dic[ear] = RefreshQ()
        temp = self.dic[ear].getRNDElement()
        if temp != "":
            self.context = temp
        return temp

    def learn(self, ear):
        if ear == "":
            return
        if ear not in self.dic:
            self.dic[ear] = RefreshQ()
            self.dic[self.context].add(ear)
            self.context = ear
            return
        self.dic[self.context].add(ear)
        self.context = ear

    def monolog(self):
        return self.respond(self.context)
 

ZORO

Member
🦈 VIP 🦈
Swift:
import Foundation

class RailChatBot {
    private var dic: [String: RefreshQ] = [:]
    private var context: String = "default"
    
    init() {
        dic[context] = RefreshQ()
    }
    
    func setContext(_ context: String) {
        if context.isEmpty { return }
        self.context = context
    }
    
    func respond(_ ear: String) -> String {
        if ear.isEmpty { return "" }
        if !dic.keys.contains(ear) {
            dic[ear] = RefreshQ()
        }
        let temp = dic[ear]?.getRNDElement() ?? ""
        if !temp.isEmpty {
            context = temp
        }
        return temp
    }
    
    func learn(_ ear: String) {
        if ear.isEmpty { return }
        if !dic.keys.contains(ear) {
            dic[ear] = RefreshQ()
            dic[context]?.add(ear)
            context = ear
            return
        }
        dic[context]?.add(ear)
        context = ear
    }
    
    func monolog() -> String {
        return respond(context)
    }
}
 
Top