|
@@ -158,8 +158,12 @@ public class AdwebEnquiryServiceImpl extends ServiceImpl<AdwebEnquiryMapper, Adw
|
|
|
private static final String EMAIL_PUBLIC_BLACKLIST_REASON = "系统操作-通过公共的询盘邮箱黑名单检测到垃圾询盘-%s";
|
|
|
private static final String EMAIL_SITE_BLACKLIST_REASON = "系统操作-通过站点的询盘邮箱黑名单检测到垃圾询盘-%s";
|
|
|
private static final String IP_BLACKLIST_REASON = "系统操作-通过询盘公共和站点ip黑名单检测到垃圾询盘-%s";
|
|
|
+ private static final String IP_PUBLIC_BLACKLIST_REASON = "系统操作-通过询盘公共ip黑名单检测到垃圾询盘-%s";
|
|
|
+ private static final String IP_SITE_BLACKLIST_REASON = "系统操作-通过询盘站点ip黑名单检测到垃圾询盘-%s";
|
|
|
private static final String URL_BLACKLIST_REASON = "系统操作-通过站点url检测到垃圾询盘-%s";
|
|
|
private static final String KEYWORD_BLACKLIST_REASON = "系统操作-通过公共和站点关键词黑名单检测到垃圾询盘-%s";
|
|
|
+ private static final String KEYWORD_PUBLIC_BLACKLIST_REASON = "系统操作-通过公共关键词黑名单检测到垃圾询盘-%s";
|
|
|
+ private static final String KEYWORD_SITE_BLACKLIST_REASON = "系统操作-通过站点关键词黑名单检测到垃圾询盘-%s";
|
|
|
private static final String LONG_WORD_REASON = "系统操作-通过单词长度超过50个字符检测到垃圾询盘";
|
|
|
|
|
|
@Value("${judge_waste_enquiry.email.tenMinNum}")
|
|
@@ -225,13 +229,11 @@ public class AdwebEnquiryServiceImpl extends ServiceImpl<AdwebEnquiryMapper, Adw
|
|
|
* @param enquiryDto 询盘对象
|
|
|
* @return
|
|
|
*/
|
|
|
- public void addEnquiry(EnquiryDTO enquiryDto, String plugin, List<AdwebSite> adwebSites) {
|
|
|
+ public void addEnquiry(EnquiryDTO enquiryDto, String plugin, AdwebSite adwebSite) {
|
|
|
log.info("=============开始进行询盘处理==============:{}", enquiryDto.getSiteHost());
|
|
|
// 获取公共黑名单关键词
|
|
|
List<String> blackWordList = getPublicEnquiryRules(0, 0);
|
|
|
|
|
|
- AdwebSite adwebSite = adwebSites.get(0);
|
|
|
-
|
|
|
// 获取子账户
|
|
|
Map<String, String> principalEmailMap = new HashMap<>();
|
|
|
List<String> subAccountIdList =
|
|
@@ -286,15 +288,16 @@ public class AdwebEnquiryServiceImpl extends ServiceImpl<AdwebEnquiryMapper, Adw
|
|
|
// 获取最近一周的询盘数量,根据域名和record id 生成唯一标识,存入redis,用来过滤之后的询盘mq,防止重复消费
|
|
|
// 记录开始时间
|
|
|
long startTime = System.currentTimeMillis();
|
|
|
- if (adwebRedisUtil.hasKey(EnquiryUniqueKey + target.getSiteHost())) {
|
|
|
- List<String> enquiryUniqueIds =
|
|
|
- (List<String>) adwebRedisUtil.get(EnquiryUniqueKey + target.getSiteHost());
|
|
|
+ String EnquiryRedisUniqueKey = EnquiryUniqueKey + target.getSiteHost();
|
|
|
+
|
|
|
+ if (adwebRedisUtil.hasKey(EnquiryRedisUniqueKey)) {
|
|
|
+ List<String> enquiryUniqueIds = getListFromRedis(EnquiryRedisUniqueKey);
|
|
|
|
|
|
// 防止redis 唯一键存储过大,并始终更新
|
|
|
enquiryUniqueIds.remove(enquiryUniqueIds.size() - 1); // 移除第一个唯一键
|
|
|
enquiryUniqueIds.add(target.getSiteHost() + target.getRecordId()); // 添加最新的唯一键
|
|
|
|
|
|
- adwebRedisUtil.set(EnquiryUniqueKey + target.getSiteHost(), enquiryUniqueIds, 60 * 60 * 24);
|
|
|
+ adwebRedisUtil.set(EnquiryRedisUniqueKey, enquiryUniqueIds, 60 * 60 * 24);
|
|
|
|
|
|
} else {
|
|
|
Date start = DateUtil.addDays(new Date(), -7);
|
|
@@ -310,7 +313,7 @@ public class AdwebEnquiryServiceImpl extends ServiceImpl<AdwebEnquiryMapper, Adw
|
|
|
.map(enquiry -> enquiry.getSiteHost() + enquiry.getRecordId())
|
|
|
.collect(Collectors.toList());
|
|
|
|
|
|
- adwebRedisUtil.set(EnquiryUniqueKey + target.getSiteHost(), enquiryUniqueIds, 60 * 60 * 24);
|
|
|
+ adwebRedisUtil.set(EnquiryRedisUniqueKey, enquiryUniqueIds, 60 * 60 * 24);
|
|
|
}
|
|
|
}
|
|
|
// 记录结束时间
|
|
@@ -1082,7 +1085,7 @@ public class AdwebEnquiryServiceImpl extends ServiceImpl<AdwebEnquiryMapper, Adw
|
|
|
isJudgeWasteEnquiry = adwebEnquiry;
|
|
|
|
|
|
// 判断询盘邮箱黑名单
|
|
|
- boolean shotTarget =
|
|
|
+ boolean shotTargetEmail =
|
|
|
dealEmailBlackList(
|
|
|
adwebEnquiry,
|
|
|
blackEmailList,
|
|
@@ -1090,152 +1093,46 @@ public class AdwebEnquiryServiceImpl extends ServiceImpl<AdwebEnquiryMapper, Adw
|
|
|
siteWhiteEmailList,
|
|
|
siteBlackEmailList);
|
|
|
|
|
|
- // 命中后跳出循环
|
|
|
- if (shotTarget) {
|
|
|
+ // 命中邮箱黑名单后跳出循环
|
|
|
+ if (shotTargetEmail) {
|
|
|
continue outerloop;
|
|
|
}
|
|
|
|
|
|
// 判断是否为ip黑名单
|
|
|
- if (CollectionUtils.isNotEmpty(blackIpList)
|
|
|
- || StringUtils.isNotBlank(adwebEnquiry.getCustomerIp())) {
|
|
|
- String ip = adwebEnquiry.getCustomerIp();
|
|
|
- // 公共ip黑名单
|
|
|
- boolean isPublicIp = false;
|
|
|
- if (publicBlackIpList.contains(ip) && !publicWhiteIpList.contains(ip)) {
|
|
|
- isPublicIp = true;
|
|
|
- }
|
|
|
-
|
|
|
- // 站点ip黑名单
|
|
|
- boolean isSiteIp = false;
|
|
|
- if (siteBlackIpList.contains(ip) && !siteWhiteIpList.contains(ip)) {
|
|
|
- isSiteIp = true;
|
|
|
- }
|
|
|
- if (isPublicIp && isSiteIp) {
|
|
|
- String reason = String.format(IP_BLACKLIST_REASON, ip);
|
|
|
- markAsWasteEnquiry(adwebEnquiry, reason, "ip");
|
|
|
- logInfo(adwebEnquiry, reason);
|
|
|
- continue;
|
|
|
- }
|
|
|
- if (isPublicIp) {
|
|
|
- adwebEnquiry.setEffectiveReason("系统操作-通过询盘公共ip黑名单检测到垃圾询盘-" + ip);
|
|
|
- log.info(
|
|
|
- "询盘id是:{}, 站点code是:{}, 通过——询盘公共ip黑名单——检测到垃圾询盘, ip是:{}",
|
|
|
- adwebEnquiry.getId(),
|
|
|
- adwebEnquiry.getSiteCode(),
|
|
|
- ip);
|
|
|
- continue;
|
|
|
- }
|
|
|
- if (isSiteIp) {
|
|
|
- adwebEnquiry.setEffectiveReason("系统操作-通过询盘站点ip黑名单检测到垃圾询盘-" + ip);
|
|
|
- log.info(
|
|
|
- "询盘id是:{}, 站点code是:{}, 通过——询盘站点ip黑名单——检测到垃圾询盘, ip是:{}",
|
|
|
- adwebEnquiry.getId(),
|
|
|
- adwebEnquiry.getSiteCode(),
|
|
|
- ip);
|
|
|
- continue;
|
|
|
- }
|
|
|
+ boolean shotTargetIp =
|
|
|
+ dealIpBlackList(
|
|
|
+ adwebEnquiry,
|
|
|
+ blackIpList,
|
|
|
+ publicBlackIpList,
|
|
|
+ publicWhiteIpList,
|
|
|
+ siteWhiteIpList,
|
|
|
+ siteBlackIpList);
|
|
|
+ // 命中IP黑名单后跳出循环
|
|
|
+ if (shotTargetIp) {
|
|
|
+ continue;
|
|
|
}
|
|
|
|
|
|
// 判断邮箱是否包含外部链接
|
|
|
- List<String> urlList = parser(adwebEnquiry.getMessage());
|
|
|
- if (StringUtils.isNotBlank(adwebSite.getDomain())) {
|
|
|
- for (String url : urlList) {
|
|
|
- if (!adwebSite.getDomain().contains(url)) {
|
|
|
- adwebEnquiry.setWasteEnquiry(1);
|
|
|
- adwebEnquiry.setUserEffective(0);
|
|
|
- adwebEnquiry.setWasteEnquiryType("other");
|
|
|
- adwebEnquiry.setEffectiveReason("系统操作-通过站点url检测到垃圾询盘-" + url);
|
|
|
- log.info(
|
|
|
- "询盘id是:{}, 站点code是:{}, 通过——站点url——检测到垃圾询盘",
|
|
|
- adwebEnquiry.getId(),
|
|
|
- adwebEnquiry.getSiteCode());
|
|
|
- continue outerloop;
|
|
|
- }
|
|
|
- }
|
|
|
- } else {
|
|
|
- if (CollectionUtils.isNotEmpty(urlList)) {
|
|
|
- adwebEnquiry.setWasteEnquiry(1);
|
|
|
- adwebEnquiry.setUserEffective(0);
|
|
|
- adwebEnquiry.setWasteEnquiryType("other");
|
|
|
- adwebEnquiry.setEffectiveReason("系统操作-通过站点url检测到垃圾询盘-空");
|
|
|
- log.info(
|
|
|
- "询盘id是:{}, 站点code是:{}, 通过——站点url——检测到垃圾询盘",
|
|
|
- adwebEnquiry.getId(),
|
|
|
- adwebEnquiry.getSiteCode());
|
|
|
- continue;
|
|
|
- }
|
|
|
+ boolean isShotTargetLink = dealMessageContentUrl(adwebEnquiry, adwebSite);
|
|
|
+ // 如果询盘内容包含外部链接,命中处理后跳出循环
|
|
|
+ if (isShotTargetLink) {
|
|
|
+ continue;
|
|
|
}
|
|
|
|
|
|
// 判断询盘是否包含关键词
|
|
|
- String message =
|
|
|
- adwebEnquiry
|
|
|
- .getMessage()
|
|
|
- .replaceAll("[\\n\\t]", " ")
|
|
|
- .replaceAll(" {2,}", " ")
|
|
|
- .toLowerCase();
|
|
|
- if (CollectionUtils.isNotEmpty(blackWordList)
|
|
|
- || CollectionUtils.isNotEmpty(siteBlackRuleList)) {
|
|
|
- // 公共关键词黑名单
|
|
|
- boolean isPublicWord = false;
|
|
|
- String isBlackWord = "";
|
|
|
- for (String blackWord : blackWordList) {
|
|
|
- if (message.contains(blackWord)) {
|
|
|
- isPublicWord = true;
|
|
|
- isBlackWord = blackWord;
|
|
|
- }
|
|
|
- }
|
|
|
- // 站点关键词黑名单
|
|
|
- boolean isSiteWord = false;
|
|
|
- for (AdwebSiteEnquiryRule siteBlackRule : siteBlackRuleList) {
|
|
|
- if (message.contains(siteBlackRule.getWord())) {
|
|
|
- isSiteWord = true;
|
|
|
- isBlackWord = siteBlackRule.getWord();
|
|
|
- }
|
|
|
- }
|
|
|
- if (isPublicWord || isSiteWord) {
|
|
|
- adwebEnquiry.setWasteEnquiry(1);
|
|
|
- adwebEnquiry.setUserEffective(0);
|
|
|
- adwebEnquiry.setWasteEnquiryType("keyword");
|
|
|
- }
|
|
|
- if (isPublicWord && isSiteWord) {
|
|
|
- adwebEnquiry.setEffectiveReason("系统操作-通过公共和站点关键词黑名单检测到垃圾询盘-" + isBlackWord);
|
|
|
- log.info(
|
|
|
- "询盘id是:{}, 站点code是:{}, 通过——公共和站点关键词黑名单——检测到垃圾询盘, 关键词是:{}",
|
|
|
- adwebEnquiry.getId(),
|
|
|
- adwebEnquiry.getSiteCode(),
|
|
|
- isBlackWord);
|
|
|
- continue outerloop;
|
|
|
- }
|
|
|
- if (isPublicWord) {
|
|
|
- adwebEnquiry.setEffectiveReason("系统操作-通过公共关键词黑名单检测到垃圾询盘-" + isBlackWord);
|
|
|
- log.info(
|
|
|
- "询盘id是:{}, 站点code是:{}, 通过——公共关键词黑名单——检测到垃圾询盘, 关键词是:{}",
|
|
|
- adwebEnquiry.getId(),
|
|
|
- adwebEnquiry.getSiteCode(),
|
|
|
- isBlackWord);
|
|
|
- continue outerloop;
|
|
|
- }
|
|
|
- if (isSiteWord) {
|
|
|
- adwebEnquiry.setEffectiveReason("系统操作-通过站点关键词黑名单检测到垃圾询盘-" + isBlackWord);
|
|
|
- log.info(
|
|
|
- "询盘id是:{}, 站点code是:{}, 通过——站点关键词黑名单——检测到垃圾询盘, 关键词是:{}",
|
|
|
- adwebEnquiry.getId(),
|
|
|
- adwebEnquiry.getSiteCode(),
|
|
|
- isBlackWord);
|
|
|
- continue outerloop;
|
|
|
- }
|
|
|
+ boolean isShotTargetKeyword =
|
|
|
+ dealMessageContentKeyWords(adwebEnquiry, blackWordList, siteBlackRuleList);
|
|
|
+
|
|
|
+ // 如果询盘内容包含外关键词黑命中的关键词,命中处理后跳出循环
|
|
|
+ if (isShotTargetKeyword) {
|
|
|
+ continue outerloop;
|
|
|
}
|
|
|
|
|
|
// 分词判断
|
|
|
if (validateWordLength(adwebEnquiry.getMessage())) {
|
|
|
- adwebEnquiry.setWasteEnquiry(1);
|
|
|
- adwebEnquiry.setUserEffective(0);
|
|
|
- adwebEnquiry.setWasteEnquiryType("other");
|
|
|
- adwebEnquiry.setEffectiveReason("系统操作-通过单词长度超过50个字符检测到垃圾询盘");
|
|
|
- log.info(
|
|
|
- "询盘id是:{}, 站点code是:{}, 通过——单词长度超过50个字符——检测到垃圾询盘",
|
|
|
- adwebEnquiry.getId(),
|
|
|
- adwebEnquiry.getSiteCode());
|
|
|
+ String reason = String.format(LONG_WORD_REASON);
|
|
|
+ markAsWasteEnquiry(adwebEnquiry, reason, "other");
|
|
|
+ logInfo(adwebEnquiry, reason);
|
|
|
continue;
|
|
|
}
|
|
|
|
|
@@ -1257,6 +1154,7 @@ public class AdwebEnquiryServiceImpl extends ServiceImpl<AdwebEnquiryMapper, Adw
|
|
|
if (isBlackFlag) {
|
|
|
continue;
|
|
|
}
|
|
|
+ // 设置为正常询盘
|
|
|
adwebEnquiry.setWasteEnquiry(0);
|
|
|
adwebEnquiry.setUserEffective(2);
|
|
|
// 此处为正常询盘,清除疑似垃圾询盘可能性
|
|
@@ -1430,6 +1328,138 @@ public class AdwebEnquiryServiceImpl extends ServiceImpl<AdwebEnquiryMapper, Adw
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ /** 询盘处理IP黑名单 */
|
|
|
+ private boolean dealIpBlackList(
|
|
|
+ AdwebEnquiry adwebEnquiry,
|
|
|
+ List<String> blackIpList,
|
|
|
+ List<String> publicBlackIpList,
|
|
|
+ List<String> publicWhiteIpList,
|
|
|
+ List<String> siteWhiteIpList,
|
|
|
+ List<String> siteBlackIpList) {
|
|
|
+ if (CollectionUtils.isNotEmpty(blackIpList)
|
|
|
+ || StringUtils.isNotBlank(adwebEnquiry.getCustomerIp())) {
|
|
|
+ String ip = adwebEnquiry.getCustomerIp();
|
|
|
+ // 公共ip黑名单
|
|
|
+ boolean isPublicIp = publicBlackIpList.contains(ip) && !publicWhiteIpList.contains(ip);
|
|
|
+
|
|
|
+ // 站点ip黑名单
|
|
|
+ boolean isSiteIp = siteBlackIpList.contains(ip) && !siteWhiteIpList.contains(ip);
|
|
|
+
|
|
|
+ // 公共IP黑名单和站点IP黑名单全部命中
|
|
|
+ if (isPublicIp && isSiteIp) {
|
|
|
+ String reason = String.format(IP_BLACKLIST_REASON, ip);
|
|
|
+ markAsWasteEnquiry(adwebEnquiry, reason, "ip");
|
|
|
+ logInfo(adwebEnquiry, reason);
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 公共IP黑名单命中
|
|
|
+ if (isPublicIp) {
|
|
|
+ String reason = String.format(IP_PUBLIC_BLACKLIST_REASON, ip);
|
|
|
+ markAsWasteEnquiry(adwebEnquiry, reason, "ip");
|
|
|
+ logInfo(adwebEnquiry, reason);
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 站点IP黑名单命中
|
|
|
+ if (isSiteIp) {
|
|
|
+ String reason = String.format(IP_SITE_BLACKLIST_REASON, ip);
|
|
|
+ markAsWasteEnquiry(adwebEnquiry, reason, "ip");
|
|
|
+ logInfo(adwebEnquiry, reason);
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ /** 询盘内容处理是否包含外部链接 */
|
|
|
+ private boolean dealMessageContentUrl(AdwebEnquiry adwebEnquiry, AdwebSite adwebSite) {
|
|
|
+ List<String> urlList = parser(adwebEnquiry.getMessage());
|
|
|
+ if (StringUtils.isNotBlank(adwebSite.getDomain())) {
|
|
|
+ for (String url : urlList) {
|
|
|
+
|
|
|
+ // 询盘内容包含外部链接命中
|
|
|
+ if (!adwebSite.getDomain().contains(url)) {
|
|
|
+ String reason = String.format(URL_BLACKLIST_REASON, url);
|
|
|
+ markAsWasteEnquiry(adwebEnquiry, reason, "other");
|
|
|
+ logInfo(adwebEnquiry, reason);
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if (CollectionUtils.isNotEmpty(urlList)) {
|
|
|
+ String reason = String.format(URL_BLACKLIST_REASON, "空");
|
|
|
+ markAsWasteEnquiry(adwebEnquiry, reason, "other");
|
|
|
+ logInfo(adwebEnquiry, reason);
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ /** 询盘内容处理是否包含关键词黑名单 */
|
|
|
+ private boolean dealMessageContentKeyWords(
|
|
|
+ AdwebEnquiry adwebEnquiry,
|
|
|
+ List<String> blackWordList,
|
|
|
+ List<AdwebSiteEnquiryRule> siteBlackRuleList) {
|
|
|
+ String message =
|
|
|
+ adwebEnquiry
|
|
|
+ .getMessage()
|
|
|
+ .replaceAll("[\\n\\t]", " ")
|
|
|
+ .replaceAll(" {2,}", " ")
|
|
|
+ .toLowerCase();
|
|
|
+ if (CollectionUtils.isNotEmpty(blackWordList)
|
|
|
+ || CollectionUtils.isNotEmpty(siteBlackRuleList)) {
|
|
|
+ // 公共关键词黑名单
|
|
|
+ boolean isPublicWord = false;
|
|
|
+ String isBlackWord = "";
|
|
|
+ for (String blackWord : blackWordList) {
|
|
|
+ if (message.contains(blackWord)) {
|
|
|
+ isPublicWord = true;
|
|
|
+ isBlackWord = blackWord;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 站点关键词黑名单
|
|
|
+ boolean isSiteWord = false;
|
|
|
+ for (AdwebSiteEnquiryRule siteBlackRule : siteBlackRuleList) {
|
|
|
+ if (message.contains(siteBlackRule.getWord())) {
|
|
|
+ isSiteWord = true;
|
|
|
+ isBlackWord = siteBlackRule.getWord();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 公共关键词黑名单和站点关键词黑名单全部命中
|
|
|
+ if (isPublicWord && isSiteWord) {
|
|
|
+ String reason = String.format(KEYWORD_BLACKLIST_REASON, isBlackWord);
|
|
|
+ markAsWasteEnquiry(adwebEnquiry, reason, "keyword");
|
|
|
+ logInfo(adwebEnquiry, reason);
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 公共关键词黑名单命中
|
|
|
+ if (isPublicWord) {
|
|
|
+ String reason = String.format(KEYWORD_PUBLIC_BLACKLIST_REASON, isBlackWord);
|
|
|
+ markAsWasteEnquiry(adwebEnquiry, reason, "keyword");
|
|
|
+ logInfo(adwebEnquiry, reason);
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 站点关键词黑名单命中
|
|
|
+ if (isSiteWord) {
|
|
|
+ String reason = String.format(KEYWORD_SITE_BLACKLIST_REASON, isBlackWord);
|
|
|
+ markAsWasteEnquiry(adwebEnquiry, reason, "keyword");
|
|
|
+ logInfo(adwebEnquiry, reason);
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return false;
|
|
|
}
|
|
|
|
|
|
/** 标记为垃圾询盘 */
|
|
@@ -1674,6 +1704,13 @@ public class AdwebEnquiryServiceImpl extends ServiceImpl<AdwebEnquiryMapper, Adw
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 验证文本中的最长单词长度是否超过限制 此方法用于确保文本中的任何单词长度不超过系统定义的最大值 它首先检查文本是否为空,然后获取文本中最长单词的长度
|
|
|
+ * 接着,它从系统字典中读取最大单词长度的限制,如果未设置,则使用默认值 最后,比较最长单词长度与限制,决定是否返回true
|
|
|
+ *
|
|
|
+ * @param text 待验证的文本
|
|
|
+ * @return 如果文本中的最长单词长度超过限制,则返回true;否则返回false
|
|
|
+ */
|
|
|
private boolean validateWordLength(String text) {
|
|
|
if (StringUtil.isEmpty(text)) {
|
|
|
return false;
|
|
@@ -1689,6 +1726,13 @@ public class AdwebEnquiryServiceImpl extends ServiceImpl<AdwebEnquiryMapper, Adw
|
|
|
return (maxWordLength > limit);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 解析给定文本中的URL和邮箱 该方法首先使用正则表达式匹配文本中的URL,包括常见的网络协议方案 然后根据预定义的域名模式或默认模式匹配特定的域名
|
|
|
+ * 同时,方法也提取文本中的邮箱地址,并将其拆分为用户名和域名部分 最后,方法确保如果一个邮箱地址被错误地识别为URL,则将其从URL列表中移除
|
|
|
+ *
|
|
|
+ * @param text 待解析的文本
|
|
|
+ * @return 包含所有识别到的URL的列表
|
|
|
+ */
|
|
|
private List<String> parser(String text) {
|
|
|
Pattern pattern1 = Pattern.compile("(https?|ftp|file)://([-a-zA-Z0-9]+\\.)+[a-zA-Z0-9]+");
|
|
|
List<String> domainPatterns = getFormKeys("enquiry_domain_pattern");
|