ericcornelissen/wordrow

Add functionality to change capitalization of words

ericcornelissen opened this issue · 0 comments

Feature Request

  • wordrow version: v0.4.0-beta

Description

By default wordrow maintains the capitalization of a word/phrase when doing a replacement, and all capitalization specified in the mapping is ignored. It may be useful as well to allow for using wordrow to explicitly change the capitalization of a word/phrase.

Example

One may want force starting proper names with capital letters. For example, if my name appears in a document such as:

Eric cornelissen started working on the wordrow program in 2020. To develop the program eric decided
to use the Go programming language.

Then I want to be able to convert this to the following (where "eric" is replaced by "Eric" and "cornelissen" is replaced by "Cornelissen")

Eric Cornelissen started working on the wordrow program in 2020. To develop the program Eric decided
to use the Go programming language.

Proposal

Possibly the most straightforward approach would be to use explicit capitalization when the from and to value are equal when ignoring capitalization. In this case, we can define a mapping such as:

# mapping.csv

foo, Foo

This would take any instance of the word "foo" (with whatever capitalization) is replaced by "Foo". For example, given the input file:

# input.txt

foo FOO Foo fOO FOo

Then, if one runs:

$ ./wordrow --map-file ./mapping.csv input.txt

The input.txt file is updated to:

# input.txt

Foo Foo Foo Foo Foo