<commit_before>package cc.factorie.app.nlp.mention

import collection.mutable.ArrayBuffer
import cc.factorie.app.nlp.{Sentence, TokenSpan, Document, Section}

/**
 * Created with IntelliJ IDEA.
 * User: belanger
 * Date: 5/29/13
 * Time: 2:01 PM
 * To change this template use File | Settings | File Templates.
 */

class MentionList extends ArrayBuffer[Mention]

object Mention{
  def apply(sec: Section, start: Int, length: Int, headTokenIndex: Int) =  new Mention(new TokenSpan(sec, start, length),headTokenIndex)
}

case class Mention(span: TokenSpan, headTokenIndex: Int = -1, mentionType: String = null) {
  def document: Document = span.document
  def start: Int = span.start
  def length: Int = span.length
  def sentence: Sentence = span.sentence
  def headToken = document.asSection.tokens(headTokenIndex)
}<commit_msg>Add method and TODO and comment about bug to Mention.<commit_after>package cc.factorie.app.nlp.mention

import collection.mutable.ArrayBuffer
import cc.factorie.app.nlp.{Sentence, TokenSpan, Document, Section, Token}

/**
 * Created with IntelliJ IDEA.
 * User: belanger
 * Date: 5/29/13
 * Time: 2:01 PM
 * To change this template use File | Settings | File Templates.
 */

class MentionList extends ArrayBuffer[Mention]

object Mention{
  def apply(sec: Section, start: Int, length: Int, headTokenIndex: Int) =  new Mention(new TokenSpan(sec, start, length),headTokenIndex)
}

// TODO I don't like the last two arguments of this constructor: -akm
// The index should be in terms of the Span, not the Section
// I'm not comfortable with mentionType as a String.  Too error prone.  I think it should be a Label.
case class Mention(span: TokenSpan, headTokenIndex: Int = -1, mentionType: String = null) {
  def document: Document = span.document
  def section: Section = span.section
  /** The Token position in its Section. */
  def start: Int = span.start
  /** The number of Tokens in the mention's span. */
  def length: Int = span.length
  def sentence: Sentence = span.sentence
  def headToken: Token = document.asSection.tokens(headTokenIndex) // This is buggy.  If the Document has multiple Sections, this won't work. -akm
}
{'fraction_non_alphanumeric': 0.1, 'fraction_numerical': 0.008333333333333333, 'mean_word_length': 4.219806763285024, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2010970', 'n_tokens_mistral': 673, 'n_tokens_neox': 652, 'n_words': 240}