Sort by

recency

|

57 Discussions

|

  • + 0 comments

    Hiden test case 0 and 1 error. But I can run it on Collab and here. Why?

    My code: input_text = input("Enter your text: ")

    def split_into_sentences(text): pattern = r'(?

  • + 0 comments

    import re

    def split_sentences(text): # Define the regular expression pattern to match sentence boundaries pattern = r"""(?<=\w.)\s+"""

    # Split the text into sentences using the pattern
    sentences = re.split(pattern, text)
    
    # Clean up the sentences by removing leading and trailing whitespace and empty strings
    sentences = [sentence.strip() for sentence in sentences if sentence.strip()]
    
    # Handle sentences ending with common abbreviations (e.g., Dr., Mr., Mrs.)
    sentences = [sentence[:-1] if sentence.endswith(".") and sentence[-2:] in [".D", ".M", ".M"] else sentence for sentence in sentences]
    
    return sentences
    

    Get the input text from the user

    input_text = input("Enter your text: ")

    Split the text into sentences

    sentences = split_sentences(input_text)

    Print the sentences

    for sentence in sentences: print(sentence)

  • + 0 comments

    I have tried NLP for my Page but I'm not sure whether I' successful or not. Kindly check and let me know.

  • + 0 comments

    This is my code

    import re
    text=str(input())
    
    for i in re.split("(?<=[.!?\"]) +", text):
        print(i)
    
  • + 0 comments
    #import re
    #sentence = "^\".*\"$|.*!$|.*?$|[a-zA-Z0-9]+\."
    input_text = raw_input().strip().split()
    strp = 0
    for i in range(len(input_text)):
        if '.' in input_text[i] or '?' in input_text[i] or '!' in input_text[i]:
            print(' '.join(input_text[strp:i+1]))
            strp = i+1
    print(' '.join(input_text[strp:]))