Hi,
I have a bunch of sentences in a file and I want to match the Nouns Phrases, which are between these delimiters <NP#>...</NP>
and substitute (delete) -in the noun phrase-, all the tags, to add only one tag "/NP" on the last word of the phrase.
This for each sentence...
<S> Who/WP is/VBZ <NP1> the/DT author/NN </NP> of/IN <NP2> the/DT book
+/NN </NP> ,/,/*comma* "/"/*\
quote* <NP3> The/DT Iron/NNP Lady/NNP </NP> :/: <NP4> A/DT Biography/N
+NP of/IN \Margaret/NNP That\
cher/NNP </NP> "/"/*quote* ?/./*end-of-sentence*</S>
Result:
<S> Who/WP is/VBZ the author/NP of/IN the book/NP ,/, The Iron Lady
+/NP :/: A Biography of Margaret That\
cher/NP "/"...
So far, I am getting nothing with the match, no even with the replacement
if ($sentence =~ / (<NP\d*>) ([a-zA-Z0-9.-_]+)\/([A-Z]+) ([^ ]+) (<\/
+NP>) /) {
$text="NounPhrase"; # to test the match to replace
$result =~ s/$question/$text/;
print "$result";};
Thanks in advance for your help