text3replace: translating some words

Description Usage Arguments Details Value See Also Examples

View source: R/rbsa6.code.r

Description

from a text, gives it back after replacing some words (in fact sequences of characters) by others. The translation can be conditionned by the surrounding characters of the sequence.

Usage

1
2
3
4
5
 
  text3replace(text,translate,lowering=FALSE,
               b.accepted=NULL,a.accepted=NULL,
               b.rejected=NULL,a.rejected=NULL,
               b.line=TRUE,e.line=TRUE) 

Arguments

text

A character vector containing the text (a component, a line).

translate

A two-columns character matrix with, row by row, a word to translate and its translations. The second column can comprise "" not the first.

lowering

Must a lowering being applied before the selection of the words to translate?

b.accepted

A character providing the surrounding characters before the words to determine the acceptance of the translation.

a.accepted

A character providing the surrounding characters after the words to determine the acceptance of the translation.

b.rejected

A character providing the surrounding characters before the words to determine the rejection of the translation.

a.rejected

A character providing the surrounding characters after the words to determine the rejection of the translation.

b.line

Must words at the beginning of a line be translated?

e.line

Must words at the end of a line be translated?

Details

The words to translate cannot be extended upon two successive lines.
The translations are done sequentially along the rows of translate so modifying their order can produce different results.
For obvious reason, b.accepted and b.rejected cannot be non NULL simultaneously; the same for a.accepted and a.rejected.
Resulting empty lines are not removed neither already present empty lines.

Value

The translated text

See Also

text3acceptance

Examples

1
2
3
4
5
6
 
  let <- c("a","e","i","o","u","y"); 
  tra <- matrix(c(let,tolower(let)),ncol=2); 
  text3replace(letters,tra); 
  text3replace(c("Il etait une fois","un petit et rouge chaperon"),tra); 
  text3replace(c("Il etait une fois","un petit et rouge chaperon"),tra,b.accepted=" "); 

rbsa documentation built on May 2, 2019, 6:07 p.m.