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;








1















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))









share|improve this question






















  • 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 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

















1















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))









share|improve this question






















  • 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 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













1












1








1








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))









share|improve this question














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






share|improve this question













share|improve this question











share|improve this question




share|improve this question










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 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

















  • 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 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
















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












1 Answer
1






active

oldest

votes


















0














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 استفهام





share|improve this answer























    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
    );



    );













    draft saved

    draft discarded


















    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









    0














    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 استفهام





    share|improve this answer



























      0














      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 استفهام





      share|improve this answer

























        0












        0








        0







        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 استفهام





        share|improve this answer













        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 استفهام






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Mar 29 at 10:04









        Noman DilawarNoman Dilawar

        85431342




        85431342





























            draft saved

            draft discarded
















































            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.




            draft saved


            draft discarded














            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





















































            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







            Popular posts from this blog

            Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

            Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

            Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript