-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adapter for Scala Grounders (rvacareanu/grounder) #887
Conversation
@robertvacareanu , once #888 is merged, that failing CI test should pass. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At some point we might have to move away from the syntax like
val engine = chosenEngine getOrElse config.getString("engine")
in favor of
val engine = chosenEngine.getOrElse(config.getString("engine"))
Odersky has made comments recently about there being too many options supported, especially with the Python style included. The infix without .() may be sacrificed.
@kwalcock Thanks for the heads up. I always tried to make that syntax work in my mind but always felt a bit off. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks really good. The only thing I'd want to change for sure is the character encoding. That has bitten us before.
def apply(groundingConcepts: Seq[GroundingConcept]): ScalaGroundersAdapter = new ScalaGroundersAdapter(groundingConcepts) | ||
def fromDkgs(dkgs: Seq[DKG]): ScalaGroundersAdapter = new ScalaGroundersAdapter(dkgs.map(dkg => GroundingConcept(dkg.id, dkg.name, dkg.description, Option(dkg.synonyms.map(_.value)), None))) | ||
def fromFile(groundingConceptsPath: String): ScalaGroundersAdapter = { | ||
val concepts = using(Source.fromFile(groundingConceptsPath)) { it => |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Source.fromFile without an encoding specified may be a problem on machines where they have Java using an unexpected default encoding. It might be easier to play it safe here and save tracking it down later.
case "scala-grounders" => | ||
// Similar to `miraembeddings` | ||
val ontologyFilePath = domainConfig.getString("ontologyPath") | ||
ScalaGroundersAdapter.fromFile(groundingConceptsPath=ontologyFilePath) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey, that's Python! ;-)
groundingConceptsPath = ontologyFilePath
import org.clulab.scala_grounders.model.DKG | ||
import org.clulab.scala_grounders.model.DKGSynonym | ||
import com.typesafe.config.ConfigFactory | ||
import org.clulab.scala_grounders.using |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Recently we've been using the the using
from
"org.scala-lang.modules" %% "scala-collection-compat" % version
often looking like Using.resource() { resource =>
. It's in the standard library for newer Scala versions.
.map { result => | ||
GroundingCandidate(fromDKGToConcept(result.dkg), result.score, details = Some(result.groundingDetails.grounderName)) | ||
} | ||
.force.toSeq |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a clever use of Streams. IntelliJ says that the .toSeq is superfluous.
## Summary of Changes Added an Adapter for the Scala Grounders package. --------- Co-authored-by: Gus Hahn-Powell <[email protected]> fe8f41f
Summary of Changes
Added an Adapter for the Scala Grounders package.