def testPhraseTimestampLookup():
    phraseLookup = PhraseTimestampLookup()
    phraseLookup.loadSubtitles('data/test_subs.txt')

    assertEquals(phraseLookup.getTimestampForIndex_(32), pippinTime)

    assertEquals(phraseLookup.getTimestamp('Hey!'), pippinTime)
    assertEquals(phraseLookup.getTimestamp("Boromir"), aragornTime)
def printCharacters(resources, callback):
  actorFirstLineIterator = ActorFirstLineIterator()
  actorFirstLineIterator.loadTranscript(resources['transcript'])

  phraseLookup = PhraseTimestampLookup()
  phraseLookup.loadSubtitles(resources['subs'])

  for actor, line in actorFirstLineIterator.getActorFirstLines():
    timestamp = phraseLookup.getTimestamp(line)
    if timestamp < 0:
      if DEBUG: print 'ERROR', "couldn't find line \"%s\" said by %s" %(line, actor)
      pass
    else:
      callback(actor, timestamp)