Skip to content
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

Optional text input files #28

Merged
merged 4 commits into from
Aug 8, 2017
Merged

Optional text input files #28

merged 4 commits into from
Aug 8, 2017

Conversation

EgoLaparra
Copy link
Contributor

No description provided.

XML.fromSource(io.Source.fromFile(xmlPath)),
io.Source.fromFile(textPath).mkString)
def apply(xml: Elem, text: String) = new Data(xml, text)
def fromPaths(xmlPath: String, textPath: Option[String]) =textPath match {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this could be more concisely written as:

apply(XML.fromSource(io.Source.fromFile(xmlPath)), textPath.map(p => io.Source.fromFile(p).mkString)

def text(implicit data: Data): String = spans.map{
case (start, end) => data.text.substring(start, end)
}.mkString("...")
def text(implicit data: Data): Option[String] = data.text match {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this could be more concisely written as:

data.text.map(text => spans.map {
  case (start, end) => text.substring(start, end)
}.mkString("..."))

@@ -26,7 +26,7 @@ case class FractionalNumber(number: Int, numerator: Int, denominator: Int) exten
val isDefined = true
}

case class VagueNumber(description: String) extends Number {
case class VagueNumber(description: Option[String]) extends Number {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't make VagueNumber take an Option[String]. Rather, in your scorer where the value of the VagueNumber doesn't matter, just pass some meaningless value. Something like entity.text.getOrElse("").

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok. Should I do the same with Event and TimeZone?

@bethard
Copy link
Collaborator

bethard commented Aug 8, 2017 via email

@bethard bethard merged commit 04950f5 into master Aug 8, 2017
@bethard bethard deleted the opttext branch August 8, 2017 17:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants