org.clulab.timenorm.scfg

TemporalExpressionParser

class TemporalExpressionParser extends AnyRef

A parser for natural language expressions of time, based on a synchronous context free grammar. Typical usage:

// create a new parser (using the default English grammar)
val parser = new TemporalExpressionParser
// establish an anchor time
val anchor = TimeSpan.of(2013, 1, 4)
// parse an expression given an anchor time (assuming here that it succeeeds)
val Success(temporal) = parser.parse("two weeks ago", anchor)
// get the TimeML value ("2012-W51") from the Temporal
val value = temporal.timeMLValue
Linear Supertypes
AnyRef, Any
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. TemporalExpressionParser
  2. AnyRef
  3. Any
  1. Hide All
  2. Show all
Learn more about member selection
Visibility
  1. Public
  2. All

Instance Constructors

  1. new TemporalExpressionParser(grammarURL: URL = ..., tokenize: (String) ⇒ IndexedSeq[String] = DefaultTokenizer)

    Creates a parser from a URL to a grammar file.

    Creates a parser from a URL to a grammar file.

    grammarURL

    The URL of a grammar file, in SynchronousGrammar.fromString format. If not specified, the default English grammar on the classpath is used. Note that if another grammar is specified, it may be necessary to override the tokenize method.

    tokenize

    A function that splits a string into tokens. The default tokenizer is appropriate for the default English grammar. Other languages may require alternate tokenizers.

Value Members

  1. final def !=(arg0: Any): Boolean

    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean

    Definition Classes
    AnyRef → Any
  4. final def asInstanceOf[T0]: T0

    Definition Classes
    Any
  5. def clone(): AnyRef

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  6. final def eq(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  7. def equals(arg0: Any): Boolean

    Definition Classes
    AnyRef → Any
  8. def finalize(): Unit

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  9. final def getClass(): Class[_]

    Definition Classes
    AnyRef → Any
  10. def hashCode(): Int

    Definition Classes
    AnyRef → Any
  11. final def isInstanceOf[T0]: Boolean

    Definition Classes
    Any
  12. final def ne(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  13. final def notify(): Unit

    Definition Classes
    AnyRef
  14. final def notifyAll(): Unit

    Definition Classes
    AnyRef
  15. def parse(sourceText: String, anchor: TimeSpan): Try[Temporal]

    Tries to parse a source string into a single Temporal object.

    Tries to parse a source string into a single Temporal object.

    sourceText

    The input string in the source language.

    anchor

    The anchor time (required for resolving relative times like "today").

    returns

    The most likely Temporal parse according to the parser's heuristic.

  16. def parseAll(sourceText: String, anchor: TimeSpan): Try[Seq[Temporal]]

    Try to parse a source string into possible Temporal objects.

    Try to parse a source string into possible Temporal objects.

    sourceText

    The input string in the source language.

    anchor

    The anchor time (required for resolving relative times like "today").

    returns

    A sequence of Temporal objects representing the possible parses. The sequence is sorted by a heuristic that tries to put the most promising parses first.

  17. final def synchronized[T0](arg0: ⇒ T0): T0

    Definition Classes
    AnyRef
  18. def toString(): String

    Definition Classes
    AnyRef → Any
  19. final def wait(): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  20. final def wait(arg0: Long, arg1: Int): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  21. final def wait(arg0: Long): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Inherited from AnyRef

Inherited from Any

Ungrouped