how to replace question mark to wordHow can I represent an 'Enum' in Python?How to flush output of print function?Keeping special marks when splitting text into tokens using regexNLP - identifying and replacing words (synonyms) in RHow to write a regular expression to search and replace a string using python?Apply regular expressions on a specific column in PandasPython Regex Sub: Using Dictionary with Regex ExpressionsReplacing a string with another using regex in PythonHow to replace a word in a sentence ONLY IF that word appears on its own (i.e. is not part of another word)? PythonTypeError when replacing strings with a list comprehension
What is the logic behind charging tax _in the form of money_ for owning property when the property does not produce money?
Why Does Mama Coco Look Old After Going to the Other World?
Why the output signal of my amplifier is heavily distorted
Do you have to have figures when playing D&D?
What should I discuss with my DM prior to my first game?
Possible runaway argument using circuitikz
Increase speed altering column on large table to NON NULL
Why is long-term living in Almost-Earth causing severe health problems?
The origin of the Russian proverb about two hares
What aircraft was used as Air Force One for the flight between Southampton and Shannon?
Can you make an identity from this product?
What is the color of artificial intelligence?
Should I refuse to be named as co-author of a low quality paper?
I'm creating a new scratch org - will it be based on Summer '19 (production org edition) or Spring '19 (sandbox edition)?
Does putting salt first make it easier for attacker to bruteforce the hash?
Is it okay to have a sequel start immediately after the end of the first book?
Section numbering in binary
What are formats in LaTeX and how to manage them?
How can I remove material from this wood beam?
What is the Leave No Trace way to dispose of coffee grounds?
Who voices the small round football sized demon in Good Omens?
What differences exist between adamantine and adamantite in all editions of D&D?
Was Self-modifying-code possible just using BASIC?
How can one's career as a reviewer be ended?
how to replace question mark to word
How can I represent an 'Enum' in Python?How to flush output of print function?Keeping special marks when splitting text into tokens using regexNLP - identifying and replacing words (synonyms) in RHow to write a regular expression to search and replace a string using python?Apply regular expressions on a specific column in PandasPython Regex Sub: Using Dictionary with Regex ExpressionsReplacing a string with another using regex in PythonHow to replace a word in a sentence ONLY IF that word appears on its own (i.e. is not part of another word)? PythonTypeError when replacing strings with a list comprehension
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
I have Arabic tweet and I want to replace question marks and exclamation into Arabic word synonymous I tried this code i used regular expression but nothing happens. I used jupyter notebook
def replace_questionmark(tweet):
text = re.sub("!", "تعجب",tweet)
text = re.sub('استفهام','؟' ,tweet)
return tweet
data_df['clean text'] = data_df['Text'].apply(lambda x: replace_questionmark(x))
python-3.x nlp
add a comment |
I have Arabic tweet and I want to replace question marks and exclamation into Arabic word synonymous I tried this code i used regular expression but nothing happens. I used jupyter notebook
def replace_questionmark(tweet):
text = re.sub("!", "تعجب",tweet)
text = re.sub('استفهام','؟' ,tweet)
return tweet
data_df['clean text'] = data_df['Text'].apply(lambda x: replace_questionmark(x))
python-3.x nlp
works for me. Could you add an example of how it failed?
– DYZ
Mar 24 at 21:13
when i read the data it did not replace the marks
– fafa
Mar 24 at 21:37
Please indent your code correctly and add a Minimal, Complete, and Verifiable example - something small that we can run and reproduce your problem.
– DYZ
Mar 24 at 21:54
You're passingtweet
tore.sub
and saving the returned string totext
(twice) then you return the unchanged variabletweet
. Try replacingtext
withtweet
– Justin Ezequiel
Mar 24 at 22:28
yes, I replace text with tweet. it replaces only the "!" but "؟" did not replace. I do not know why.I think because of its Arabic marks, it did not recognize it ??
– fafa
Mar 25 at 12:20
add a comment |
I have Arabic tweet and I want to replace question marks and exclamation into Arabic word synonymous I tried this code i used regular expression but nothing happens. I used jupyter notebook
def replace_questionmark(tweet):
text = re.sub("!", "تعجب",tweet)
text = re.sub('استفهام','؟' ,tweet)
return tweet
data_df['clean text'] = data_df['Text'].apply(lambda x: replace_questionmark(x))
python-3.x nlp
I have Arabic tweet and I want to replace question marks and exclamation into Arabic word synonymous I tried this code i used regular expression but nothing happens. I used jupyter notebook
def replace_questionmark(tweet):
text = re.sub("!", "تعجب",tweet)
text = re.sub('استفهام','؟' ,tweet)
return tweet
data_df['clean text'] = data_df['Text'].apply(lambda x: replace_questionmark(x))
python-3.x nlp
python-3.x nlp
asked Mar 24 at 20:54
fafafafa
112
112
works for me. Could you add an example of how it failed?
– DYZ
Mar 24 at 21:13
when i read the data it did not replace the marks
– fafa
Mar 24 at 21:37
Please indent your code correctly and add a Minimal, Complete, and Verifiable example - something small that we can run and reproduce your problem.
– DYZ
Mar 24 at 21:54
You're passingtweet
tore.sub
and saving the returned string totext
(twice) then you return the unchanged variabletweet
. Try replacingtext
withtweet
– Justin Ezequiel
Mar 24 at 22:28
yes, I replace text with tweet. it replaces only the "!" but "؟" did not replace. I do not know why.I think because of its Arabic marks, it did not recognize it ??
– fafa
Mar 25 at 12:20
add a comment |
works for me. Could you add an example of how it failed?
– DYZ
Mar 24 at 21:13
when i read the data it did not replace the marks
– fafa
Mar 24 at 21:37
Please indent your code correctly and add a Minimal, Complete, and Verifiable example - something small that we can run and reproduce your problem.
– DYZ
Mar 24 at 21:54
You're passingtweet
tore.sub
and saving the returned string totext
(twice) then you return the unchanged variabletweet
. Try replacingtext
withtweet
– Justin Ezequiel
Mar 24 at 22:28
yes, I replace text with tweet. it replaces only the "!" but "؟" did not replace. I do not know why.I think because of its Arabic marks, it did not recognize it ??
– fafa
Mar 25 at 12:20
works for me. Could you add an example of how it failed?
– DYZ
Mar 24 at 21:13
works for me. Could you add an example of how it failed?
– DYZ
Mar 24 at 21:13
when i read the data it did not replace the marks
– fafa
Mar 24 at 21:37
when i read the data it did not replace the marks
– fafa
Mar 24 at 21:37
Please indent your code correctly and add a Minimal, Complete, and Verifiable example - something small that we can run and reproduce your problem.
– DYZ
Mar 24 at 21:54
Please indent your code correctly and add a Minimal, Complete, and Verifiable example - something small that we can run and reproduce your problem.
– DYZ
Mar 24 at 21:54
You're passing
tweet
to re.sub
and saving the returned string to text
(twice) then you return the unchanged variable tweet
. Try replacing text
with tweet
– Justin Ezequiel
Mar 24 at 22:28
You're passing
tweet
to re.sub
and saving the returned string to text
(twice) then you return the unchanged variable tweet
. Try replacing text
with tweet
– Justin Ezequiel
Mar 24 at 22:28
yes, I replace text with tweet. it replaces only the "!" but "؟" did not replace. I do not know why.I think because of its Arabic marks, it did not recognize it ??
– fafa
Mar 25 at 12:20
yes, I replace text with tweet. it replaces only the "!" but "؟" did not replace. I do not know why.I think because of its Arabic marks, it did not recognize it ??
– fafa
Mar 25 at 12:20
add a comment |
1 Answer
1
active
oldest
votes
The following code solves your problem
import pandas as pd
import re
Text = [u'I am feeling good !', u'I am testing this code ؟']
data_df = pd.DataFrame(columns=['Text'], data=Text)
def replace_questionmark(tweet):
text = tweet.replace(u'!', u'تعج')
text = text.replace(u'؟', u'استفهام')
return text.encode('utf-8')
data_df['clean text'] = data_df['Text'].apply(lambda x: replace_questionmark(x))
print(data_df)
Output
Text clean text
0 I am feeling good ! I am feeling good تعج
1 I am testing this code ؟ I am testing this code استفهام
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%2f55328470%2fhow-to-replace-question-mark-to-word%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
The following code solves your problem
import pandas as pd
import re
Text = [u'I am feeling good !', u'I am testing this code ؟']
data_df = pd.DataFrame(columns=['Text'], data=Text)
def replace_questionmark(tweet):
text = tweet.replace(u'!', u'تعج')
text = text.replace(u'؟', u'استفهام')
return text.encode('utf-8')
data_df['clean text'] = data_df['Text'].apply(lambda x: replace_questionmark(x))
print(data_df)
Output
Text clean text
0 I am feeling good ! I am feeling good تعج
1 I am testing this code ؟ I am testing this code استفهام
add a comment |
The following code solves your problem
import pandas as pd
import re
Text = [u'I am feeling good !', u'I am testing this code ؟']
data_df = pd.DataFrame(columns=['Text'], data=Text)
def replace_questionmark(tweet):
text = tweet.replace(u'!', u'تعج')
text = text.replace(u'؟', u'استفهام')
return text.encode('utf-8')
data_df['clean text'] = data_df['Text'].apply(lambda x: replace_questionmark(x))
print(data_df)
Output
Text clean text
0 I am feeling good ! I am feeling good تعج
1 I am testing this code ؟ I am testing this code استفهام
add a comment |
The following code solves your problem
import pandas as pd
import re
Text = [u'I am feeling good !', u'I am testing this code ؟']
data_df = pd.DataFrame(columns=['Text'], data=Text)
def replace_questionmark(tweet):
text = tweet.replace(u'!', u'تعج')
text = text.replace(u'؟', u'استفهام')
return text.encode('utf-8')
data_df['clean text'] = data_df['Text'].apply(lambda x: replace_questionmark(x))
print(data_df)
Output
Text clean text
0 I am feeling good ! I am feeling good تعج
1 I am testing this code ؟ I am testing this code استفهام
The following code solves your problem
import pandas as pd
import re
Text = [u'I am feeling good !', u'I am testing this code ؟']
data_df = pd.DataFrame(columns=['Text'], data=Text)
def replace_questionmark(tweet):
text = tweet.replace(u'!', u'تعج')
text = text.replace(u'؟', u'استفهام')
return text.encode('utf-8')
data_df['clean text'] = data_df['Text'].apply(lambda x: replace_questionmark(x))
print(data_df)
Output
Text clean text
0 I am feeling good ! I am feeling good تعج
1 I am testing this code ؟ I am testing this code استفهام
answered Mar 29 at 10:04
Noman DilawarNoman Dilawar
85431342
85431342
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.
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%2f55328470%2fhow-to-replace-question-mark-to-word%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
works for me. Could you add an example of how it failed?
– DYZ
Mar 24 at 21:13
when i read the data it did not replace the marks
– fafa
Mar 24 at 21:37
Please indent your code correctly and add a Minimal, Complete, and Verifiable example - something small that we can run and reproduce your problem.
– DYZ
Mar 24 at 21:54
You're passing
tweet
tore.sub
and saving the returned string totext
(twice) then you return the unchanged variabletweet
. Try replacingtext
withtweet
– Justin Ezequiel
Mar 24 at 22:28
yes, I replace text with tweet. it replaces only the "!" but "؟" did not replace. I do not know why.I think because of its Arabic marks, it did not recognize it ??
– fafa
Mar 25 at 12:20