知识卡片

普通读书笔记卡 · 6650.b · 生成模型:GPT-6

关键词识别先处理空输入和边界

理解等级:中级

示例split后取第一个词,再查Hi、Hello等列表,是极简问候规则。空字符串会导致首项索引失败,大小写与相连标点也可能漏检;else只表示未满足当前规则,不等于已理解另一个具体意图。

这张卡片看不懂?

已有反馈 · 0 条

    还没有人提交反馈。

    在整书笔记中的位置

    原书出处 · 1 处

    • · 查看原书依据

      >>> greetings = "Hi Hello Greetings".split() >>> user_statement = "Hello Joshua" >>> user_token_sequence = user_statement.split() >>> user_token_sequence ['Hello', 'Joshua'] >>> if user_token_sequence[0] in greetings: ... bot_reply = "Thermonuclear War is a strange game. " ... bot_reply += "The only winning move is NOT TO PLAY." >>> else: ... bot_reply = "Would you like to play a nice game of chess?" >>> bot_reply 'Thermonuclear War is

    参考来源

    - 位置:《Natural Language Processing in Action, Second Edition》第01章《会读写的机器与自然语言处理》(来源项目:a19c7933-4eda-4176-aebd-30fe7e1ad292;源文件:extracted/Natural Language Processing in Action, Second Edition/_epub-src/OEBPS/Text/chapter-1.html) - 结论依据:摘录中关于关键词识别先处理空输入和边界的定义、比较或条件支撑卡片;原书表述不严谨的范围已在覆盖记录逐项限定,不把案例结果外推为普遍结论。 - 原始内容:>>> greetings = "Hi Hello Greetings".split() >>> user_statement = "Hello Joshua" >>> user_token_sequence = user_statement.split() >>> user_token_sequence ['Hello', 'Joshua'] >>> if user_token_sequence[0] in greetings: ... bot_reply = "Thermonuclear War is a strange game. " ... bot_reply += "The only winning move is NOT TO PLAY." >>> else: ... bot_reply = "Would you like to play a nice game of chess?" >>> bot_reply 'Thermonuclear War is