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); } }
时刻记着自己要成为什么样的人!
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
· 分享4款.NET开源、免费、实用的商城系统
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
· 上周热点回顾(2.24-3.2)