Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -148,31 +148,50 @@ abstract class ExtractionManager(

protected def loadMappingPages(language : Language) : Map[WikiTitle, WikiPage] =
{
val namespace = language.wikiCode match {
case "wikidata" =>
Namespace.mappings(Language.English)
case _ =>
Namespace.mappings.getOrElse(language, throw new NoSuchElementException("no mapping namespace for language "+language.wikiCode))
}
val namespaceOpt = language.wikiCode match {
case "wikidata" =>
Some(Namespace.mappings(Language.English))
case _ =>
Namespace.mappings.get(language)
}

if (namespaceOpt.isEmpty) {
logger.warning(
s"No mapping namespace for language ${language.wikiCode} – skipping mapping pages."
)
return Map.empty
}

val source = if (paths.mappingsDir != null && paths.mappingsDir.isDirectory)
{
val file = new File(paths.mappingsDir, namespace.name(Language.Mappings).replace(' ','_')+".xml")
if(!file.exists()) {
logger.warning("MAPPING FILE [" + file + "] DOES NOT EXIST! WILL BE IGNORED")
return Map[WikiTitle, WikiPage]()
}
logger.warning("LOADING MAPPINGS NOT FROM SERVER, BUT FROM LOCAL FILE ["+file+"] - MAY BE OUTDATED - ONLY FOR TESTING!")
XMLSource.fromFile(file, language) // TODO: use Language.Mappings?
}
else
{
val url = paths.apiUrl
WikiSource.fromNamespaces(Set(namespace), url, language) // TODO: use Language.Mappings?
val namespace = namespaceOpt.get

val source = if (paths.mappingsDir != null && paths.mappingsDir.isDirectory)
{
val file = new File(
paths.mappingsDir,
namespace.name(Language.Mappings).replace(' ','_') + ".xml"
)

if (!file.exists()) {
logger.warning(
"MAPPING FILE [" + file + "] DOES NOT EXIST! WILL BE IGNORED"
)
return Map.empty
}

source.map(page => (page.title, page)).toMap
logger.warning(
"LOADING MAPPINGS NOT FROM SERVER, BUT FROM LOCAL FILE [" + file +
"] - MAY BE OUTDATED - ONLY FOR TESTING!"
)

XMLSource.fromFile(file, language)
}
else
{
val url = paths.apiUrl
WikiSource.fromNamespaces(Set(namespace), url, language)
}

source.map(page => (page.title, page)).toMap
}

protected def loadOntology() : Ontology =
Expand Down
Loading