Convert::Context

Attributed Text data type
Download

Convert::Context Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Perl Artistic License
  • Price:
  • FREE
  • Publisher Name:
  • Martin Schwartz
  • Publisher web site:
  • http://search.cpan.org/~mschwartz/

Convert::Context Tags


Convert::Context Description

Attributed Text data type Convert::Context is an Attributed Text data type.Convert::Context maintains attributed strings. It allows you to access those strings similar to perl's normal strings.An attributed string is a string to that attributes are connected at certain string positions. An attribute can be everything scalar: numbers, strings, references are welcome. Attributes are not part of the string. Semantics of the attributes have to be done by the applying code.What does this mean?A basic work for a text system is to localize a certain text part. This is trivial if you have only plain text to look at. It is no longer trivial, if you have attributes or entries among your text like: bold, italic, bookmarks and so on. One has two strategies to mingle attributes with a string: 1. You can enrich the text by inserting control codes. E.g., if you have a line with two bold words: (A) "The word bold is always bold" it would look (here with HTML controls) like: (B) "The word bold is always bold" If you would look for the text "bold is" in (B) with perls m// operator, you'd fail. You would have to strip the HTML control sequences first. This is an ok method, but not used here. 2. You can maintain separate lists, holding at which position of the text which control codes are stored. This is, what Convert::Context does. The example from above would look like: offset 0---------1---------2------- text The word bold is always bold attrib (0 1 0 1 ) Internally this is stored as: $Context = { "T" => ("The word bold is always bold"), "A" => "O" => , }The maintainance of these lists is a little bit tricky, so what a luck, that you don't need to care about this.Do not rely on this internal representation, as it might change. E.g. it could happen, that "O" in future stores relative offsets instead of absolute. Requirements: · Perl


Convert::Context Related Software