Code Monkey home page Code Monkey logo

Comments (6)

shi-yuan avatar shi-yuan commented on June 16, 2024

是不让包含这个短语的结果搜出来,还是需要搜出来只是替换成***之类的?

from elasticsearch-analysis-ansj.

chongqiWang avatar chongqiWang commented on June 16, 2024

是不让包含这个短语的结果搜出来,还是需要搜出来只是替换成***之类的?

不让他搜出来

并且把这个短语弄成读取文件的方式

from elasticsearch-analysis-ansj.

shi-yuan avatar shi-yuan commented on June 16, 2024

可以在搜索的时候,加must_not过滤掉

from elasticsearch-analysis-ansj.

chongqiWang avatar chongqiWang commented on June 16, 2024

可以在搜索的时候,加must_not过滤掉

那不是得写很长过滤条件,我主要是对结果过滤,屏蔽短语

from elasticsearch-analysis-ansj.

shi-yuan avatar shi-yuan commented on June 16, 2024

如果短语很多,
如果变化不频繁,可以考虑写索引的时候放进去,这样搜索的时候直接用这个字段来过滤
如果变化频繁,可以在获取到结果集之后,程序里处理

from elasticsearch-analysis-ansj.

shi-yuan avatar shi-yuan commented on June 16, 2024

从内容里提取短语,参考:

词典dic_xxx内容:

战天下	a	1000
天下大乱	a	2000

示例:

import org.ansj.library.DicLibrary;
import org.nlpcn.commons.lang.tire.GetWord;
import org.nlpcn.commons.lang.tire.domain.Forest;
import java.util.Arrays;

public class Test {
    public static void main(String[] args) {
        Forest forest = DicLibrary.get("dic_xxx");
        GetWord gw = forest.getWord("如何实现短语屏蔽功能:天下大乱,云长战吕布,吕布大战天下");
        String word;
        while ((word = gw.getAllWords()) != null) {
            System.out.println(word + "============" + Arrays.toString(gw.getParam()));
        }
    }
}

输出:

天下大乱============[a, 2000]
战天下============[a, 1000]

from elasticsearch-analysis-ansj.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.