CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
Script Modification Required

 



vkchan
New User

Sep 15, 2013, 4:10 AM

Post #1 of 2 (512 views)
Script Modification Required Can't Post

Input:
<title>REFERENCES</title>
<ref id="ref0023"><mixed-citation publication-type="journal"><label>1.</label> <string-name><surname>Bell</surname> <given-names>BG</given-names></string-name>, <string-name><surname>Kircher</surname> <given-names>JC</given-names></string-name>, <string-name><surname>Bernhardt</surname> <given-names>PC</given-names></string-name>. <article-title>New measures improve the accuracy of the directed-lie test when detecting deception using a mock crime</article-title>. <source><italic>Physiol Behav</italic></source> <year>2008</year>; <volume><bold>94</bold></volume>: <fpage>331</fpage>–<lpage>340</lpage>.</mixed-citation></ref>
<ref id="ref0024"><mixed-citation publication-type="journal"><label>2.</label> <string-name><surname>Lykken</surname> <given-names>DT</given-names></string-name>. <article-title>Psychology and the lie detector industry</article-title>. <source><italic>Am Psychol</italic></source> <year>1974</year>; <volume><bold>29</bold></volume>: <fpage>725</fpage>–<lpage>739</lpage>.</mixed-citation></ref>

<p><bold>Development of the CAINS</bold></p>
<kwd-group><kwd>ACL</kwd><kwd>Injury</kwd><kwd>Reconstruction</kwd><kwd>Muscle</kwd><kwd>EMG</kwd></kwd-group>

<title>References</title>
<ref id="ref0051"><mixed-citation publication-type="journal"><label>1.</label> <string-name><surname>Kirkpatrick</surname> <given-names>B</given-names></string-name>, <string-name><surname>Fenton</surname> <given-names>WS</given-names></string-name>, <string-name><surname>Carpenter</surname> <given-names>WT</given-names> <suffix>Jr</suffix></string-name>, <article-title>Marder SR: The NIMH-MATRICS consensus statement on negative symptoms</article-title>. <source>Schizophr Bull</source> <year>2006</year>; <volume>32</volume>:<fpage>214</fpage>–<lpage>219</lpage></mixed-citation></ref>
<ref id="ref0052"><mixed-citation publication-type="journal"><label>2.</label> <string-name><surname>Blanchard</surname> <given-names>JJ</given-names></string-name>, <string-name><surname>Kring</surname> <given-names>AM</given-names></string-name>, <string-name><surname>Horan</surname> <given-names>WP</given-names></string-name>, <article-title>Gur RE: Toward the next generation of negative symptom assessments: the collaboration to advance negative symptom assessment in schizophrenia</article-title>. <source>Schizophr Bull</source> <year>2011</year>; <volume>37</volume>:<fpage>291</fpage>–<lpage>299</lpage> <comment>10.1093/schbul/sbq104</comment></mixed-citation></ref>




Output:
<title>REFERENCES</title>
<ref id="R1"><no>1.</no><cit type="journal"> <au><lname>Bell</lname> <fname>BG</fname></au>, <au><lname>Kircher</lname> <fname>JC</fname></au>, <au><lname>Bernhardt</lname> <fname>PC</fname></au>. <atitle>New measures improve the accuracy of the directed-lie test when detecting deception using a mock crime</atitle>. <source><I>Physiol Behav</I></source> <yr>2008</yr>; <vol><B>94</B></vol>: <fpage>331</fpage>–<lpage>340</lpage>.</cit></ref>
<ref id="R2"><no>2.</no><cit type="journal"> <au><lname>Lykken</lname> <fname>DT</fname></au>. <atitle>Psychology and the lie detector industry</atitle>. <source><I>Am Psychol</I></source> <yr>1974</yr>; <vol><B>29</B></vol>: <fpage>725</fpage>–<lpage>739</lpage>.</cit></ref>

<p><bold>Development of the CAINS</bold></p>
<kwd-group><kwd>ACL</kwd><kwd>Injury</kwd><kwd>Reconstruction</kwd><kwd>Muscle</kwd><kwd>EMG</kwd></kwd-group>

<title>References</title>
<ref id="R1"><cit type="journal"> <au><lname>Kirkpatrick</lname> <fname>B</fname></au>, <au><lname>Fenton</lname> <fname>WS</fname></au>, <au><lname>Carpenter</lname> <fname>WT</fname> <sfx>Jr</sfx></au>, <atitle>Marder SR: The NIMH-MATRICS consensus statement on negative symptoms</atitle>. <source>Schizophr Bull</source> <yr>2006</yr>; <vol>32</vol>:<fpage>214</fpage>–<lpage>219</lpage></cit></ref>
<ref id="R2"><cit type="journal"> <au><lname>Blanchard</lname> <fname>JJ</fname></au>, <au><lname>Kring</lname> <fname>AM</fname></au>, <au><lname>Horan</lname> <fname>WP</fname></au>, <atitle>Gur RE: Toward the next generation of negative symptom assessments: the collaboration to advance negative symptom assessment in schizophrenia</atitle>. <source>Schizophr Bull</source> <yr>2011</yr>; <vol>37</vol>:<fpage>291</fpage>–<lpage>299</lpage> <comment>10.1093/schbul/sbq104</comment></cit></ref>


Script Used:


my $xmlcont='';
my $input=$ARGV[0];

#print $input;
opendir (DIRC, $input) || die "canot open the file";

@chap_files=(readdir(DIRC));
@files = grep(/(.*?).xml/, @chap_files);
#print @files;
foreach $file_one(@files) {
open (CHAP, $input . "\\" . $file_one) || die "canot open the file";
open (XMLFILE, ">". $input . "\\output\\" . $file_one ."_out") || die "can't open xml file";
$xmlcont_abs='';
while (<CHAP>) {
$xmlcont=$_;
# Content Removal
$xmlcont =~ s#(<mixed-citation publication-type="book">)(<label>\d</lable>)#<\2\1>#gi;
$xmlcont =~ s#</label>#</no>#gi;
$xmlcont =~ s#<label>#<no>#gi;
$xmlcont =~ s#<string-name>#<au>#gi;
$xmlcont =~ s#</string-name>#</au>#gi;
$xmlcont =~ s#<surname>#<lname>#gi;
$xmlcont =~ s#</surname>#</lname>#gi;
$xmlcont =~ s#<given-names>#<fname>#gi;
$xmlcont =~ s#</given-names>#</fname>#gi;
$xmlcont =~ s#<(s)uf(f)i(x)>#<\1\2\3>#gi;
$xmlcont =~ s#<(a)rticle-(title)>#<\1\2>#gi;


$xmlcont_abs.=$xmlcont;



}
close (CHAP);
print XMLFILE $xmlcont_abs;
close(XMLFILE);

}


Request for Modification:
1. <ref id="ref00XX"> should change as <ref id="R1">
2. <mixed-citation publication-type="journal"><label>1.</label> need to change as "<no>1.</no><cit type="journal">". (Transpose required between these two)


(This post was edited by vkchan on Sep 15, 2013, 4:12 AM)


Laurent_R
Veteran / Moderator

Sep 16, 2013, 10:44 AM

Post #2 of 2 (479 views)
Re: [vkchan] Script Modification Required [In reply to] Can't Post

You already asked that in the intermediate section (under a different name ?), please don't ask the same questions in different parts of the forum.

To people wishing to answer: please do it in the intermediate sections, where there are already some answers.

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives