Remove duplicate words from a sentence In this challenge, you will remove duplicate words from each sentence.

Examples

Hello Hello, World!
Hello, World!

Code Code! Golf Code
Code! Golf Code

Hello  hello   World
Hello   World

Programming Golf Programming!
Programming Golf!


Specification


Input will be a string of ASCII characters.
A sentence is defined as anything until the end of the string, a linefeed (\n), or punctuation (.!?).
A word is defined as a sequence of A-Za-z.
Words are case insensitive (Hello == heLlO).





Only the first occurrence of a word in a sentence is kept.
If a word is removed, the spaces before the removed word should be removed. (e.g. A   A B -> A B).





As always standard loopholes are disallowed.




This is code-golf so shortest code in bytes wins!
JavaScript (ES6), 98

Note while I found it myself, it's annoyingly similar to @Neil's, just with the additional logic to split the whole input string in sentences.

s=&gt;s.replace(/[^\n.!?]+/g,s=&gt;s.replace(/ *([a-z]+)/ig,(r,w)=&gt;k[w=w.toUpperCase()]?'':k[w]=r,k=[]))


Test



f=s=&gt;s.replace(/[^\n.!?]+/g,s=&gt;s.replace(/ *([a-z]+)/ig,(r,w)=&gt;k[w=w.toUpperCase()]?'':k[w]=r,k=[]))

console.log=x=&gt;O.textContent+=x+'\n'

;[['Hello Hello, World!','Hello, World!']
,['Code Code! Golf Code','Code! Golf Code']
,['Hello  hello   World','Hello   World']
,['Programming Golf Programming!','Programming Golf!']]
.forEach(t=&gt;{
  var i=t[0],k=t[1],r=f(i)
  console.log((r==k?'OK ':'KO ')+i+' -&gt; '+r)
})  
&lt;pre id=O&gt;&lt;/pre&gt;