4

I'm designing a computer program dealing with double quotation and grammar.

The program has to correct the wrong input text.

Example:-

Input:- He said, “the case is far from over, and we will win.”

Output:- He said, “The case is far from over, and we will win.”

  1. Is the input grammatically wrong?
  2. Is my output correct?
  3. Shall I make the program to change the first letter after every , " to be always in capitalized letter? Will this cause any grammar issues in other cases?
  4. Will this rule always give the correct results in all scenarios of double quotation?
  5. Can I add the same rule for single quotation inside the double quotation? , '
  6. If the quotation starts at the beginning of the sentence then there won't be any comma and space at the beginning.

“Will you still be my friend?” Alberta asked.

In this case shall I use the rule to change the first letter to capital letter if any sentence starts with a double quotation and ends with " ... ?" or " ... !" or " something ."

In the following case there won't be any change:-

Input:- Gretchen said she was “way too busy” to join the gym.

Output:- Gretchen said she was “way too busy” to join the gym.

1
  • 1
    I don't have any proof, but I strongly suspect that the program you propose is a very difficult problem to make, on par with machine translation.
    – Hearth
    May 10, 2022 at 2:19

2 Answers 2

5

Your output in the example is correct.

However, this will cause problems with quotes like:

"I didn't see an actual alien being," Mr Johnson said, "but I sure wish I had."

You'll note that the second half of the quote is not capitalised, but it is set off from the word "said" by a space and comma.

Grammarly offers another example that would cause a problem:

Neil Young’s admonishment “It’s better to burn out than it is to rust” is not appreciated by everyone.

Here the quote is not set off by a comma (since there is no quotive verb like "said"). Nevertheless, the quote is a complete sentence and is correctly capitalised. Some style guides would insert a comma after "admonishment" but not all.

In general the rule is to "capitalize the first letter of a direct quote when the quoted material is a complete sentence".(source) However to decide if the quoted material is a full sentence you would either need the ability to correctly parse English grammar. A simple algorithm is not going to work here.

1
  • 1
    incidentally, you might notice I've put another edge case in my last paragraph. The quote could be a complete sentence, and it is a complete (imperative) sentence in the source, but I've adapted it to flow into my sentence as an infinitive. So I've not capitalised the word "capitalize".
    – James K
    May 9, 2022 at 20:15
2

Output:- He said, “The case is far from over, and we will win.”

Yes, a quoted sentence or sentence in a dialog should always have a capital letter like the beginning of any sentence. However, there should be no comma:

Output:- He said “The case is far from over, and we will win.”

Unless He said is at the end:

Output:- “The case is far from over, and we will win”, he said.

If you are quoting a phrase from a speaker, it is placed in quotation marks without capital letters.

Gretchen said she was “way too busy” to join the gym. [OK]

10
  • Thank you. In the below example there is no need for capital letter, right? - Gretchen said she was “way too busy” to join the gym. The program can just identify such sentences by missing comma, right?
    – user452779
    May 9, 2022 at 14:44
  • 1
    @user452779 Fyi, we say example below, not below example. Cheers.
    – Lambie
    May 9, 2022 at 14:47
  • Thank you. The program won't correct the punctuation, only change the word case based on the comma. Assuming the user always has the correct punctuation.
    – user452779
    May 9, 2022 at 14:51
  • I ran into a problem. What is the difference between " and “ ”. Which one should be used?
    – user452779
    May 9, 2022 at 16:02
  • 2
    The ASCII code for computers only has " and ' and these are the symbols on computer keyboards. For quality typesetting you should use “ ”, but these are inconvenient to type, so in many casual contexts, people just use ". The "straight quote mark" can function as both an opening and a closing quote.
    – James K
    May 9, 2022 at 18:34

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .