• java anchor 发现


    package example;
    
    import com.alibaba.fastjson.JSON;
    import com.alibaba.fastjson.JSONObject;
    import com.techwolf.oceanus.text.understand.util.FileUtil;
    
    import java.io.IOException;
    import java.util.*;
    import java.util.regex.Matcher;
    import java.util.regex.Pattern;
    
    public class AnchorEscapeTest {
    
        private static int basePositionCode = 170610;
        private static int targetPositionCode = 170625;
        private static String targetPositionName = "传媒 | 影视媒体 | 带货主播";
        private static final String PARAMS_PATH = "escape/anchor_escape_params.json";
    
        private static String paramStr;
    
        static {
            try {
                paramStr = FileUtil.readString(PARAMS_PATH, "UTF-8");
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    
        private static JSONObject ob = JSON.parseObject(paramStr);
        private static Pattern prefixCodePattern = Pattern.compile(ob.getString("prefixCode"));
        private static Pattern titleOrJdOnePattern = Pattern.compile(ob.getString("keywordsOne"));
        private static Pattern titleOrJdTwoPattern = Pattern.compile(ob.getString("keywordsTwo"));
        private static Pattern titleOrJdThreePattern = Pattern.compile(ob.getString("keywordsThree"));
        private static Pattern titleExcludeOnePattern = Pattern.compile(ob.getString("keywordsFour"));
        private static Pattern jdExcludeTwoPattern = Pattern.compile(ob.getString("keywordsFive"));
    
        public AnchorEscapeTest() throws IOException {
        }
    
        public static boolean checkAnchor(String positionTitle, String positionDesc) {
            String title = positionTitle.toLowerCase();
            String desc = positionDesc.toLowerCase();
            Matcher leveOneMatcher = prefixCodePattern.matcher(Integer.toString(positionCode).substring(0, 3));
            Matcher titleOneMatcher = titleOrJdOnePattern.matcher(title);
            Matcher jdOneMatcher = titleOrJdOnePattern.matcher(desc);
            Matcher titleTwoMatcher = titleOrJdTwoPattern.matcher(title);
            Matcher jdTwoMatcher = titleOrJdTwoPattern.matcher(desc);
            Matcher titleThreeMatcher = titleOrJdThreePattern.matcher(title);
            Matcher jdThreeMatcher = titleOrJdThreePattern.matcher(desc);
            Matcher titleExcludeMatcher = titleExcludeOnePattern.matcher(title);
            Matcher jdExcludeMatcher = jdExcludeTwoPattern.matcher(desc);
    
            boolean isAnchor = false;
            if (leveOneMatcher.find() && Objects.equals(positionResults.get(0).positionCode, basePositionCode)) { // 在特定一级类下,并且三级类=170610
                if ((titleOneMatcher.find() || jdOneMatcher.find()) && (titleTwoMatcher.find() || jdTwoMatcher.find()) ||
                        (titleThreeMatcher.find() || jdThreeMatcher.find())) {
                    if (!(titleExcludeMatcher.find() || jdExcludeMatcher.find())) {
                        isAnchor = true;
                    }
                }
            }
            return isAnchor;
        }
    
        public static void main(String[] args) throws IOException {
            String title = "招电商主播,这个是";
            String desc = "这是你的机会,快来参与,速";
            // 带货主播识别
            boolean res = checkAnchor(title, desc);
        }
    }
    时刻记着自己要成为什么样的人!
  • 相关阅读:
    ggplot2 上篇
    R笔记1
    读书笔记 第2章 数据挖掘概述
    读书笔记 数据化营销
    [LeetCode] 172. 阶乘后的零
    [LeetCode] 171. Excel表列序号
    [LeetCode] 169. 求众数
    知乎使用selenium反爬虫的解决方案
    [LeetCode] 168. Excel表列名称
    [LeetCode] 167. 两数之和 II
  • 原文地址:https://www.cnblogs.com/demo-deng/p/15327613.html
Copyright © 2020-2023  润新知