usbong / UsbongKit

A framework for reading and displaying contents of Usbong Trees
www.usbong.ph
Apache License 2.0
2 stars 1 forks source link

Fix hints parser implementation #22

Closed chrisamanse closed 7 years ago

chrisamanse commented 7 years ago

Instead of going through each hints in the hints XML, and searching for the word in a text, go through each word of the text, and find the hint in the hints XML. This will fix the cases discussed in #21. Also, this is reduce the runtime if there are significantly greater number of hints in the hints XML than the words in a text.

Current implementation (pseudocode):

for (word, hint) in hintsXML {
  let location = text.find(word)
  text.add(hint, in: location)
}

Intended implementation:

for (locationOfWord, word) in text {
  let hint = hintsXML[word]
  text.add(hint, in: locationOfWord)
}