8000 Improve the algorithm to match case when replacing. by piquan · Pull Request #51 · Posnet/xkcd-substitutions · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
This repository was archived by the owner on Jun 13, 2024. It is now read-only.

Improve the algorithm to match case when replacing. #51

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

piquan
Copy link
@piquan piquan commented May 28, 2016

Fix for #31. This improves the algorithm we use to match case, rather than doing a character-by-character check of case.

This computes the Hamming distance (number of characters changed) between the original and its lower case, upper case, and title case equivalents. Whichever is the closest match to the original, we do the same to the replacement. The lower case path also has a special check for whether the initial letter is capitalized, so t 8000 hat sentence starts are correctly handled.

This computes the Hamming distance between the original and its lower
case, upper case, and title case equivalents.  Whichever is the
closest match to the original, we do the same to the replacement.  The
lower case path also has a special check for whether the initial
letter is capitalized, so that sentence starts are correctly handled.
@piquan
Copy link
Author
piquan commented May 28, 2016

This is based on b471210, which is currently the Posnet:master top-of-tree. This patch doesn't integrate quite precisely after #48, so let me know if you need me to rebase this or other pull requests to make them easier to apply.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant
0