当前位置: 首页>>代码示例>>Python>>正文


Python aiml.Kernel方法代码示例

本文整理汇总了Python中aiml.Kernel方法的典型用法代码示例。如果您正苦于以下问题:Python aiml.Kernel方法的具体用法?Python aiml.Kernel怎么用?Python aiml.Kernel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在aiml的用法示例。


在下文中一共展示了aiml.Kernel方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _load_scripts

# 需要导入模块: import aiml [as 别名]
# 或者: from aiml import Kernel [as 别名]
def _load_scripts(self) -> None:
        """
        Scripts are loaded recursively from files with extensions .xml and .aiml
        Returns: None

        """
        # learn kernel to all aimls in directory tree:
        all_files = sorted(self.path_to_aiml_scripts.rglob('*.*'))
        learned_files = []
        for each_file_path in all_files:
            if each_file_path.suffix in ['.aiml', '.xml']:
                # learn the script file
                self.kernel.learn(str(each_file_path))
                learned_files.append(each_file_path)
        if not learned_files:
            log.warning(f"No .aiml or .xml files found for AIML Kernel in directory {self.path_to_aiml_scripts}") 
开发者ID:deepmipt,项目名称:DeepPavlov,代码行数:18,代码来源:aiml_skill.py

示例2: _load_alice

# 需要导入模块: import aiml [as 别名]
# 或者: from aiml import Kernel [as 别名]
def _load_alice(self):
        self.kern = aiml.Kernel()
        self.kern.verbose(False)
        self.kern.setTextEncoding(None)
        chdir = os.path.join(aiml.__path__[0], 'botdata', 'alice')
        self.kern.bootstrap(
            learnFiles="startup.xml", commands="load alice", chdir=chdir
        ) 
开发者ID:facebookresearch,项目名称:ParlAI,代码行数:10,代码来源:alice.py

示例3: train

# 需要导入模块: import aiml [as 别名]
# 或者: from aiml import Kernel [as 别名]
def train(ev, core, init=False):
    """
    :param ev: The event object referenced in the event.
    :type ev: sigma.core.mechanics.event.SigmaEvent
    :param core: The chatterbot core class.
    :type core: aiml.Kernel
    :param init: If the training is initializing or runtime.
    :type init: bool
    """
    cb_log(ev, init, 'Learning generic AIML interactions...')
    core.learn(os.sep.join([ev.resource('aiml_files'), '*.aiml']))
    cb_log(ev, init, 'Learning properties unique to the client...')
    with open(ev.resource('properties.yml')) as prop_file:
        prop_data = yaml.safe_load(prop_file)
    for prop_key in prop_data:
        prop_val = prop_data.get(prop_key)
        chatter_core.setBotPredicate(prop_key, prop_val)
    cb_log(ev, init, 'Learning additional software details...')
    version = ev.bot.info.get_version()
    full_version = f'{version.major}.{version.minor}.{version.patch}'
    if version.beta:
        full_version += ' Beta'
    chatter_core.setBotPredicate('version', full_version)
    birthday_date = arrow.get(datetime.date(2016, 8, 16))
    age = (arrow.utcnow() - birthday_date).days // 365.25
    chatter_core.setBotPredicate('age', str(int(age)))
    chatter_core.setBotPredicate('birthday', birthday_date.format('MMMM DD'))
    chatter_core.setBotPredicate('birthdate', birthday_date.format('MMMM DD, YYYY'))
    cb_log(ev, init, 'Loaded Chatter Core.') 
开发者ID:lu-ci,项目名称:apex-sigma-core,代码行数:31,代码来源:chatter_core_init.py

示例4: __init__

# 需要导入模块: import aiml [as 别名]
# 或者: from aiml import Kernel [as 别名]
def __init__(self):
    self._kernel = aiml.Kernel() 
开发者ID:sld,项目名称:convai-bot-1337,代码行数:4,代码来源:ai.py

示例5: __init__

# 需要导入模块: import aiml [as 别名]
# 或者: from aiml import Kernel [as 别名]
def __init__(self,
                 path_to_aiml_scripts: str,
                 positive_confidence: float = 0.66,
                 null_response: str = "I don't know what to answer you",
                 null_confidence: float = 0.33,
                 **kwargs
                 ) -> None:
        """
        Construct skill:
            read AIML scripts,
            load AIML kernel

        Args:
            path_to_aiml_scripts: string path to folder with AIML scripts
            null_response: Response string to answer if no AIML Patterns matched
            positive_confidence: The confidence of response if response was found in AIML scripts
            null_confidence: The confidence when AIML scripts has no rule for responding and system returns null_response
        """
        # we need absolute path (expanded for user home and resolved if it relative path):
        self.path_to_aiml_scripts = Path(path_to_aiml_scripts).expanduser().resolve()
        log.info(f"path_to_aiml_scripts is: `{self.path_to_aiml_scripts}`")

        self.positive_confidence = positive_confidence
        self.null_confidence = null_confidence
        self.null_response = null_response
        self.kernel = aiml.Kernel()
        # to block AIML output:
        self.kernel._verboseMode = False
        self._load_scripts() 
开发者ID:deepmipt,项目名称:DeepPavlov,代码行数:31,代码来源:aiml_skill.py

示例6: __init__

# 需要导入模块: import aiml [as 别名]
# 或者: from aiml import Kernel [as 别名]
def __init__(self, channel_name, bot_token, database):
        """
        Initialize the bot using the Discord token and channel name to chat in.

        :param channel_name: Only chats in this channel. No hashtag included.
        :param bot_token: Full secret bot token
        :param database: Path for sqlite file to use
        """
        # Store configuration values
        self.channel_name = channel_name
        self.token = bot_token
        self.database = database
        self.message_count = 0
        self.last_reset_time = datetime.now()

        logging.info("[*] Setting up signal handlers")
        signal(SIGINT, self.exit_handler)
        signal(SIGTERM, self.exit_handler)

        # Setup database
        logging.info("[*] Initializing database...")
        self.db = sqlite3.connect(self.database)
        self.cursor = self.db.cursor()
        self.setup_database_schema()
        logging.info('[+] Database initialized')

        # Load AIML kernel
        logging.info("[*] Initializing AIML kernel...")
        start_time = datetime.now()
        self.aiml_kernel = aiml.Kernel()
        self.setup_aiml()
        end_time = datetime.now()
        logging.info(f"[+] Done initializing AIML kernel. Took {end_time - start_time}")

        # Set up Discord
        logging.info("[*] Initializing Discord bot...")
        self.discord_bot = discord.AutoShardedClient()
        self.setup_discord_events()
        logging.info("[+] Done initializing Discord bot.")
        logging.info("[+] Exiting __init__ function.") 
开发者ID:DevDungeon,项目名称:Cathy,代码行数:42,代码来源:__init__.py


注:本文中的aiml.Kernel方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。