I need to convert US English gender specific text from one gender to another or make gender neutral
I need to convert US English sentences from one gender to another, make gender neutral, or take a gender neutral sentence and make it gender specific.
Currently I am using something like "He opened the door".Replace("He","She")
, but this does not work for all as something like "she has a sheep".Replace("he","she")
will return something like "sshe has a ssheep", and adding spaces to the front or back of the words does not work either.
What is a good way of doing this, and can anyone point me to a good list of gender specific words that include gender neutral words like:
Husband, Wife, Spouse
Husbands, Wives, Spouses
I am thinking that I can split the sentence apart by spaces into an array, check and convert each word in the array, then rebuild the sentence from the array, but it just seems like it should be easier than that.
If anyone has any ideas, I prefer c# code.
c#
add a comment |
I need to convert US English sentences from one gender to another, make gender neutral, or take a gender neutral sentence and make it gender specific.
Currently I am using something like "He opened the door".Replace("He","She")
, but this does not work for all as something like "she has a sheep".Replace("he","she")
will return something like "sshe has a ssheep", and adding spaces to the front or back of the words does not work either.
What is a good way of doing this, and can anyone point me to a good list of gender specific words that include gender neutral words like:
Husband, Wife, Spouse
Husbands, Wives, Spouses
I am thinking that I can split the sentence apart by spaces into an array, check and convert each word in the array, then rebuild the sentence from the array, but it just seems like it should be easier than that.
If anyone has any ideas, I prefer c# code.
c#
1
Are you assuming grammatically correct, well punctuated inputs? If not, how do you plan to cope with e.g.shell
- a hard protective cover, vsshell
- she will contracted with a missing apostrophe?
– Damien_The_Unbeliever
Nov 19 '18 at 14:46
1
Looks like a job for Regex docs.microsoft.com/en-us/dotnet/api/…
– pm_2
Nov 19 '18 at 14:46
I would recommend writing your own replacing function if you dont want to see Regex. In this case the whole world need to match so you can split the string on spaces, loop through all the worlds and replace them. then rebuild the string by joining them together, but punctuation then becomes a problem.
– DaanV
Nov 19 '18 at 14:46
2
To a first approximation, regexes haveb
for matching "word boundaries", which isn't perfect ("isn't" isn't two words, for starters), but it's something. Beware that naive implementations of word replacement are likely to produce laughable results if you're not careful -- many fixed expressions involve the word "man" in a context where it can't be replaced with "woman" or "person", for example. If a rewrite requires adjusting the grammar, that's a whole different kettle of fish.
– Jeroen Mostert
Nov 19 '18 at 14:47
add a comment |
I need to convert US English sentences from one gender to another, make gender neutral, or take a gender neutral sentence and make it gender specific.
Currently I am using something like "He opened the door".Replace("He","She")
, but this does not work for all as something like "she has a sheep".Replace("he","she")
will return something like "sshe has a ssheep", and adding spaces to the front or back of the words does not work either.
What is a good way of doing this, and can anyone point me to a good list of gender specific words that include gender neutral words like:
Husband, Wife, Spouse
Husbands, Wives, Spouses
I am thinking that I can split the sentence apart by spaces into an array, check and convert each word in the array, then rebuild the sentence from the array, but it just seems like it should be easier than that.
If anyone has any ideas, I prefer c# code.
c#
I need to convert US English sentences from one gender to another, make gender neutral, or take a gender neutral sentence and make it gender specific.
Currently I am using something like "He opened the door".Replace("He","She")
, but this does not work for all as something like "she has a sheep".Replace("he","she")
will return something like "sshe has a ssheep", and adding spaces to the front or back of the words does not work either.
What is a good way of doing this, and can anyone point me to a good list of gender specific words that include gender neutral words like:
Husband, Wife, Spouse
Husbands, Wives, Spouses
I am thinking that I can split the sentence apart by spaces into an array, check and convert each word in the array, then rebuild the sentence from the array, but it just seems like it should be easier than that.
If anyone has any ideas, I prefer c# code.
c#
c#
edited Nov 19 '18 at 14:43


fubo
29.5k966103
29.5k966103
asked Nov 19 '18 at 14:41
Stephen Lee Parker
805714
805714
1
Are you assuming grammatically correct, well punctuated inputs? If not, how do you plan to cope with e.g.shell
- a hard protective cover, vsshell
- she will contracted with a missing apostrophe?
– Damien_The_Unbeliever
Nov 19 '18 at 14:46
1
Looks like a job for Regex docs.microsoft.com/en-us/dotnet/api/…
– pm_2
Nov 19 '18 at 14:46
I would recommend writing your own replacing function if you dont want to see Regex. In this case the whole world need to match so you can split the string on spaces, loop through all the worlds and replace them. then rebuild the string by joining them together, but punctuation then becomes a problem.
– DaanV
Nov 19 '18 at 14:46
2
To a first approximation, regexes haveb
for matching "word boundaries", which isn't perfect ("isn't" isn't two words, for starters), but it's something. Beware that naive implementations of word replacement are likely to produce laughable results if you're not careful -- many fixed expressions involve the word "man" in a context where it can't be replaced with "woman" or "person", for example. If a rewrite requires adjusting the grammar, that's a whole different kettle of fish.
– Jeroen Mostert
Nov 19 '18 at 14:47
add a comment |
1
Are you assuming grammatically correct, well punctuated inputs? If not, how do you plan to cope with e.g.shell
- a hard protective cover, vsshell
- she will contracted with a missing apostrophe?
– Damien_The_Unbeliever
Nov 19 '18 at 14:46
1
Looks like a job for Regex docs.microsoft.com/en-us/dotnet/api/…
– pm_2
Nov 19 '18 at 14:46
I would recommend writing your own replacing function if you dont want to see Regex. In this case the whole world need to match so you can split the string on spaces, loop through all the worlds and replace them. then rebuild the string by joining them together, but punctuation then becomes a problem.
– DaanV
Nov 19 '18 at 14:46
2
To a first approximation, regexes haveb
for matching "word boundaries", which isn't perfect ("isn't" isn't two words, for starters), but it's something. Beware that naive implementations of word replacement are likely to produce laughable results if you're not careful -- many fixed expressions involve the word "man" in a context where it can't be replaced with "woman" or "person", for example. If a rewrite requires adjusting the grammar, that's a whole different kettle of fish.
– Jeroen Mostert
Nov 19 '18 at 14:47
1
1
Are you assuming grammatically correct, well punctuated inputs? If not, how do you plan to cope with e.g.
shell
- a hard protective cover, vs shell
- she will contracted with a missing apostrophe?– Damien_The_Unbeliever
Nov 19 '18 at 14:46
Are you assuming grammatically correct, well punctuated inputs? If not, how do you plan to cope with e.g.
shell
- a hard protective cover, vs shell
- she will contracted with a missing apostrophe?– Damien_The_Unbeliever
Nov 19 '18 at 14:46
1
1
Looks like a job for Regex docs.microsoft.com/en-us/dotnet/api/…
– pm_2
Nov 19 '18 at 14:46
Looks like a job for Regex docs.microsoft.com/en-us/dotnet/api/…
– pm_2
Nov 19 '18 at 14:46
I would recommend writing your own replacing function if you dont want to see Regex. In this case the whole world need to match so you can split the string on spaces, loop through all the worlds and replace them. then rebuild the string by joining them together, but punctuation then becomes a problem.
– DaanV
Nov 19 '18 at 14:46
I would recommend writing your own replacing function if you dont want to see Regex. In this case the whole world need to match so you can split the string on spaces, loop through all the worlds and replace them. then rebuild the string by joining them together, but punctuation then becomes a problem.
– DaanV
Nov 19 '18 at 14:46
2
2
To a first approximation, regexes have
b
for matching "word boundaries", which isn't perfect ("isn't" isn't two words, for starters), but it's something. Beware that naive implementations of word replacement are likely to produce laughable results if you're not careful -- many fixed expressions involve the word "man" in a context where it can't be replaced with "woman" or "person", for example. If a rewrite requires adjusting the grammar, that's a whole different kettle of fish.– Jeroen Mostert
Nov 19 '18 at 14:47
To a first approximation, regexes have
b
for matching "word boundaries", which isn't perfect ("isn't" isn't two words, for starters), but it's something. Beware that naive implementations of word replacement are likely to produce laughable results if you're not careful -- many fixed expressions involve the word "man" in a context where it can't be replaced with "woman" or "person", for example. If a rewrite requires adjusting the grammar, that's a whole different kettle of fish.– Jeroen Mostert
Nov 19 '18 at 14:47
add a comment |
2 Answers
2
active
oldest
votes
You should consider an NLP library such as https://sergey-tihon.github.io/Stanford.NLP.NET/StanfordCoreNLP.html or https://www.nrecosite.com/nlp_ner_net.aspx
In that way you can break down the sentence into tokens and then identify and replace the subject of that sentence.
var tokens = new Tokenizer().Parse("John closed tasks");
var searchQuery = new TokenSequence(tokens.ToArray());
recognizer.Recognize(searchQuery, matchesCombinationHandler);
add a comment |
I would do a replacement of ".She ", " She ", ".she ", " she ", " she,", " She,", " she;", " She;". As english speaking human we use spaces and punctuation in writing to determine if the letters are their own word or part of another word. So this is really the only way to do it. Of course you could probably make a regular expression but with the same approach.
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53376968%2fi-need-to-convert-us-english-gender-specific-text-from-one-gender-to-another-or%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
You should consider an NLP library such as https://sergey-tihon.github.io/Stanford.NLP.NET/StanfordCoreNLP.html or https://www.nrecosite.com/nlp_ner_net.aspx
In that way you can break down the sentence into tokens and then identify and replace the subject of that sentence.
var tokens = new Tokenizer().Parse("John closed tasks");
var searchQuery = new TokenSequence(tokens.ToArray());
recognizer.Recognize(searchQuery, matchesCombinationHandler);
add a comment |
You should consider an NLP library such as https://sergey-tihon.github.io/Stanford.NLP.NET/StanfordCoreNLP.html or https://www.nrecosite.com/nlp_ner_net.aspx
In that way you can break down the sentence into tokens and then identify and replace the subject of that sentence.
var tokens = new Tokenizer().Parse("John closed tasks");
var searchQuery = new TokenSequence(tokens.ToArray());
recognizer.Recognize(searchQuery, matchesCombinationHandler);
add a comment |
You should consider an NLP library such as https://sergey-tihon.github.io/Stanford.NLP.NET/StanfordCoreNLP.html or https://www.nrecosite.com/nlp_ner_net.aspx
In that way you can break down the sentence into tokens and then identify and replace the subject of that sentence.
var tokens = new Tokenizer().Parse("John closed tasks");
var searchQuery = new TokenSequence(tokens.ToArray());
recognizer.Recognize(searchQuery, matchesCombinationHandler);
You should consider an NLP library such as https://sergey-tihon.github.io/Stanford.NLP.NET/StanfordCoreNLP.html or https://www.nrecosite.com/nlp_ner_net.aspx
In that way you can break down the sentence into tokens and then identify and replace the subject of that sentence.
var tokens = new Tokenizer().Parse("John closed tasks");
var searchQuery = new TokenSequence(tokens.ToArray());
recognizer.Recognize(searchQuery, matchesCombinationHandler);
answered Nov 19 '18 at 17:03


Rebecca
9,520968110
9,520968110
add a comment |
add a comment |
I would do a replacement of ".She ", " She ", ".she ", " she ", " she,", " She,", " she;", " She;". As english speaking human we use spaces and punctuation in writing to determine if the letters are their own word or part of another word. So this is really the only way to do it. Of course you could probably make a regular expression but with the same approach.
add a comment |
I would do a replacement of ".She ", " She ", ".she ", " she ", " she,", " She,", " she;", " She;". As english speaking human we use spaces and punctuation in writing to determine if the letters are their own word or part of another word. So this is really the only way to do it. Of course you could probably make a regular expression but with the same approach.
add a comment |
I would do a replacement of ".She ", " She ", ".she ", " she ", " she,", " She,", " she;", " She;". As english speaking human we use spaces and punctuation in writing to determine if the letters are their own word or part of another word. So this is really the only way to do it. Of course you could probably make a regular expression but with the same approach.
I would do a replacement of ".She ", " She ", ".she ", " she ", " she,", " She,", " she;", " She;". As english speaking human we use spaces and punctuation in writing to determine if the letters are their own word or part of another word. So this is really the only way to do it. Of course you could probably make a regular expression but with the same approach.
answered Nov 19 '18 at 14:48


Josh Woodcock
1,5801016
1,5801016
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53376968%2fi-need-to-convert-us-english-gender-specific-text-from-one-gender-to-another-or%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
Are you assuming grammatically correct, well punctuated inputs? If not, how do you plan to cope with e.g.
shell
- a hard protective cover, vsshell
- she will contracted with a missing apostrophe?– Damien_The_Unbeliever
Nov 19 '18 at 14:46
1
Looks like a job for Regex docs.microsoft.com/en-us/dotnet/api/…
– pm_2
Nov 19 '18 at 14:46
I would recommend writing your own replacing function if you dont want to see Regex. In this case the whole world need to match so you can split the string on spaces, loop through all the worlds and replace them. then rebuild the string by joining them together, but punctuation then becomes a problem.
– DaanV
Nov 19 '18 at 14:46
2
To a first approximation, regexes have
b
for matching "word boundaries", which isn't perfect ("isn't" isn't two words, for starters), but it's something. Beware that naive implementations of word replacement are likely to produce laughable results if you're not careful -- many fixed expressions involve the word "man" in a context where it can't be replaced with "woman" or "person", for example. If a rewrite requires adjusting the grammar, that's a whole different kettle of fish.– Jeroen Mostert
Nov 19 '18 at 14:47