Represent one word (or puncutation mark) in a NLPSentence.

Introduced properties

fun begin_offset: Int

nlp :: NLPToken :: begin_offset

Position of the first character in the input
protected fun begin_offset=(begin_offset: Int)

nlp :: NLPToken :: begin_offset=

Position of the first character in the input
init defaultinit(index: Int, word: String, lemma: String, begin_offset: Int, end_offset: Int, pos: String)

nlp :: NLPToken :: defaultinit

fun end_offset: Int

nlp :: NLPToken :: end_offset

Position of the last character in the input
protected fun end_offset=(end_offset: Int)

nlp :: NLPToken :: end_offset=

Position of the last character in the input
init from_xml(xml: XMLStartTag)

nlp :: NLPToken :: from_xml

Init self from an XML element.
fun index: Int

nlp :: NLPToken :: index

Index of this word in the sentence.
protected fun index=(index: Int)

nlp :: NLPToken :: index=

Index of this word in the sentence.
fun lemma: String

nlp :: NLPToken :: lemma

word lemma
protected fun lemma=(lemma: String)

nlp :: NLPToken :: lemma=

word lemma
fun pos: String

nlp :: NLPToken :: pos

Part Of Speech tag
protected fun pos=(pos: String)

nlp :: NLPToken :: pos=

Part Of Speech tag
fun word: String

nlp :: NLPToken :: word

Original word
protected fun word=(word: String)

nlp :: NLPToken :: word=

Original word

Redefined properties

redef type SELF: NLPToken

nlp $ NLPToken :: SELF

Type of this instance, automatically specialized in every class

All properties

fun !=(other: nullable Object): Bool

core :: Object :: !=

Have self and other different values?
fun ==(other: nullable Object): Bool

core :: Object :: ==

Have self and other the same value?
type CLASS: Class[SELF]

core :: Object :: CLASS

The type of the class of self.
type SELF: Object

core :: Object :: SELF

Type of this instance, automatically specialized in every class
fun begin_offset: Int

nlp :: NLPToken :: begin_offset

Position of the first character in the input
protected fun begin_offset=(begin_offset: Int)

nlp :: NLPToken :: begin_offset=

Position of the first character in the input
protected fun class_factory(name: String): CLASS

core :: Object :: class_factory

Implementation used by get_class to create the specific class.
fun class_name: String

core :: Object :: class_name

The class name of the object.
init defaultinit(index: Int, word: String, lemma: String, begin_offset: Int, end_offset: Int, pos: String)

nlp :: NLPToken :: defaultinit

fun end_offset: Int

nlp :: NLPToken :: end_offset

Position of the last character in the input
protected fun end_offset=(end_offset: Int)

nlp :: NLPToken :: end_offset=

Position of the last character in the input
init from_xml(xml: XMLStartTag)

nlp :: NLPToken :: from_xml

Init self from an XML element.
fun get_class: CLASS

core :: Object :: get_class

The meta-object representing the dynamic type of self.
fun hash: Int

core :: Object :: hash

The hash code of the object.
fun index: Int

nlp :: NLPToken :: index

Index of this word in the sentence.
protected fun index=(index: Int)

nlp :: NLPToken :: index=

Index of this word in the sentence.
init init

core :: Object :: init

fun inspect: String

core :: Object :: inspect

Developer readable representation of self.
protected fun inspect_head: String

core :: Object :: inspect_head

Return "CLASSNAME:#OBJECTID".
intern fun is_same_instance(other: nullable Object): Bool

core :: Object :: is_same_instance

Return true if self and other are the same instance (i.e. same identity).
fun is_same_serialized(other: nullable Object): Bool

core :: Object :: is_same_serialized

Is self the same as other in a serialization context?
intern fun is_same_type(other: Object): Bool

core :: Object :: is_same_type

Return true if self and other have the same dynamic type.
fun lemma: String

nlp :: NLPToken :: lemma

word lemma
protected fun lemma=(lemma: String)

nlp :: NLPToken :: lemma=

word lemma
intern fun object_id: Int

core :: Object :: object_id

An internal hash code for the object based on its identity.
fun output

core :: Object :: output

Display self on stdout (debug only).
intern fun output_class_name

core :: Object :: output_class_name

Display class name on stdout (debug only).
fun pos: String

nlp :: NLPToken :: pos

Part Of Speech tag
protected fun pos=(pos: String)

nlp :: NLPToken :: pos=

Part Of Speech tag
fun serialization_hash: Int

core :: Object :: serialization_hash

Hash value use for serialization
intern fun sys: Sys

core :: Object :: sys

Return the global sys object, the only instance of the Sys class.
abstract fun to_jvalue(env: JniEnv): JValue

core :: Object :: to_jvalue

fun to_s: String

core :: Object :: to_s

User readable representation of self.
fun word: String

nlp :: NLPToken :: word

Original word
protected fun word=(word: String)

nlp :: NLPToken :: word=

Original word
package_diagram nlp::NLPToken NLPToken core::Object Object nlp::NLPToken->core::Object

Parents

interface Object

core :: Object

The root of the class hierarchy.

Class definitions

nlp $ NLPToken
# Represent one word (or puncutation mark) in a `NLPSentence`.
class NLPToken

	# Index of this word in the sentence.
	var index: Int

	# Original word
	var word: String

	# `word` lemma
	var lemma: String

	# Position of the first character in the input
	var begin_offset: Int

	# Position of the last character in the input
	var end_offset: Int

	# Part Of Speech tag
	var pos: String

	# Init `self` from an XML element.
	#
	# ~~~
	# var xml = """
	#  <token id="2">
	#	<word>University</word>
	#	<lemma>University</lemma>
	#	<CharacterOffsetBegin>9</CharacterOffsetBegin>
	#	<CharacterOffsetEnd>19</CharacterOffsetEnd>
	#	<POS>NNP</POS>
	#  </token>""".to_xml["token"].first.as(XMLStartTag)
	#
	# var token = new  NLPToken.from_xml(xml)
	# assert token.index == 2
	# assert token.word == "University"
	# assert token.lemma == "University"
	# assert token.begin_offset == 9
	# assert token.end_offset == 19
	# assert token.pos == "NNP"
	# ~~~
	init from_xml(xml: XMLStartTag) do
		var index = xml.attributes.first.as(XMLStringAttr).value.to_i
		var word = read_data(xml, "word")
		var lemma = read_data(xml, "lemma")
		var begin_offset = read_data(xml, "CharacterOffsetBegin").to_i
		var end_offset = read_data(xml, "CharacterOffsetEnd").to_i
		var pos = read_data(xml, "POS")
		init(index, word, lemma, begin_offset, end_offset, pos)
	end

	private fun read_data(xml: XMLStartTag, tag_name: String): String do
		var res = ""
		if xml[tag_name].is_empty then return res
		var first = xml[tag_name].first
		if not first isa XMLStartTag then return res
		var data = first.data
		if data == null then return res
		return data
	end
end
lib/nlp/stanford.nit:239,1--299,3