PDA

View Full Version : Giúp mình với - rất cấp bách



timedy
30-11-2004, 18:15
Mình tìm được trên mạng một bài nói cách download toàn bộ medical dictionnary với nội dung sau:



If you followed the last tutorials, you now have at least the Merck Manual, the Merck Geriatrics Manual, and the South African Monographs reference. But you still don't have what's sometime needed - a medical dictionnary.

No problemo : let's create one using a copylefted ressource available online : the OMD. They never replied to my requests, so we'll once again have to use wget...

The following script will retrieve a ~700 Mb local copy of the website:


for i in B C D E F G H I J K L M N O P Q R S T U V W X Y Z; do
wget -l 1 -r --user-agent="Mozilla/4.0 (compatible; MSIE 6.0; MSIE 5.5; Windows NT 5.1) Opera 7.0 [en]" http://cancerweb.ncl.ac.uk/omd/contents/$i.html ; mv cancerweb.ncl.ac.uk omd/$i
done

The process it with the following scripts: save the first one as "par.pl" and make it executable with chmod +x


#!/usr/bin/perl

$inputfile =$ARGV[0];
$line="0";

if (! -f "$inputfile") {
die ("Usage: parse.pl $file");
}

open (INPUTF, $inputfile) or die "Couldn't open " . $inputfile . " !";

do {
$term=<INPUTF>;
} until ($term =~ m{.*?<H1>.*?</H1>.*?}gsi);

$term =~ s{.*?<H1>}{<entry>};
$term =~ s{</H1>.*?}{</entry>};
$definition = "<definition>";

do {
$line=<INPUTF>;
$definition=$definition . " " . $line;
} until ($line =~ m{<HR>});

$definition =~ s{<HR>}{</definition>};

printf ($term . "\n");
printf ($definition);

This one should be called "createxml.sh" :

for letter in A B C D E F G H I J K L M N O P Q R S T U V W X Y Z; do for i in $letter/cgi-bin/omd\?* ; do ./par.pl $i >> dic$letter.xml ; done ; rm -fr $letter; done

You will then have various dic.xml files. The next step will be converting them into a big zbedic file - we'll see how to do that in the next tutorial.


Như mình lại không hiểu làm cách nào để thực hiện những chỉ dẫn trên vì bản thân mình chỉ biết sữ dụng Internet để tìm kiếm thông tin thôi chứ lập trình thì mù tịt. Mong các bạn nếu được có thể giúp mình được không vì mình rất cần nguồn thông tin này phục vụ cho việc học tập.
Rất mong được sự hướng dẩn tận tình của các chuyên gia. Nếu như mình post bài không đúng vị trí thì nhờ admin chuyển tới nơi thích hợp vì thật chất mình cũng chẳng biết nội dung nó hướng dẫn gì.
Nguyên trang của nội dung trên ở: http://externe.net/zaurus/modules.php?op=modload&name=News&file=article&sid=30&mode=thread&order=0&thold=0

doremimon
14-12-2004, 19:59
he he topic nay hay day