Blacklist -> Stoplist
This commit is contained in:
parent
228d007ed1
commit
e2d8a74529
@ -34,8 +34,8 @@ Change the file contents of the appropriate file.
|
||||
|
||||
A simple `git rm` on the approriate file will do the trick.
|
||||
|
||||
#### Refer the blacklist
|
||||
Please do not suggest to add domains from the blacklist. They're banned for the reason. The list currently looks like follows
|
||||
#### Refer the stoplist
|
||||
Please do not suggest to add domains from the stoplist. They're banned for the reason. The list currently looks like follows
|
||||
* si.edu - anyone could register a domain there
|
||||
* america.edu - anyone could register a domain there
|
||||
* californiacolleges.edu - anyone could register e-mail account there
|
||||
|
||||
@ -7,7 +7,7 @@ import java.io.File
|
||||
*/
|
||||
|
||||
object CompilationState {
|
||||
val blacklist = File("lib/domains/blacklist.txt").readLines().toHashSet()
|
||||
val stoplist = File("lib/domains/stoplist.txt").readLines().toHashSet()
|
||||
val domains = File("lib/domains/tlds.txt").readLines().toHashSet()
|
||||
}
|
||||
|
||||
@ -16,13 +16,13 @@ fun main(args: Array<String>) {
|
||||
root.walkTopDown().forEach {
|
||||
if (it.isFile) {
|
||||
val parts = it.toRelativeString(root).replace('\\', '/').removeSuffix(".txt").split('/').toList()
|
||||
if (!checkSet(CompilationState.blacklist, parts) && !checkSet(CompilationState.domains, parts)) {
|
||||
if (!checkSet(CompilationState.stoplist, parts) && !checkSet(CompilationState.domains, parts)) {
|
||||
CompilationState.domains.add(parts.reversed().joinToString("."))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
val blacklist = CompilationState.blacklist.map { "-$it" }.sorted().joinToString("\n")
|
||||
val stoplist = CompilationState.stoplist.map { "-$it" }.sorted().joinToString("\n")
|
||||
File("out/artifacts").mkdirs()
|
||||
File("out/artifacts/swot.txt").writeText(blacklist + "\n" + CompilationState.domains.sorted().joinToString("\n"))
|
||||
File("out/artifacts/swot.txt").writeText(stoplist + "\n" + CompilationState.domains.sorted().joinToString("\n"))
|
||||
}
|
||||
|
||||
@ -2,7 +2,7 @@ package swot
|
||||
|
||||
fun isAcademic(email: String): Boolean {
|
||||
val parts = domainParts(email)
|
||||
return !isBlacklisted(parts) && (isUnderTLD(parts) || findSchoolNames(parts).isNotEmpty())
|
||||
return !isStoplisted(parts) && (isUnderTLD(parts) || findSchoolNames(parts).isNotEmpty())
|
||||
}
|
||||
|
||||
fun findSchoolNames(emailOrDomain: String): List<String> {
|
||||
@ -13,13 +13,13 @@ fun isUnderTLD(parts: List<String>): Boolean {
|
||||
return checkSet(Resources.tlds, parts)
|
||||
}
|
||||
|
||||
fun isBlacklisted(parts: List<String>): Boolean {
|
||||
return checkSet(Resources.blackList, parts)
|
||||
fun isStoplisted(parts: List<String>): Boolean {
|
||||
return checkSet(Resources.stoplist, parts)
|
||||
}
|
||||
|
||||
private object Resources {
|
||||
val tlds = readList("/tlds.txt") ?: error("Cannot find /tlds.txt")
|
||||
val blackList = readList("/blacklist.txt") ?: error("Cannot find /blacklist.txt")
|
||||
val stoplist = readList("/stoplist.txt") ?: error("Cannot find /stoplist.txt")
|
||||
|
||||
fun readList(resource: String) : Set<String>? {
|
||||
return javaClass.getResourceAsStream(resource)?.reader()?.buffered()?.lineSequence()?.toHashSet()
|
||||
|
||||
Loading…
Reference in New Issue
Block a user