Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8605729
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T02:54:40+00:00 2026-06-12T02:54:40+00:00

I read a text into R using the readChar() function. I aim at testing

  • 0

I read a text into R using the readChar() function. I aim at testing the hypothesis that the sentences of the text have as many occurrences of letter “a” as occurrences of letter “b”. I recently discovered the {stringr} package, which helped me a great deal to do useful things with my text such as counting the number of characters and the total number of occurrences of each letter in the entire text. Now, I need to know the number of sentences in the whole text. Does R have any function, which can help me do that? Thank you very much!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T02:54:41+00:00Added an answer on June 12, 2026 at 2:54 am

    Thank you @gui11aume for your answer. A very good package I just found that can help do the work is {openNLP}. This is the code to do that:

    install.packages("openNLP") ## Installs the required natural language processing (NLP) package
    install.packages("openNLPmodels.en") ## Installs the model files for the English language
    library(openNLP) ## Loads the package for use in the task
    library(openNLPmodels.en) ## Loads the model files for the English language
    
    text = "Dr. Brown and Mrs. Theresa will be away from a very long time!!! I can't wait to see them again." ## This sentence has unusual punctuation as suggested by @gui11aume
    
    x = sentDetect(text, language = "en") ## sentDetect() is the function to use. It detects and seperates sentences in a text. The first argument is the string vector (or text) and the second argument is the language.
    x ## Displays the different sentences in the string vector (or text).
    
    [1] "Dr. Brown and Mrs. Theresa will be away from a very long time!!! "
    [2] "I can't wait to see them again."
    
    length(x) ## Displays the number of sentences in the string vector (or text).
    
    [1] 2
    

    The {openNLP} package is really great for natural language processing in R and you can find a good and short intro to it here or you can check out the package’s documentation here.

    Three more languages are supported in the package. You just need to install and load the corresponding model files.

    1. {openNLPmodels.es} for Spanish
    2. {openNLPmodels.ge} for German
    3. {openNLPmodels.th} for Thai
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am wanting to read the text of multiple files into a string using
I have this text read into an NSString *responce which I am trying to
I'm trying to read a text document that is separated into essentially paragraphs of
I have block of text read from a PDF document, using the ItextSharp library(method:
I would like to read a text file into an array of strings using
I am using MySQL phpmyadmin. I have a inserted a multi-lingual text into DB
I have a text editing program that saves it's output into a PDF file.
I want to read and write NaN values from/into text files using iostream and
I have an ssis package...which read data from fixed-column-width text file into DB table.
I try to read a text files with 20x20 data into variable C, and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.