#!/usr/bin/perl

$incomments = 0;
while(<STDIN>) {
	$len = length($_);
	if (/^<CommentsCorrections>/) {
		$incomments = 1;
		next;
	}	
	if (/^<\/CommentsCorrections>/) {
		$incomments = 0;
		next;
	}
	if ($incomments) { next; }
	if (/^<PMID>/) {
		print "\nPMID " . substr($_, 6, $len - 14) . "\n";
		next;
	}
	if (/^<ArticleTitle>/) {
		$text = substr($_, 14, $len - 30);
		&segment;
		print $text . "\n";
		next;
	}
	if (/^<AbstractText>/) {
		$text = substr($_, 14, $len - 30);
		&segment;
		print "ABSTRACT\n";
		print $text . "\n";
		next;
	}
	next;
	print;
}

sub segment {
	$text =~ s/&amp;/&/g;
	$text =~ s/&lt;/</g;
	$text =~ s/&gt;/>/g;
	$text =~ s/&quot;/"/g;
	$text =~ s/&apos;/'/g;
	$text =~ s/\. +([A-Z])/\.\n$1/g;
	$text =~ s/Dr\.\n/Dr\. /g;
}