Skip to content

Commit e26ef81

Browse files
committed
change Extractor Trait to accept [T] type argument
1 parent 1411550 commit e26ef81

34 files changed

+55
-43
lines changed

core/src/main/scala/org/dbpedia/extraction/mappings/AbstractExtractor.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class AbstractExtractor(
2424
def language : Language
2525
}
2626
)
27-
extends Extractor
27+
extends Extractor[PageNode]
2828
{
2929
private val maxRetries = 3
3030

core/src/main/scala/org/dbpedia/extraction/mappings/ArticleCategoriesExtractor.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import org.dbpedia.extraction.wikiparser._
1111
*/
1212
class ArticleCategoriesExtractor( context : {
1313
def ontology : Ontology
14-
def language : Language } ) extends Extractor
14+
def language : Language } ) extends Extractor[PageNode]
1515
{
1616
private val dctermsSubjectProperty = context.ontology.properties("dct:subject")
1717

core/src/main/scala/org/dbpedia/extraction/mappings/ArticleTemplatesExtractor.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class ArticleTemplatesExtractor(
1717
def language: Language
1818
def redirects: Redirects
1919
}
20-
) extends Extractor {
20+
) extends Extractor[PageNode] {
2121

2222
// FIXME: this uses the http://xx.dbpedia.org/property/ namespace, but the
2323
// http://dbpedia.org/ontology/ namespace would probably make more sense.

core/src/main/scala/org/dbpedia/extraction/mappings/CategoryLabelExtractor.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import org.dbpedia.extraction.util.Language
1111
*/
1212
class CategoryLabelExtractor( context : {
1313
def ontology : Ontology
14-
def language : Language } ) extends Extractor
14+
def language : Language } ) extends Extractor[PageNode]
1515
{
1616
private val labelProperty = context.ontology.properties("rdfs:label")
1717

core/src/main/scala/org/dbpedia/extraction/mappings/CompositeExtractor.scala

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@ package org.dbpedia.extraction.mappings
22

33
import org.dbpedia.extraction.destinations.Quad
44
import org.dbpedia.extraction.wikiparser.PageNode
5+
import org.dbpedia.extraction.mappings.Extractor
56

6-
class CompositeExtractor(extractors: Mapping[PageNode]*)
7+
class CompositeExtractor(extractors: Seq[Extractor[PageNode]])
78
extends CompositeMapping[PageNode](extractors: _*)
8-
with Extractor
9+
with Extractor[PageNode]
910

1011
/**
1112
* Creates new extractors.
@@ -14,15 +15,25 @@ object CompositeExtractor
1415
{
1516
/**
1617
* Creates a new extractor.
17-
*
18+
*
1819
* TODO: using reflection here loses compile-time type safety.
1920
*
2021
* @param extractors List of extractor classes to be instantiated
2122
* @param context Any type of object that implements the required parameter methods for the extractors
2223
*/
23-
def load(classes: Seq[Class[_ <: Extractor]], context: AnyRef): Extractor =
24+
def load(classes: Seq[Class[_ <: Extractor[_]]], context: AnyRef): Extractor[PageNode] =
2425
{
25-
val extractors = classes.map(_.getConstructor(classOf[AnyRef]).newInstance(context))
26-
new CompositeExtractor(extractors: _*)
26+
val extractors = classes.map(_.getConstructor(classOf[AnyRef]).newInstance(context))
27+
28+
var pageNodeExtractors : Seq[Extractor[PageNode]] = Seq.empty
29+
30+
extractors foreach { extractor : Extractor[_] =>
31+
extractor match {
32+
case ex : Extractor[PageNode] => pageNodeExtractors :+ ex
33+
case _ =>
34+
}
35+
}
36+
37+
new CompositeExtractor(pageNodeExtractors: Seq[Extractor[PageNode]])
2738
}
2839
}

core/src/main/scala/org/dbpedia/extraction/mappings/ContributorExtractor.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import java.net.{URLEncoder, URI}
1616

1717
class ContributorExtractor( context : {
1818
def ontology : Ontology
19-
def language : Language } ) extends Extractor
19+
def language : Language } ) extends Extractor[PageNode]
2020
{
2121

2222
override val datasets = Set(DBpediaDatasets.RevisionMeta)

core/src/main/scala/org/dbpedia/extraction/mappings/DisambiguationExtractor.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class DisambiguationExtractor(
1616
def language : Language
1717
}
1818
)
19-
extends Extractor
19+
extends Extractor[PageNode]
2020
{
2121
private val language = context.language
2222

core/src/main/scala/org/dbpedia/extraction/mappings/ExternalLinksExtractor.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class ExternalLinksExtractor (
1616
def language : Language
1717
}
1818
)
19-
extends Extractor
19+
extends Extractor[PageNode]
2020
{
2121
val wikiPageExternalLinkProperty = context.ontology.properties("wikiPageExternalLink")
2222

core/src/main/scala/org/dbpedia/extraction/mappings/Extractor.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ import org.dbpedia.extraction.wikiparser._
88
* Necessary to get some type safety in CompositeExtractor:
99
* Class[_ <: Extractor] can be checked at runtime, but Class[_ <: Mapping[PageNode]] can not.
1010
*/
11-
trait Extractor extends Mapping[PageNode]
11+
trait Extractor[T] extends Mapping[T]

core/src/main/scala/org/dbpedia/extraction/mappings/FlickrWrapprLinkExtractor.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class FlickrWrapprLinkExtractor (
1717
def language : Language
1818
}
1919
)
20-
extends Extractor
20+
extends Extractor[PageNode]
2121
{
2222
private val language = context.language
2323

0 commit comments

Comments
 (0)