swtloc.core.Fusion

class swtloc.core.Fusion(letters: dict, acceptable_stroke_width_ratio: float, acceptable_color_deviation: List[int], acceptable_height_ratio: float, acceptable_angle_deviation: float)[source]

Bases: object

Class for fusing Individual Components (Letters) into Grouped Components Words, comparing aspects like :

  • Proximity of letters to each other

  • Relative minimum bounding box rotation angle from each other

  • Deviation in color between from one component to the other

  • Ratio of stroke widths from one to the other

  • Ratio of minimum bounding box height of one to the other

Methods

Fusion.__init__(letters, ...)

Create Fusion object

Fusion.getProximityLetters(anchor_letter, ...)

Finds all the labels which are in proximity of anchor_letter amongst the remaining_letters

Fusion.groupEligibility(curr_letter, ...)

Check whether two ProxyLetters are eligible to be grouped with one another.

Fusion.groupLetters(curr_letter, ...)

Groups curr_letter with its proximity labels which are eligible to be grouped to it.

Fusion.runGrouping()

Fuses eligible individual components (letters) together which can be eligible to form a word out of them.

getProximityLetters(anchor_letter: swtloc.core.ProxyLetter, remaining_letters: dict) List[int][source]

Finds all the labels which are in proximity of anchor_letter amongst the remaining_letters

Parameters
  • anchor_letter (ProxyLetter) – Letter with respect to which proximity labels are to be searched.

  • remaining_letters (dict) – A dictionary, with labels as keys, mapped to their corresponding ProxyLetter object.

Returns

List of all the labels which are in the proximity of anchor_letter

Return type

(List[int])

groupEligibility(curr_letter, proximity_letter) bool[source]

Check whether two ProxyLetters are eligible to be grouped with one another.

Parameters
  • curr_letter (ProxyLetter) – Current Letter

  • proximity_letter (ProxyLetter) – A letter in proximity of Current Letter

Returns

Whether curr_letter and proximity_letter are eligible to be grouped with each other

Return type

(bool)

groupLetters(curr_letter, remaining_letters, grouping) List[swtloc.core.ProxyLetter][source]

Groups curr_letter with its proximity labels which are eligible to be grouped to it. [Recursive Function]

Parameters
  • curr_letter (ProxyLetter) – ProxyLetter whose grouping needs to be mapped.

  • remaining_letters (dict) – Dictionary with keys as the ProxyLetter label and the corresponding values as the ProxyLetter themselves.

  • grouping (list) – A list of lists containing ProxyLetters which can be assumed to be words.

Returns

A list containing ProxyLetters which can be

assumed to be a word.

Return type

(List[ProxyLetter])

runGrouping() List[List[swtloc.core.ProxyLetter]][source]

Fuses eligible individual components (letters) together which can be eligible to form a word out of them.

Returns

A list of lists containing ProxyLetter which can be assumed

to be words amongst the pool of individual components provided to the Fusion class.

Return type

(List[List[ProxyLetter]])