Clojure interop for Scala objects and properties

I am trying to use the Scala library in a Clojure project, but am encountering some problems. How to implement the following Scala code in Clojure?

object LabelDomain extends CategoricalDomain[String] class Label(val token: Token, s: String) extends LabeledCategoricalVariable(s) { def domain = LabelDomain } object FeaturesDomain extends CategoricalDimensionTensorDomain[String] class Features(val token: Token) extends BinaryFeatureVectorVariable[String] { def domain = FeaturesDomain } object model extends ChainModel[Label, Features, Token]( LabelDomain, FeaturesDomain, l => l.token.attr[Features], l => l.token, t => t.attr[Label]) 

CategoricalDomain and CategoricalDimensionTensorDomain are traits. LabeledCategoricalVariable and BinaryFeatureVectorVariable are abstract classes. ChainModel is a class.

+4
source share
1 answer

It looks like you are trying to use FACTORIE with clojure. As a person who loves clojure and works in the laboratory that builds FACTORIE, I would not recommend this. The FACTORIE code base is written in a very imperative style and filled with volatile state. If I got a FACTORIE object in clojure, I would find it very disorienting. FACTORIE also makes aggressive use of scala functions in ways that won't be well handled for compiled java (which is the level at which clojure and scala should interact).

If you already have a large clojure code base and need a good linear chain CRF implementation (depending on your use of ChainModel above), I would recommend looking at MALLET . This is pure java and was developed by the same laboratory.

0
source

Source: https://habr.com/ru/post/1494958/


All Articles