Closed meokz closed 2 years ago
I also need to remove hyphenation when pasting into Deepl or Google Translate, and I feel the need for this tool. Therefore, I would like to incorporate this PR. As for the UI implementation, it's done perfectly!
However, in the implementation below, doesn't it replace all " " in the original sentence?
private func getFormattedText(_ input: String) -> String {
let lines = input
.components(separatedBy: .newlines)
.map { $0.replacingOccurrences(of: "- ", with: "") }
let output = lines
.joined(separator: " ")
.replacingOccurrences(of: " ", with: "\n")
return output
}
If this is not a problem, please comment.
I think we don't need to worry about it. A single space in the original sentence will be preserved correctly.
Note that if there are two or more consecutive spaces in the original sentence, there is a mistake that will be replaced by a new line.
@meokz Sorry for the late reply. I see you said it's not a problem, so I'll merge it! Thanks for the new feature!
Hey, I implemented a hyphenation remover that removes unnecessary hyphenation from copied text from PDF. It is useful for preprocessing for translating English to other languages using Google Translate and DeepL. This is inspired by shaper (Ref: https://twitter.com/KeijiKobara/status/1391317599850430467?s=20&t=tb8xyWdcpLVKmAk99NNvMw)
Feel free to accept or decline this PR for reason that this is your personal project.