Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
/^[A-Z](*)\.$/
#!perl
use strict;
use warnings;
my $data;
{
local $/ = "";
$data = <DATA>;
}
$data =~ s/\n(?!$)/ /sg;
[b]my @sentences = $data =~ /(.+?[.?!])(?:\s\s+|$)/g;[/b]
for (my $i=0; $i<@sentences; $i++) {
print "$i: $sentences[$i]\n";
}
__DATA__
There are 5 rooms in Mr. Tanaka's house. On the first floor are the living
room and the kitchen. Outside the living room window, we see a garden. In
the garden, we see Mr. Tanaka playing ball with his son. On the second floor
are the master bedroom, a bathroom, and the children's bedroom. There is no
TV in the children's bedroom, but there are a stereo and a computer.
0: There are 5 rooms in Mr. Tanaka's house.
1: On the first floor are the living room and the kitchen.
2: Outside the living room window, we see a garden.
3: In the garden, we see Mr. Tanaka playing ball with his son.
4: On the second floor are the master bedroom, a bathroom, and the children's bedroom.
5: There is no TV in the children's bedroom, but there are a stereo and a computer.
#!perl
use strict;
use warnings;
my $data;
{
local $/ = "";
$data = <DATA>;
}
$data =~ s/\n(?!$)/ /sg;
[b]my @sentences = $data =~ /(.+?[.;?!])(?:\s+|$)/g;[/b]
for (my $i=0; $i<@sentences; $i++) {
[b]$sentences[$i] = process($sentences[$i], ":");[/b]
print "$i: $sentences[$i]\n";
}
[b]sub process {
my ($string, $pattern) = @_;
$string =~ /$pattern/? "<SPAN>".$string."</SPAN>": $string;
}[/b]
__DATA__
There are 5 rooms in Mr. Tanaka's house. On the first floor: the living
room and the kitchen. Outside the living room window, we see a garden. In
the garden, we see Mr. Tanaka playing ball with his son. On the second floor:
the master bedroom, a bathroom, and the children's bedroom. There is no
TV in the children's bedroom; but there are a stereo and a computer.
0: There are 5 rooms in Mr.
1: Tanaka's house.
2: <SPAN>On the first floor: the living room and the kitchen.</SPAN>
3: Outside the living room window, we see a garden.
4: In the garden, we see Mr.
5: Tanaka playing ball with his son.
6: <SPAN>On the second floor: the master bedroom, a bathroom, and the children's bedroom.</SPAN>
7: There is no TV in the children's bedroom;
8: but there are a stereo and a computer.
#!perl
use strict;
use warnings;
my $data;
{
local $/ = "";
$data = <DATA>;
}
$data =~ s/\n/ /g;
my @sent = split(/(\.|\?|\!)\s/,$data);
for(my $i=0;$i<$#sent-1;$i+=2){
if ($sent[$i] =~ /:/){
print "$i: <SPAN>$sent[$i]$sent[$i+1]</SPAN>\n";
}else{
print "$i: $sent[$i]$sent[$i+1]\n";
}
}
__DATA__
There are 5 rooms in Mr Tanaka's house. On the first floor: the living
room and the kitchen. Outside the living room window, we see a garden. In
the garden, we see Mr Tanaka playing ball with his son? On the second floor:
the master bedroom, a bathroom, and the children's bedroom! There is no
TV in the children's bedroom; but there are a stereo and a computer.
Sentence: There are 5 rooms in Mr Tanaka's house.
Sentence: <SPAN>On the first floor: the living room and the kitchen.</SPAN>
Sentence: Outside the living room window, we see a garden.
Sentence: In the garden, we see Mr Tanaka playing ball with his son?
Sentence: <SPAN>On the second floor: the master bedroom, a bathroom, and the children's bedroom!</SPAN>
Sentence: There is no TV in the children's bedroom; but there are a stereo and a computer.
my $j = 1;
for(my $i=0;$i<$#sent-1;$i+=2){
if ($sent[$i] =~ /:/){
print "$j: <SPAN>$sent[$i]$sent[$i+1]</SPAN>\n";
}else{
print "$j: $sent[$i]$sent[$i+1]\n";
}
$j++;
}