Skip to content

fixing untranslated text indicator#28

Open
adil-uddin wants to merge 1 commit intodimagi:masterfrom
adil-uddin:adil/icds-1709
Open

fixing untranslated text indicator#28
adil-uddin wants to merge 1 commit intodimagi:masterfrom
adil-uddin:adil/icds-1709

Conversation

@adil-uddin
Copy link
Contributor

No description provided.

@adil-uddin
Copy link
Contributor Author

fixing issues in #26
@mkangia
image_2020_10_09T13_44_57_042Z

Copy link
Contributor

@mkangia mkangia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for taking care of this @adil-uddin
mostly just coding optimizations.


def get_unique_words(cell):
"""
Remove output tags and return unique words. If 'jr://file/' is found in cell return empty list
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is the reason for doing this?

"""
Checks whether a word contains only english alphabet or not
"""
if len(re.findall('[a-zA-z0-9]', word)) == len(word):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can just do a regex match here?

"""
source_cell_words = get_unique_words(source_cell)
current_cell_words = get_unique_words(current_cell)
shared_words = set(source_cell_words).intersection(set(current_cell_words))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need get_unique_words to return a list? we can just have that return a set and hence then not need to convert it to set again?

current_cell_words = get_unique_words(current_cell)
shared_words = set(source_cell_words).intersection(set(current_cell_words))
if len(shared_words) > 0:
shared_english_words = []
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit:
common_words -> shared_english_words
distinct_words -> non_shared_words

if is_english_word(word):
continue
else:
return shared_english_words, True
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this can be rewritten as

for word in non_shared_words:
    if not is_english_word(word):
        return shared_english_words, True


def is_english_word(word):
"""
Checks whether a word contains only english alphabet or not
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: is_alphanumeric would be a true reflection of what this method is doing.

source_cell_words = get_unique_words(source_cell)
current_cell_words = get_unique_words(current_cell)
shared_words = set(source_cell_words).intersection(set(current_cell_words))
if len(shared_words) > 0:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: len is redundant here? just if shared_words should suffice?

if is_english_word(word):
has_english_words = True
else:
has_non_english_words = True
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if both are true we can break out of the loop?

if has_english_words and has_non_english_words:
    break

curMismatchFillStyle = None
mismatch_present = False
lesser_mismatch_present = False
lang_mismatch_present = False
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can this be rewritten such that these variables are not declared? it looks like that should be possible to assign curMismatchFillStyle directly

curMismatchFillStyle = LESSER_MISMATCH_FILL_STYLE_NAME
curMismatchFillStyle = None
mismatch_present = False
lesser_mismatch_present = False
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

similarly here, looks like it should be possible to rewrite this without the new set of variables.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Comments