本文整理汇总了Scala中scala.reflect.io.Directory类的典型用法代码示例。如果您正苦于以下问题:Scala Directory类的具体用法?Scala Directory怎么用?Scala Directory使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Directory类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Scala代码示例。
示例1: NoGroundTruthImportTest
//设置package包名称以及导入依赖的类
package org.opencompare.io.wikipedia
import org.opencompare.io.wikipedia.io.{MediaWikiAPI, WikiTextLoader, WikiTextTemplateProcessor}
import org.scalatest.prop.TableDrivenPropertyChecks._
import org.scalatest.prop.Tables.Table
import org.scalatest.{FlatSpec, Matchers}
import scala.collection.JavaConversions._
import scala.io.Source
import scala.reflect.io.Directory
class NoGroundTruthImportTest extends FlatSpec with Matchers {
val language = "en"
val url = "wikipedia.org"
val mediaWikiAPI = new MediaWikiAPI(url)
val miner = new WikiTextLoader(new WikiTextTemplateProcessor(mediaWikiAPI))
def getResources: List[java.io.File] = {
val classLoader = getClass().getClassLoader()
val path = classLoader.getResource("wikitext/")
val file = new java.io.File(path.getPath)
val folder = new Directory(file)
val files = folder.files.filter(_.isFile)
files.map(file => new java.io.File(file.path)).toList
}
val inputs = Table(
"wikitext", getResources: _*
)
forAll(inputs) { file =>
it should "import " + file.getName in {
val wikitext = Source.fromFile(file).mkString
val containers = miner.mine(language, wikitext, file.getName)
for (container <- containers) {
val pcm = container.getPcm
withClue("Name")(pcm.getName.size should not be (0))
withClue("Features")(pcm.getConcreteFeatures.size() should not be (0))
withClue("Products")(pcm.getProducts.size() should not be (0))
}
}
}
}