Skip to content

Commit

Permalink
Blacklist -> Stoplist
Browse files Browse the repository at this point in the history
  • Loading branch information
shafirov committed Jun 10, 2020
1 parent 228d007 commit e2d8a74
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
File renamed without changes.
8 changes: 4 additions & 4 deletions src/swot/Compiler.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}

Expand All @@ -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"))
}
8 changes: 4 additions & 4 deletions src/swot/Swot.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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> {
Expand All @@ -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()
Expand Down

0 comments on commit e2d8a74

Please sign in to comment.