#include <GlyphFeatures.h>
Inheritance diagram for Conjecture::GlyphFeatures:
****************************************************************
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 LineType & | lineType () 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 () |
LineType & | lineTypeRef () |
Variant2Set & | horizontalRef () |
Variant2Set & | verticalRef () |
VariantSet & | holesRef () |
VariantSet & | cupsRef () |
Confidence | lineMatch (Variant mine, Variant target) const |
|
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. |
|
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. |
|
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. |
|
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
> 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.) |
|
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. |
|
Establishes how well this GlyphFeatures instance matches aginst 'features'.
|
|
Print a description of this set of features. |