Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Use all char points when generating indexes instead of only the first #41

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions lgr/core.py
Original file line number Diff line number Diff line change
@@ -1274,15 +1274,13 @@ def generate_index_label(self, label):
for char in chars:
logger.debug('Char CP: %s', format_cp(char.cp))
# Index: smallest id of the char and its variants
# FIXME: This index algorithm has some problems when dealing with sequences and should be fixed
ids = [char.as_index()]
ids = [char.cp]
for var in char.get_variants():
var_char = self.repertoire.get_char(var.cp)
logger.debug('Variant CP: %r', var_char)
ids.append(var_char.as_index())
logger.debug('List of variant ids: %s', ids)
ids.append(var.cp)

index_label.append(min(ids))
# Find the minimum id, handling both single values and tuples
min_id = min(ids, key=lambda x: x if isinstance(x, int) else min(x))
index_label += min_id

logger.debug("Index label: '%s'", index_label)