Jump to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Hi!

I have a question about the capitalization of sentences via calculation. I have a text field to which I usually import certain amount of text (cca. 10 sentences) in the form of sentences but without the capitalization of the first letter in a sentence. Is there a way to capitalize the fist letter of each sentence via calculation?

Any help is appreciated!

9 minutes ago, Sinky said:

Is there a way to capitalize the fist letter of each sentence via calculation?

Maybe. It depends on whether there is a way to recognize where a sentence begins and/or ends - IOW, on your definition of what exactly is a "sentence". Can you provide a few examples of what this text field can contain?

 

  • Author

Thank you for quick reply.

I would make it simple. The first letter after the full stop should be capitalized. There is space between the full stop and first letter. I hope this helps.

 

42 minutes ago, Sinky said:

The first letter after the full stop should be capitalized.

That is indeed simple. Perhaps even too simple - because that would exclude the very first letter in the field. Assuming that's not what you meant, and assuming a bunch of other stuff - such as that the first character after a full stop and a space is not a punctuation character, and that the field does not contain any carriage returns - you could try something like = 

While ( [ 
listOfValues = Substitute ( YourTable::Textfield ; ". " ; "¶" ) ;
i = 1 ;
n = ValueCount ( listOfValues ) ;
result = ""
] ; 
i ≤ n ; 
[ 
value = GetValue ( listOfValues ; i ) ;
result = List ( result ; Upper ( Left ( value ; 1 ) ) & Right ( value ; Length ( value ) - 1 ) ) ;
i = i + 1
] ; 
Substitute ( result ; ¶ ; ". " ) 
)

 

Edited by comment

  • Author

Sorry I should have been more specific. The imported text is a transcription of speech via speech-to-text app. Because of this, the very first letter is always capitalized but other first letters of sentences are not. The first character after a full stop is never a punctuation character. However, there are carriage returns.

Here is an example of text:

Woke up early. did twenty push-ups plus 3 minute plank.

skipped lunch. gym after work. 

55 minutes ago, Sinky said:

However, there are carriage returns.

That could be handled. However, in your example, there is no space after the 2nd full stop (the one after "plank"). I am not sure if that's just an omission on your part, or is this how it is for real. Because then it starts to move away from "simple".

 

  • Author

You're right, that's my mistake. There should be space after 2nd full stop.

Edited by Sinky

1 hour ago, Sinky said:

There should be space after 2nd full stop.

But then this contradicts your earlier statement:

3 hours ago, Sinky said:

The first character after a full stop is never a punctuation character.

Here, the first character after the full stop and space is a carriage return. So this is still not as "simple" as promised.

So far I've come up with this = 

While ( [ 
listOfValues = Substitute ( YourTable::Textfield ; [ ". ¶" ; Char (1300031) ] ; [ ". " ; Char (1300030) ] ) ;
i = 1 ;
n = ValueCount ( listOfValues ) ;
result = ""
] ; 
i ≤ n ; 
[ 
value = GetValue ( listOfValues ; i ) ;
result = List ( result ; Upper ( Left ( value ; 1 ) ) & Right ( value ; Length ( value ) - 1 ) ) ;
i = i + 1
] ; 
Substitute ( result ; [ Char (1300030) ; ". " ] ; [ Char (1300031) ; ". ¶" ]  ) 
)

See if it works for you as expected. I'll try to come back to this later to see if it can be streamlined a bit.

Is there ever a case where a carriage return comes in the middle of a sentence?

 

 

 

Edited by comment

  • Author

Hey, no need to trouble yourself further with this. The solution you offered works perfect. Thank you once again!

Create an account or sign in to comment

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.