Conjecture::GlyphFeatures Class Reference

#include <GlyphFeatures.h>

Inheritance diagram for Conjecture::GlyphFeatures:

Conjecture::Root List of all members.

Detailed Description

Encapsulates features of interest within a Glyph.

****************************************************************

Features include:

Parameterizable values:

NOTE: This class is currently space-inefficient. A much, much tighter implementation that packs values into bits and avoids vectors, etc. could be implemented. Whether this is necessary depends on how this class ends up being used.

It is CRITICALLY important that no state be exposed, since it is quite likely we will be moving to a different implementation.


Public Types

typedef float Confidence
enum  LineType {
  LTUnknown = 0, Base = 1, Ascender = 2, Descender = 3,
  Total = 4, __LTSIZE = 5
}
enum  Variant {
  Center = 1, Top = 2, Bottom = 3, Left = 4,
  Right = 5, Dominant = 8, Recessive = 9, HalfLine = 10,
  Undef = 11
}

Public Member Functions

 GlyphFeatures (LineType lineType=LTUnknown)
 GlyphFeatures (wchar_t unicode, LineType lineType, const std::string &spec)
void init (wchar_t unicode, LineType lineType)
wchar_t unicode () const
bool xdisconnect () const
bool ydisconnect () const
float MostOfLength () const
const LineTypelineType () const
void addHorizontal (Variant position, Variant length)
void addVertical (Variant position, Variant length)
void addHole (Variant position)
void addCup (Variant position)
Variant hasHorizontal (Variant position) const
Variant hasVertical (Variant position) const
bool hasHole (Variant position) const
bool hasCup (Variant position) const
std::ostream & print (std::ostream &os=std::cout, const std::string &indent="") const
Confidence matches (const GlyphFeatures &target) const

Static Public Member Functions

static void Test (int argc=0, const char *argv[]=NULL)

Protected Member Functions

void unicodeIs (const wchar_t &unicode)
void xdisconnectIs (const bool &xdisconnect)
void ydisconnectIs (const bool &ydisconnect)
void lineTypeIs (const LineType &lineType)
void MostOfLengthIs (float MostOfLength)
const Variant2Set & horizontal () const
const Variant2Set & vertical () const
const VariantSet & holes () const
const VariantSet & cups () const
wchar_t & unicodeRef ()
bool & xdisconnectRef ()
bool & ydisconnectRef ()
LineTypelineTypeRef ()
Variant2Set & horizontalRef ()
Variant2Set & verticalRef ()
VariantSet & holesRef ()
VariantSet & cupsRef ()
Confidence lineMatch (Variant mine, Variant target) const


Member Typedef Documentation

typedef float Conjecture::GlyphFeatures::Confidence
 

A type providing a measure of how confident one is about something.

Normally this is a value between 0 and 1, with 1 being perfectly confident and 0 indicating no points of commonality.

However, it is possible for Confidence values to be both negative (0 to -1) and greater than 1 (1-2). If negative, it indicates active confidence that there is NOT a match, with -1 being absolute certainty of no match. If greater than 1, it indicates that all criteria match "and then some". In some situations, overmatching is not a problem, but in others it is an indication of lessened confidence. The recipient of the Confidence value decides what to do with values greater than 1 depending on the context.


Member Enumeration Documentation

enum Conjecture::GlyphFeatures::LineType
 

The LineType enum is used by the 'GlyphlineType' method. It categorizes a glyph relative to the line within which it resides Unknown --> if the Glyph isn't in a line Base --> glyphs that do not go above midY or below baseY Ascender --> glyphs that do not go below baseY but do go above midY Descender --> glyphs that do not go above midY but do go below baseY Total --> glyphs that go above midY and below baseY

FUTURE FIX: Another type between Base and Ascender for "minor" ascenders (like 't') may help in identification! Same might be true of "minor descenders", but descenders are much rarer so it may not be necessary.

enum Conjecture::GlyphFeatures::Variant
 

Type describing all variants.

Currently mixing variants from all features - may want to introduce different types for each feature type. i.e. Top/Center/Bottom are used for horizontal line positions, Left/Center/Right are used for vertical line positions, Top/Bottom/Left/Right/Center are used for holes, Top/Left/Right/Bottom are used for cups, and All/Most/Half are used for line length.


Constructor & Destructor Documentation

Conjecture::GlyphFeatures::GlyphFeatures wchar_t  unicode,
LineType  lineType,
const std::string &  spec
 

Creates a fully-initialized GlyphFeature instance based on a concise string specification.

Each character in 'spec' identifies a feature to add: vertical Left/Dominant line L vertical Left/Recessive line l vertical Left/HalfLine line

 vertical Right/Dominant line R vertical Right/Recessive line r vertical Right/HalfLine line

 vertical Center/Dominant line C vertical Center/Recessive line c vertical Center/HalfLine line

 horizontal Top/Dominant line T horizontal Top/Recessive line t horizontal Top/HalfLine line

 horizontal Bottom/Dominant line B horizontal Bottom/Recessive line b horizontal Bottom/HalfLine line

= horizontal Center/Dominant line

  • horizontal Center/Recessive line ~ horizontal Center/HalfLine line

> Left cup < Right cup ^ Bottom cup v Top cup

o Center hole e Top hole a Bottom hole 8 Top hole and Bottom hole

x disconnected in x direction (have no example currently) y disconnected in y direction (i.e. 'i', umlauts, accents, etc.)


Member Function Documentation

GlyphFeatures::Variant Conjecture::GlyphFeatures::hasHorizontal Variant  position  )  const
 

FUTURE FIX: A complete reimplementation of this class will make it orders-of-magnitude more efficient in both time and space! For now, these methods require search, but a new implementation can make them trivially efficient.

Returns the length-variant of the horizontal line feature at position 'position'.

If no horizontal line feature exists at that position, Variant::Undef is return.

GlyphFeatures::Confidence Conjecture::GlyphFeatures::matches const GlyphFeatures target  )  const
 

Establishes how well this GlyphFeatures instance matches aginst 'features'.

  • A perfect score of 1.0 is assigned if 'this' has EXACTLY the same set of features as 'target', indicating certainty that 'this' *is* 'target'.

  • "Overscoring" (a result greater than 1.0) occurs if 'this' contains a superset of 'target'. Whether overscoring is actually "same as", "better" or "worse" than a perfect score is up to the receiver to decide.

  • No similarities results in a score of 0.0

  • No similarities AND active indications of a non-match result in scores between 0.0 and -1.0, with -1.0 indicating certainty that a match does NOT exist.

  • Line-matching rules:
    • If 'target' expects a Dominant line for a particular position/orientation:
      • If 'this' has a feature for that line p/o:
        • if 'this' is Dominant, perfect match
        • if 'this' is Recessive, 90% (arbitrary) match
        • if 'this' is HalfLine, 25% (arbitrary) match
      • If 'this' does not have a line for that position:
        • Assign -100% match
    • If 'target' expects a Recessive line for a particular position/orientation:
      • If 'this' has a feature for that line p/o:
        • if 'this' is Dominant or Recessive, perfect match
        • if 'this' is HalfLine, 80% (arbitrary) match
      • If no line position, -50% match
    • If 'target' expects a HalfLine line for a particular position/orientation:
      • If 'this' has a feature for that line p/o:
        • if 'this' is Dominant, -10% (arbitrary) match
        • if 'this' is Recessive, 50% (arbitrary) match
        • if 'this' is HalfLine, 100% match
      • If no line position, -50% (arbitrary) match
    • If 'target' does not have a feature for a particular position/orientation:
      • If 'this' has a feature for that line p/o:
        • if 'this' is Dominant, -100% match
        • if 'this' is Recessive, -80% (arbitrary) match
        • if 'this' is HalfLine, -50% (arbitrary) match
      • If 'this' has no feature for that line p/0, 100% match

  • Hole-matching rules:
    • If 'target' has a <type> hole:
      • if 'this' has a <type> hole, 100%
      • if 'this' has any other hole, 10%
      • if 'this' has no holes, -10% (arbitrary, low penalty because hole detection can be flawed)
    • If 'target' has no holes but 'this' does, -10% (arbitrary) penalty

  • Cup-matching rules:
    • If 'target' has a <type> cup:
      • if 'this' has <type> cup, 100%
      • anything else, 0%
    • If 'target' has no cups but 'this' does, -50%

std::ostream& Conjecture::GlyphFeatures::print std::ostream &  os = std::cout,
const std::string &  indent = ""
const
 

Print a description of this set of features.


The documentation for this class was generated from the following files:
Generated on Thu Jun 15 19:56:11 2006 for Conjecture by  doxygen 1.4.6