Good afternoon @Masantm,
First of all: This is not as simple a question as it seems.
For us humans, it is very simple and easy to identify where or not the 'x' to neutralize the genres of words, but the computer performs only instructions, so it is up to us to explain the rules and exceptions.
In the example:
"The girl took the drill"
neutralizing genres would be:
"X garotx pegou na furadeira"
but the complexity lies in how to pass the instructions to the computer.
"Computer, exchange all letters 'o' and 'a' for 'x' "
Upshot:
"X gxrxtx pegxu nx furxdeirx"
Opa, we have already faced the first problem: It is not all the letters 'o' and 'a' that should be replaced, so that reading the sentence does not become a guessing game. In addition, we have words that have gender defined and do not have 'o' or 'a', for example: "teachers". At this point we can already see that only the letters 'o' and 'a' that are at the end of each word need to be exchanged, more precisely in the last two letters, which is where the classification of the word genres is grammatically positioned, so let’s go.
"Computer, change the letters 'o','a' and occasionally 'and', but only those in the last two positions of each word"
Upshot:
"X garotx pegxu nx furadeirx"
It is a better result than the previous one, but still has many problems. " Drill" is a feminine gender word, however it is an object name, so it does not enter the rule of neutral writing, as well as "caught" and "in the".
Attempt 3:
"Computer, exchange the letters 'o', 'a' and occasionally 'and' for 'x', in words that relate to subjects, to neutralize their genres. as articles and adjectives, but do not change if they are objects, as they have no gender"
Upshot:
"X garotx pegou na furadeira"
Perfect, right? But passing instructions to a program is not as simple as saying "Computer, do it". To make the above instruction readable to a computer we would have to feed it a considerable amount of data and rules.
This book above was just to open your mind to the complexity that some programs can assume. I’m a computer student so I think it’s important to give you this first notion, because sometimes we let things go by "beats".
#include <stdio.h>
#include <string.h>
int main(){
char string[100];
int i;
gets(string);
for(i=0;i<100;i++){
if(string[i] == ' '){ //Checando se o caractere em questão é um espaço
if(string[i- 1] == 'a' || string[i- 1] == 'o'){
string[i- 1] = 'x';
}else if(string[i- 2] == 'a' || string[i- 2] == 'o' || string[i- 2] == 'e'){
string[i- 2] = 'x';
}else{
i++;
}
}
}
printf(string);
return 0;
}
This is an example of code I did until the second attempt, "Computer, replace the letters 'o', 'a' and occasionally 'e' at the end of the words".
I purposely left a logic hole, can you figure out what it is? It’s nothing as complex as the problems I mentioned above and can serve you as an exercise.
I hope that knowledge will be useful to you.
Welcome to Stackoverflow and good studies!
Hug!
Young, first, use tags correctly, C and C# are completely different things. Also never put your code on external sources, this makes it difficult to access people who have locks for some domains and, moreover, makes it difficult to read the question, no one wants to have to access 3 different links to try to write an answer.
– Jéf Bueno
Read a basic tutorial on declaring and assigning variables in C. With gender = x; you are assigning the contents of variable x to the gender variable, maybe you wanted to do: gender = 'x'; (assigning constant 'x' to the gender variable).
– anonimo
Why in his example the letter 'e', from the end of university, is replaced by 'x'?
– anonimo
LINQ : Thanks, I’m new here and your tips were very useful. anonimo1: Thanks, I’ll try your suggestion. anonimo2: I also found it bizarre, but it’s done from student to student, just for educational purposes so I don’t think it interferes too much.
– MaSanTM
Only with a parser to do what you want. To create a parser you will have to build a lexical parser with lex(or flex) plus a syntactic parser created with Yacc(or Bison) that together will act on the text based on a digital dictionary of the Portuguese language so that after you attach a token grammatical(not a syntactic token) to all words ai yes can decide which words may or may not have gender neutralized.
– Augusto Vasques