-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
50 additions
and
4 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
32 changes: 32 additions & 0 deletions
32
scraper/src/main/scala/org/clulab/habitus/scraper/apps/VerifyDownloadsApp.scala
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,32 @@ | ||
package org.clulab.habitus.scraper.apps | ||
|
||
import org.clulab.habitus.scraper.Cleaner | ||
import org.clulab.utils.{FileUtils, Sourcer} | ||
|
||
import java.net.URL | ||
import scala.util.Using | ||
|
||
object VerifyDownloadsApp extends App { | ||
val term = "sitemap" | ||
val corpusFileName = args.lift(0).getOrElse(s"./scraper/corpora/ghana/$term/articlecorpus-filtered.txt") | ||
val baseDirName = args.lift(1).getOrElse("/home/kwa/data/Corpora/habitus-project/corpora/ghana-sitemap/articlesonly/www_ghanaweb_com") | ||
val cleaner = new Cleaner() | ||
|
||
def extractFile(line: String): String = { | ||
val url = new URL(line) | ||
val file = cleaner.clean(url.getFile) + ".html" | ||
|
||
file | ||
} | ||
|
||
val corpusFiles = Using.resource(Sourcer.sourceFromFilename(corpusFileName)) { source => | ||
source.getLines.map(extractFile).toSet | ||
} | ||
|
||
FileUtils.findFiles(baseDirName, "html").foreach { file => | ||
val name = file.getName | ||
|
||
if (!corpusFiles(name)) | ||
println(s"$name is extra!") | ||
} | ||
} |
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