ANTICHAT — форум по информационной безопасности, OSINT и технологиям
ANTICHAT — русскоязычное сообщество по безопасности, OSINT и программированию.
Форум ранее работал на доменах antichat.ru, antichat.com и antichat.club,
и теперь снова доступен на новом адресе —
forum.antichat.xyz.
Форум восстановлен и продолжает развитие: доступны архивные темы, добавляются новые обсуждения и материалы.
⚠️ Старые аккаунты восстановить невозможно — необходимо зарегистрироваться заново.

21.11.2008, 21:13
|
|
Динозавр
Регистрация: 10.01.2008
Сообщений: 2,841
Провел на форуме: 9220514
Репутация:
3338
|
|
2 Digimortal:
Да я уже понял, раздел с php перепутал. Сорри
|
|
|

24.11.2008, 14:44
|
|
Участник форума
Регистрация: 19.02.2008
Сообщений: 186
Провел на форуме: 584540
Репутация:
96
|
|
Регулярка, нужна помощь, срочно оч...
abbreviate
v. 1 shorten, compress, contract, truncate, trim, reduce,
curtail: We abbreviated some of the longer words to save space.
2 shorten, cut, condense, abridge, abstract, digest, epitomize,
summarize, US synopsize: The school presented an abbreviated
version of A Midsummer Night's Dream.
Есть куча текста такого вида, нужно удалить все предложения(примеры).
В этой ситуации это:
: The school presented an abbreviated
version of A Midsummer Night's Dream.
Все примеры начинаются с : и заканчиваются .
Вот мои не рабочие варианты:
s/: (.*)//ig;
s/: (.*) \.//ig;
s/: (.*) \n \.//ig;
s/: (.*) \n (.*) \.//ig;
Помогите пожалуйста!
|
|
|

24.11.2008, 15:20
|
|
Познавший АНТИЧАТ
Регистрация: 27.04.2007
Сообщений: 1,044
Провел на форуме: 3660186
Репутация:
905
|
|
|
|
|

24.11.2008, 16:02
|
|
Участник форума
Регистрация: 19.02.2008
Сообщений: 186
Провел на форуме: 584540
Репутация:
96
|
|
krypt3r, не то! Ребят помогайте - кто подскажет обязательно плюс поставлю! Еще раз обьясняю задание. Есть текст типа:
wfvdsgfds: sdfsdfdsfasdasf. Надо удалить : sdfsdfdsfasdasf.
|
|
|

24.11.2008, 16:20
|
|
Познавший АНТИЧАТ
Регистрация: 27.04.2007
Сообщений: 1,044
Провел на форуме: 3660186
Репутация:
905
|
|
Чего не то? o_O
Код:
#!/usr/bin/perl
use strict;
use warnings;
my $text = "abbreviate
v. 1 shorten, compress, contract, truncate, trim, reduce,
curtail: We abbreviated some of the longer words to save space.
2 shorten, cut, condense, abridge, abstract, digest, epitomize,
summarize, US synopsize: The school presented an abbreviated
version of A Midsummer Night's Dream.";
$text =~ s/:[^\.]+\.//g;
print $text, "\n";
Результат
Код:
abbreviate
v. 1 shorten, compress, contract, truncate, trim, reduce,
curtail
2 shorten, cut, condense, abridge, abstract, digest, epitomize,
summarize, US synopsize
|
|
|

24.11.2008, 16:25
|
|
Участник форума
Регистрация: 19.02.2008
Сообщений: 186
Провел на форуме: 584540
Репутация:
96
|
|
С этим вопросом разобрался! Спасибо.
Но ребя добить не получается никак  Помогите плз.
Вообще суть такая, есть текстовой документ с таким текстом:
Код:
abandon v. 1 give up or over, yield, surrender, leave, cede, let go,
deliver (up), turn over, relinquish: I can see no reason why we
should abandon the house to thieves and vandals. 2 depart from,
leave, desert, quit, go away from: The order was given to
abandon ship. 3 desert, forsake, jilt, walk out on: He even
abandoned his fianc‚e. 4 give up, renounce; discontinue, forgo,
drop, desist, abstain from: She abandoned cigarettes and whisky
after the doctor's warning.
--n. 5 recklessness, intemperance, wantonness, lack of
restraint, unrestraint: He behaved with wild abandon after he
received the inheritance.
abandoned adj. 1 left alone, forlorn, forsaken, deserted, neglected;
rejected, shunned, cast off or aside, jilted, dropped, outcast:
An abandoned infant was found on the church steps. Totally
alone, she felt abandoned by her friends. 2 bad, immoral,
amoral, wicked, sinful, evil, corrupt, unprincipled,
unrestrained, uninhibited, reprobate; loose, wanton, debauched,
wild, dissolute, dissipated, profligate; depraved, lewd,
lascivious, flagitious: His abandoned behaviour soon landed him
in jail.
abbreviate
v. 1 shorten, compress, contract, truncate, trim, reduce,
curtail: We abbreviated some of the longer words to save space.
2 shorten, cut, condense, abridge, abstract, digest, epitomize,
summarize, US synopsize: The school presented an abbreviated
version of A Midsummer Night's Dream.
abbreviated
adj. skimpy, brief, revealing: The dancers' abbreviated
costumes shocked some members of the audience.
abbreviation
n. initialism; acronym; shortening, contraction: UK is one
kind of abbreviation, or initialism; NATO, which is pronounced
as a word, is another, usually called an acronym.
abdicate v. give up, renounce, disclaim, waive, disown, surrender,
yield, relinquish, abandon, resign, quit: He abdicated all
responsibility for care of the children. She abdicated the
throne to marry a commoner.
abduct v. kidnap, carry off, make away or off with, seize, Slang US
snatch, grab: The child that was abducted is safe.
abet v. 1 encourage, urge, instigate, incite, provoke, egg on, prod,
goad; aid, help, assist: The jury found that his wife had
abetted him in the murder. 2 countenance, approve (of),
support, endorse, second, sanction, condone; further, advance,
promote, uphold: By failing to inform on the terrorists, the
neighbours abetted the bombing.
abeyance n. in abeyance. pending, abeyant, reserved, in reserve,
shelved, pushed or shoved or shunted aside, postponed, put off,
suspended, US tabled; temporarily inactive, dormant; latent;
Colloq in a holding pattern, on the back burner; Slang on hold,
in the deep-freeze, on the shelf, on ice, hanging fire: Legal
proceedings were held in abeyance so that talks could take place
to reach an out-of-court settlement.
abhor v. hate, loathe, detest, abominate, execrate; regard or view
with horror or dread or fright or repugnance or loathing or
disgust, shudder at, recoil or shrink from; be or stand aghast
at: He said that he abhorred any violation of human rights.
abhorrent adj. hateful, detestable, abhorred, abominable, contemptible,
odious, loathsome, horrid, heinous, execrable, repugnant;
repulsive, repellent, revolting, offensive, disgusting,
horrifying, obnoxious: The idea of war was totally abhorrent to
her.
и т.д.
Нужно сделать что бы было так:
abhorrent|hateful|detestable и т.д.
т.е. убрать из текста все числа, удалить все словечки типа adj. v. и т.п.
Удалить все примеры (начинаются или с : или с . заканчиваются .).
Вот мои наброски:
Код:
open(TXT,"file.txt");
open(ST,">result.txt");
@all=<TXT>;
close(TXT);
$string=join($string,@all);
$string=~s/v\.|adj\.|n\.//ig;
$string=~s/\d//ig;
$string=~s/,|;/|/ig;
$string=~s/:[^\.]+\.//g;
$string=~s/\.(.*)\.//g;
@new=$string;
foreach (@new){
$_=~s/ {2,}/|/g; #Удаление пробелов
$_=~s/ //g; #Удаление пробелов
$_ .= "\n"; #Установка символа переноса строки
print ST $_; #Запись в файл
}
close(ST);
Но работает хреновенько  . Кто действительно поможет, получит небольшое денежное вознагрождение и + !
Всем спасибо заранее
Последний раз редактировалось $p01nt; 24.11.2008 в 18:43..
|
|
|

24.11.2008, 22:32
|
|
Участник форума
Регистрация: 04.05.2006
Сообщений: 161
Провел на форуме: 389768
Репутация:
158
|
|
Обязательно на Perl?
Могу на PHP написать.
|
|
|

24.11.2008, 23:14
|
|
Участник форума
Регистрация: 19.02.2008
Сообщений: 186
Провел на форуме: 584540
Репутация:
96
|
|
Solker, сори, обязательно на Perl
|
|
|

25.11.2008, 09:11
|
|
Познавший АНТИЧАТ
Регистрация: 27.04.2007
Сообщений: 1,044
Провел на форуме: 3660186
Репутация:
905
|
|
$p01nt, попробуй вот этот код.
Код:
#!/usr/bin/perl
use strict;
use warnings;
open my $F, '<', '05.txt';
my $text = join '', <$F>;
$text =~ s/\n{2}/\$\$\$/g;
$text =~ s/\n/ /g;
$text =~ s/:[^\.]+\./\,/g;
$text =~ s/\d+//g;
$text =~ s/[\,\;]/\|/g;
$text =~ s/\s(v|n|adj|pron|num|adv|prep|conj)\.\s/\|/g;
$text =~ s/\|\s+/\|/g;
$text =~ s/\$\$\$/\n/g;
$text =~ s/\s*\|\s*$//g;
print $text, "\n";
Но код имеет ограничения. Первое - если идет подряд несколько примеров, то вырезается только первый (регулярка s/  [^\.]+\.)+/\,/g не помогла). Второе - надо в строке
Код:
$text =~ s/\s(v|n|adj|pron|num|adv|prep|conj)\.\s/\|/g;
перечислить все части речи, встречающиеся в файле. Третье - строка
--n. 5 recklessness, intemperance, wantonnes
видимо съехала с родного места, такие надо поднимать к соответствующему слову на родину.
ЗЫ. Больше моск уже не работает =/
Последний раз редактировалось krypt3r; 25.11.2008 в 09:14..
|
|
|

25.11.2008, 11:01
|
|
Участник форума
Регистрация: 19.02.2008
Сообщений: 186
Провел на форуме: 584540
Репутация:
96
|
|
Опять я с тупыми вопросами  Теперь у мну не работает парсер.
Код:
#Обьявление необходимых модулей
use warnings;
use LWP 5.64;
use encoding "cp1251";
#Создаем "броузер" и обьявляем переменные
$urlWnews='http://www.kinopoisk.ru/level/2/page/';
$newsview='http://www.kinopoisk.ru/level/2/news/';
$numbOnpage=5;
$parsWpage=2;
$browser = LWP::UserAgent->new;
$browser->agent('Mozilla/4.76 [en] (Win98; U)');
#Узнаем номер новостей на каждой странице
$sr=1;$i=0;
while($parsWpage > $sr){
$urlWnews="http://www.kinopoisk.ru/level/2/page/" . "$sr";
print "Parsim $urlWnews\n";
while($numbOnpage > $i) {
$response=$browser->get($urlWnews) or die ("DIE!");
$response=$response->as_string;
@ms=$response=~m/<a href="\/level\/2\/news\/(.*)\/" class="continue">/ig;
print $ms[$i] . "\n";
$i++;
}
$i=0;
$sr++;
}
#Самый чоткий момент, вытаскиваем новости! #Помочь тут :))
$i=0;$max=$#ms;
while($max > $i){
$newsview .= $ms[$i];
$response=$browser->get($newsview) or die ("DIE!");
$response=$response->as_string;
@titl=$response=~m/<title>(.*)<\/title>/ig;
$titl[$i] .= '.txt';
@text=$response=~m/<tr><td style="padding-top:10px;padding-bottom:20px" colspan=2 class="news">[^\.]<td><\/tr>/ig; # ВОт тут не получается
open(FF,">$titl[$i]");
print FF $text;
close(FF);
}
Cобственно говоря все до парсинга самой новости работает. А вот с последним проблемы, помогите плз!
Последний раз редактировалось $p01nt; 25.11.2008 в 15:32..
|
|
|
|
|
Здесь присутствуют: 1 (пользователей: 0 , гостей: 1)
|
|
|
|