美文网首页
word分词器使用(java)

word分词器使用(java)

作者: Quillagua | 来源:发表于2020-12-02 11:00 被阅读0次

    1.在pom.xml中导入依赖

     <dependency>
        <groupId>org.apdplat</groupId>
        <artifactId>word</artifactId>
        <version>1.1</version>
    </dependency>
    
    

    2.在代码中使用

    package com.vortex.commonAPI.controller;
    
    import javax.servlet.http.HttpServletRequest;
    
    import org.apdplat.word.WordSegmenter;
    import org.springframework.web.bind.annotation.RequestMapping;
    import org.springframework.web.bind.annotation.RequestMethod;
    import org.springframework.web.bind.annotation.RestController;
    
    @RestController
    @RequestMapping(value = "wordSegmenter")
    public class WordSegmenterController {
        @RequestMapping(value = "/spliceString", method = RequestMethod.GET)
        public Object spliceString(HttpServletRequest request) {
            String words = request.getParameter("words");
            // 移除停用词进行分词
            // List<Word> list = WordSegmenter.seg(words);
            // 保留停用词
            return WordSegmenter.segWithStopWords(words);
        }
    }
    
    

    3.实例

    image

    相关文章

      网友评论

          本文标题:word分词器使用(java)

          本文链接:https://www.haomeiwen.com/subject/tijrwktx.html