有人知道什么工具或者算法,可以将多个词组组成短语?

2019-11-09 15:55:14 +08:00
 Egfly

最近想实现一个这样的功能,来改变一下 elasticsearch 文本搜索的匹配度。
现将字符串 “某数学兴趣小组开展了一次课外活动” 放到 elasticsearch 里去搜索,会使用 ik 分词器 ik_smart 进行分词,分词结果如下:

{
  "tokens" : [
    {
      "token" : "某",
      "start_offset" : 0,
      "end_offset" : 1,
      "type" : "CN_CHAR",
      "position" : 0
    },
    {
      "token" : "数学",
      "start_offset" : 1,
      "end_offset" : 3,
      "type" : "CN_WORD",
      "position" : 1
    },
    {
      "token" : "兴趣小组",
      "start_offset" : 3,
      "end_offset" : 7,
      "type" : "CN_WORD",
      "position" : 2
    },
    {
      "token" : "开展",
      "start_offset" : 7,
      "end_offset" : 9,
      "type" : "CN_WORD",
      "position" : 3
    },
    {
      "token" : "了",
      "start_offset" : 9,
      "end_offset" : 10,
      "type" : "CN_CHAR",
      "position" : 4
    },
    {
      "token" : "一次",
      "start_offset" : 10,
      "end_offset" : 12,
      "type" : "CN_WORD",
      "position" : 5
    },
    {
      "token" : "课外活动",
      "start_offset" : 12,
      "end_offset" : 16,
      "type" : "CN_WORD",
      "position" : 6
    }
  ]
}

但是这样的结果并不能满足的我需求,我想将上面分词后的结果再进行重组,组成新的、有意义的短语,如:一次数学课外活动

请问有没有某种工具或算法能实现这样的需求?

666 次点击
所在节点    问与答
1 条回复
noreplay
2019-11-10 10:29:45 +08:00
试试 gan ?我随便说的哈。手动狗头+滑稽保命😁

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/617921

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX