GithubHelp home page GithubHelp logo

words-match's Introduction

words match

字符串匹配,使用DFA算法实现

-
word 你好 你好吗 你好吗 helloworld
content 你好啊 你好好吗 你好,吗 hello world
模糊匹配 ×
精确匹配 × × ×

Rule

  • 中英混合word: 精确匹配
  • word含有空格: 精确匹配
  • word含有数字: 模糊匹配
  • word最小长度: 2

usage

<dependency>
    <groupId>io.github.fzdwx</groupId>
    <artifactId>words-match</artifactId>
    <version>0.10.2</version>
</dependency>

code

  private static Collection<String> words=new HashSet<String>(){
        {
        add("**人");
        add("**男人");
        add("**人民");
        add("人民");
        add("中间");
        add("女人");
        add("一举");
        add("一举成名");
        add("一举成名走四方");
        add("成名");
        add("走四方");
        add("zzz");
        add("hello");
        add("Qwe");
        add("你好aa");
        add("qweFJAKf");
        add("hhhasd");
        }
        };

final String content="中1国1人,民,一zzz举,he*l l.oQWE你好aa  qWefJAkf,h1...h1h1a1S1D";

final WordsMatcher accurate=WordsMatcher.accurate(words);
final WordsAction action=this.accurate.action(this.content);
final Map<String, String> all=action.findAll();

more

todo

  • 简体繁体
  • 半角圆角
  • 若一个word在content中匹配到了多次,如何保存?
    • 现在是覆盖,保留最后一个
  • replace 方法不能替换*
  • more

words-match's People

Contributors

fzdwx avatar

Stargazers

 avatar

Watchers

 avatar

words-match's Issues

半角圆角

Discussed in #4

Originally posted by fzdwx March 12, 2022
no desc

replace 方法不能替换*

String#replace()不能替换带*的字符
原因:用的正则匹配的

word: hello
matchWord: he*l l.o
content: 中1国1人,民,一zzz举,he*l l.oQWE你好aa  qWefJAkf,h1...h1h1a1S1D

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.