-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/master' into dong
- Loading branch information
Showing
8 changed files
with
108 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package com.java.lwzdhw.utils; | ||
|
||
import com.java.lwzdhw.bean.News; | ||
|
||
import java.util.HashSet; | ||
import java.util.Set; | ||
import java.util.Vector; | ||
|
||
public class MaskHandler { | ||
private static MaskHandler instance = null; | ||
private Set<String> badWords = new HashSet<>(); | ||
final private static double minThreshold = 0.5; | ||
|
||
private MaskHandler(){ | ||
|
||
} | ||
public void add(final String word){ | ||
badWords.add(word); | ||
} | ||
|
||
public void remove(final String word){ | ||
badWords.remove(word); | ||
} | ||
|
||
public void flush(){ | ||
badWords.clear(); | ||
} | ||
|
||
public boolean check(final News news){ | ||
if(badWords.size() == 0) return true; | ||
News.ScoreWord[] keywords = news.getKeywords(); | ||
Vector<String> vector = new Vector<>(); | ||
for (int i = 0 ; i < keywords.length ; ++i){ | ||
if (keywords[i].score > minThreshold && badWords.contains(keywords[i].word)) | ||
return false; | ||
} | ||
return true; | ||
} | ||
|
||
public static MaskHandler getInstance(){ | ||
if(instance == null) { | ||
instance = new MaskHandler(); | ||
} | ||
return instance; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters