|
From: Sebastian H. <hel...@in...> - 2010-10-12 14:40:38
|
Hi, I'm not so fixed upon using Spring, just Dependency Injection Framework might do. I just wanted to try to see, if Spring worked with Scala and you are right, it works, but only at a price (as the datatypes are not compatible). I didn't yet have time to fully read the cake pattern page and I find it quite complex to understand, as I'm just a Scala toddler ;) Can you make an example based on the Wiktionary module? Just reading the XML file and then print out the subject. as in Text Extractor. Spring already works and one of it's main advantage is the reusability of components and the flexibility: Note that it gets rid of most of the ConfigLoader class and the factory method in XMLSource and additionally the XMLSource could be changed to another Source without changing the code. So you cannot compare the 2 lines directly with the xml. The basic changes needed are that Java datatypes can be passed into the Scala classes. I'm not sure if I fully understand the cake pattern yet. How much work do you think it would take to add to the framework? Have you ever used Guice and can you give the example above? Guice would also be fine, I think. Cheers, Sebastian Am 12.10.2010 13:03, schrieb Robert Isele: > Hi Sebastian, > > I also agree that we should generalize the DBpedia Framework. In my > opinion, it's biggest drawback is the lacking configurability. e.g. at > the moment each extractor takes an ExtractionContext object in its > constructor, which contains the complete configuration even if most > extractors only need a part of it (e.g. some extractors don't need the > ontology in which case it does not need to be loaded). We could gain > much flexibility, if we make this more configurable. > > I see two ways two achieve this: > 1) Using Spring. As I understand, this would make it possible to > configure the complete extraction process including all extractors > using an XML configuration file. > 2) Making the API more flexible. e.g. letting the extractors define > which data they need in a static way (e.g. by using the Cake pattern > [1]). The configuration would then be a small Scala script. > > I will have to take a deeper look into this. The biggest drawback, > that I see with Spring is, that it might not fit smoothly into Scala > and makes the configuration more complicated than necessary. > e.g. comparing the configuration of the XMLFileSource: > Spring: > <bean id="testSource" class="org.dbpedia.extraction.XMLFileSource"> > <constructor-arg index="0"> > <value>file:mediawiki_test_dump.xml</value> > </constructor-arg> > <constructor-arg index="1"> > <list value-type="java.lang.Integer"> > <value>0</value> > </list> > </constructor-arg> > </bean> > > Scala: > XMLSource.fromFile(new File(mediawiki_test_dump.xml), _.namespace == > WikiTitle.Namespace.File) > > For me, the second version looks much clearer and more descriptive. I > understand that using the implementation language itself for > configuration, instead of XML, may sound unusual in the Java World > (although it is advocated by Google Guice [2]). But I think it is much > cleaner and more flexible, than Spring's way of replicating the Java > Beans Model in XML. While this may be a good idea in Java, I think > Scala with it's more concise syntax and better type system, would > provide a perfect way to configure a specific extraction script. > > As I don't know much about Spring yet, especially in the context of > using it together with Scala, I will take a deeper look into it in the > next days. As we are planning to make another release of DBpedia in a > few weeks, I can also commit some time into improving the framework, > but will discuss it over the list before making any bigger > refactoring. > > [1] http://jonasboner.com/2008/10/06/real-world-scala-dependency-injection-di.html > [2] http://code.google.com/p/google-guice/ > > On Mon, Oct 11, 2010 at 11:53 PM, Sebastian Hellmann > <hel...@in...> wrote: > >> Hi, >> today, I tried if the framework was compatible with Spring and it works: >> See the Wiktionary module: >> wiktionary/src/main/resources/config.xml >> wiktionary/src/main/scala/org.dbpedia.extraction.wiktionary.Extract line 32 >> wiktionary/src/main/scala/org.dbpedia.extraction.XMLFileSource >> (in XMLFileSource note that I didn't succeed to do the conversion here >> correctly on line 19) >> wiktionary/src/main/scala/org.dbpedia.extraction.mappints/TestExtractor >> >> Per default all resources instantiated with spring are singletons. >> This might be useful for stuff like the ontology source or the commons. >> These can be injected easily into the extractors without the >> ExtractionContext. >> We would gain quite some flexibility with that. One of the LOD2 tasks is >> about generalizing the Framework software, >> which would be easily achived, if we had a Wiktionary dump ;) >> >> - @Robert/Max Please review and give feedback ASAP, I'm only here for 10 >> more days. >> - Could somebody add Jonas to the developers list... I seem to have the >> forgotten the password. >> >> Cheers, >> Sebastian >> >> >> >> >> -- >> Dipl. Inf. Sebastian Hellmann >> Department of Computer Science, University of Leipzig >> Homepage: http://bis.informatik.uni-leipzig.de/SebastianHellmann >> Research Group: http://aksw.org >> >> >> ------------------------------------------------------------------------------ >> Beautiful is writing same markup. Internet Explorer 9 supports >> standards for HTML5, CSS3, SVG 1.1, ECMAScript5, and DOM L2& L3. >> Spend less time writing and rewriting code and more time creating great >> experiences on the web. Be a part of the beta today. >> http://p.sf.net/sfu/beautyoftheweb >> _______________________________________________ >> Dbpedia-developers mailing list >> Dbp...@li... >> https://lists.sourceforge.net/lists/listinfo/dbpedia-developers >> >> -- Dipl. Inf. Sebastian Hellmann Department of Computer Science, University of Leipzig Homepage: http://bis.informatik.uni-leipzig.de/SebastianHellmann Research Group: http://aksw.org |