创新互联百度小程序教程:swan.ai.nlpLexerCustom

  • swan.ai.nlpLexerCustom
    • 方法参数
      • object 参数说明
      • success 返回参数说明
      • items 参数说明
    • 示例
      • 图片示例
      • 代码示例
      • 返回值示例

    swan.ai.nlpLexerCustom

    基础库 3.20.11 开始支持,低版本需做兼容处理。

    网站建设公司,为您提供网站建设,网站制作,网页设计及定制网站建设服务,专注于成都企业网站定制,高端网页制作,对护栏打桩机等多个行业拥有丰富的网站建设经验的网站建设公司。专业网站设计,网站优化推广哪家好,专业seo优化优化,H5建站,响应式网站。

    解释:词法分析,提供分词、词性标注、专名识别三大功能。
    Web 态说明:受宿主环境限制,Web 态暂不支持 AI 能力相关接口。在 Web 态会做 打开百度 App 对应小程序页面 的降级处理。

    方法参数

    Object object

    object 参数说明

    属性名 类型 必填 默认值 说明

    text

    String

    是

    待分析文本

    success

    Function

    否

    接口调用成功后的回调函数

    fail

    Function

    否

    接口调用失败的回调函数

    complete

    Function

    否

    接口调用结束的回调函数(调用成功、失败都会执行)

    success 返回参数说明

    参数名 参数类型 说明

    log_id

    Number

    唯一的 log id,用于问题定位

    text

    String

    原始单条请求文本

    items

    Array

    词汇数组,每个元素对应结果中的一个词

    items 参数说明

    参数名 参数类型 说明

    item

    String

    词汇的字符串

    ne

    String

    命名实体类型,命名实体识别算法使用。词性标注算法中,此项为空串

    pos

    String

    词性,词性标注算法使用。命名实体识别算法中,此项为空串

    byte_offset

    Number

    在 text 中的字节级 offset(使用 GBK 编码)

    byte_length

    Number

    字节级 length(使用 GBK 编码)

    uri

    String

    链指到知识库的 URI,只对命名实体有效。对于非命名实体和链接不到知识库的命名实体,此项为空串

    formal

    String

    词汇的标准化表达,主要针对时间、数字单位,没有归一化表达的,此项为空串

    basic_words

    Array

    基本词成分

    loc_details

    Array

    地址成分,非必需,仅对地址型命名实体有效,没有地址成分的,此项为空数组

    示例

    跳转编辑工具

    在开发者工具中打开

    在 WEB IDE 中打开

    扫码体验

    代码示例

    请使用百度APP扫码

    图片示例

    代码示例

    • SWAN
    • JS
     
     
     
    1. 识别内容
    2. {{content}}
    3. 识别结果
    4. 词汇的字符串:
    5. {{item.item}}
    6. 命名实体类型:
    7. {{item.ne !== '' ? item.ne : '暂无'}}
    8. 词性:
    9. {{item.pos !== '' ? item.pos : '暂无'}}
    10. 识别出错,请到控制台查看信息
    11. nlpLexerCustom

    返回值示例

    • JSON
     
     
     
    1. {
    2. "text":"百度是一家高科技公司",
    3. "items":[
    4. {
    5. "byte_length":4,
    6. "byte_offset":0,
    7. "formal":"",
    8. "item":"百度",
    9. "ne":"ORG",
    10. "pos":"",
    11. "uri":"",
    12. "loc_details":[ ],
    13. "basic_words":["百度"]
    14. },
    15. {
    16. "byte_length":2,
    17. "byte_offset":4,
    18. "formal":"",
    19. "item":"是",
    20. "ne":"",
    21. "pos":"v",
    22. "uri":"",
    23. "loc_details":[ ],
    24. "basic_words":["是"]
    25. },
    26. {
    27. "byte_length":4,
    28. "byte_offset":6,
    29. "formal":"",
    30. "item":"一家",
    31. "ne":"",
    32. "pos":"m",
    33. "uri":"",
    34. "loc_details":[ ],
    35. "basic_words":["一","家"]
    36. },
    37. {
    38. "byte_length":6,
    39. "byte_offset":10,
    40. "formal":"",
    41. "item":"高科技",
    42. "ne":"",
    43. "pos":"n",
    44. "uri":"",
    45. "loc_details":[ ],
    46. "basic_words":["高","科技"]
    47. },
    48. {
    49. "byte_length":4,
    50. "byte_offset":16,
    51. "formal":"",
    52. "item":"公司",
    53. "ne":"",
    54. "pos":"n",
    55. "uri":"",
    56. "loc_details":[ ],
    57. "basic_words":["公司"]
    58. }
    59. ]
    60. }

    分享题目:创新互联百度小程序教程:swan.ai.nlpLexerCustom
    当前链接:http://wkslyf.com/article/dhspscg.html