текст статьи

------------------------------------------------------------------------
-- Actor Prolog, (c) 2003, IRE RAS Alexei A. Morozov                  --
------------------------------------------------------------------------
-- This program is an example of visual component-oriented            --
-- programming in Actor Prolog. The program consists only of an SADT  --
-- diagram in the IDL format. The source text components written in   --
-- Actor Prolog are connected to the program automatically in         --
-- accordance with the names of blocks of the SADT diagram and        --
-- the #package options included in the notes of the blocks of the    --
-- diagram. Actor Prolog translates the diagram into the logic        --
-- program and executes it.                                           --
------------------------------------------------------------------------

package "E:\\A_PROLOG\\EXAMPLES\\WEB\\COMPLEX":

import '_ENTER_REQUEST'
        from "E:\A_PROLOG\MOROZOV\WEB\ENGINES\REQUEST";
import '_CONVERT_MESSAGE_"SEARCH"_TO_"SHOW"_AND_"SEARCH"'
        from "E:\A_PROLOG\MOROZOV\LINKS\MANIFOLD";
import '_BROWSE_LIST'
        from "E:\A_PROLOG\MOROZOV\WEB\BROWSING\LIST";
import '_CONTROL_ENGINE'
        from "E:\A_PROLOG\MOROZOV\WEB\ENGINES\CONTROL";
import '_CONSULT_RAMBLER'
        from "E:\A_PROLOG\MOROZOV\WEB\ENGINES\RAMBLER";
import '_CONSULT_GOOGLE'
        from "E:\A_PROLOG\MOROZOV\WEB\ENGINES\GOOGLE";
import '_MERGE_TWO_LISTS'
        from "E:\A_PROLOG\MOROZOV\LINKS\MERGE";
import '_CHECK_RESOURCES'
        from "E:\A_PROLOG\MOROZOV\WEB\FILTERS\CHECK";
import '_FILTER_LIST'
        from "E:\A_PROLOG\MOROZOV\WEB\FILTERS\ENGINE";

project:

        (('MODEL',
                project_name = "Complex Search",
                creation_date = "26/7/2002",
                title = "Use Two Search Engines and "
                        "Preliminary Filtering",
                language_version = "1.2.8"))

------------------------------------------------------------------------
class 'MODEL' specializing 'ALPHA':
box = (('DIAGRAM-ROOT',
        model = model,
        container = self));
model = self;
project_name = "Complex Search";
[
]
------------------------------------------------------------------------
class 'DIAGRAM-ROOT' specializing 'A-0':
box_0 = (('DIAGRAM-A0',
        container = self,
        model = model));
status = "PUBLICATION";
revision_date = "27/7/2002";
creation_date = "27/7/2002";
author = "Alexei A. Morozov";
title = "A-0";
name = "A-0";
number = 'root';
model;
x = 7.0;
y = 22.0;
container;
con = ('REPORT',
        title = "A-0",
        x = x,
        y = y,
        width = 37,
        height = 9);
[
]
------------------------------------------------------------------------
class 'A-0' specializing 'COMPOUND_BLOCK':
box_0;
title;
name;
number;
model;
x;
y;
container;
con;
[
]
------------------------------------------------------------------------
class 'DIAGRAM-A0'
specializing 'USE_TWO_SEARCH_ENGINES_AND_PRELIMINARY_FILTERING':
variable:
        link_1;
        link_2;
        link_3;
        link_4;
        link_5;
constant:
        box_1 = (('DIAGRAM-A1',
                constant:
                        container = self,
                        model = model,
                        entry_o1 = ('ARROW',
                                constant:
                                        host = self,
                                        entry = "1o1",
                                variable:
                                        value = link_5),
                variable:
                        value_o1 = link_5,
                constant:
                        entry_o2 = ('ARROW',
                                constant:
                                        host = self,
                                        entry = "1o2",
                                variable:
                                        value = link_3),
                variable:
                        value_o2 = link_3));
        box_2 = (('DIAGRAM-A2',
                constant:
                        container = self,
                        model = model,
                        entry_i1 = ('ARROW',
                                constant:
                                        host = self,
                                        entry = "2i1",
                                variable:
                                        value = link_5),
                variable:
                        value_i1 = link_5,
                constant:
                        entry_o1 = ('ARROW',
                                constant:
                                        host = self,
                                        entry = "2o1",
                                variable:
                                        value = link_1),
                variable:
                        value_o1 = link_1,
                constant:
                        entry_o2 = ('ARROW',
                                constant:
                                        host = self,
                                        entry = "2o2",
                                variable:
                                        value = link_4),
                variable:
                        value_o2 = link_4));
        box_3 = (('DIAGRAM-A3',
                constant:
                        container = self,
                        model = model,
                        entry_i2 = ('ARROW',
                                constant:
                                        host = self,
                                        entry = "3i2",
                                variable:
                                        value = link_3),
                variable:
                        value_i2 = link_3,
                constant:
                        entry_i1 = ('ARROW',
                                constant:
                                        host = self,
                                        entry = "3i1",
                                variable:
                                        value = link_4),
                variable:
                        value_i1 = link_4,
                constant:
                        entry_o1 = ('ARROW',
                                constant:
                                        host = self,
                                        entry = "3o1",
                                variable:
                                        value = link_2),
                variable:
                        value_o1 = link_2));
        box_4 = (('DIAGRAM-A4',
                constant:
                        container = self,
                        model = model,
                        entry_c1 = ('ARROW',
                                constant:
                                        host = self,
                                        entry = "4c1",
                                variable:
                                        value = link_1),
                variable:
                        value_c1 = link_1,
                constant:
                        entry_i1 = ('ARROW',
                                constant:
                                        host = self,
                                        entry = "4i1",
                                variable:
                                        value = link_2),
                variable:
                        value_i1 = link_2));
        status = "PUBLICATION";
        revision_date = "27/7/2002";
        creation_date = "27/7/2002";
        author = "Alexei A. Morozov";
        title = "A0: Use Two Search Engines and Preliminary Filtering";
        name = "Use Two Search Engines and Preliminary Filtering";
        number = 0;
        model;
        x = 25.64498;
        y = 14.82936;
        container;
        con = ('REPORT',
                title = "A0: USE_TWO_SEARCH_ENGINES_AND_"
                        "PRELIMINARY_FILTERING",
                x = x,
                y = y,
                width = 37,
                height = 9);
[
component(box_1).
component(box_2).
component(box_3).
component(box_4):-!.
"1o1"{|REST}:-!,
        box_2 << "i1"{|REST}.
"2i1"{|REST}:-!,
        box_1 << "o1"{|REST}.
"1o2"{|REST}:-!,
        box_3 << "i2"{|REST}.
"3i2"{|REST}:-!,
        box_1 << "o2"{|REST}.
"2o1"{|REST}:-!,
        box_4 << "c1"{|REST}.
"4c1"{|REST}:-!,
        box_2 << "o1"{|REST}.
"2o2"{|REST}:-!,
        box_3 << "i1"{|REST}.
"3i1"{|REST}:-!,
        box_2 << "o2"{|REST}.
"3o1"{|REST}:-!,
        box_4 << "i1"{|REST}.
"4i1"{|REST}:-!,
        box_3 << "o1"{|REST}.
P("1o1",REST*):-!,
        box_2 << P("i1",REST*).
P("2i1",REST*):-!,
        box_1 << P("o1",REST*).
P("1o2",REST*):-!,
        box_3 << P("i2",REST*).
P("3i2",REST*):-!,
        box_1 << P("o2",REST*).
P("2o1",REST*):-!,
        box_4 << P("c1",REST*).
P("4c1",REST*):-!,
        box_2 << P("o1",REST*).
P("2o2",REST*):-!,
        box_3 << P("i1",REST*).
P("3i1",REST*):-!,
        box_2 << P("o2",REST*).
P("3o1",REST*):-!,
        box_4 << P("i1",REST*).
P("4i1",REST*):-!,
        box_3 << P("o1",REST*).
]
------------------------------------------------------------------------
class 'USE_TWO_SEARCH_ENGINES_AND_PRELIMINARY_FILTERING'
specializing 'COMPOUND_BLOCK':
box_1;
box_2;
box_3;
box_4;
title;
name;
number;
model;
x;
y;
container;
con;
[
]
------------------------------------------------------------------------
class 'DIAGRAM-A3' specializing 'COLLECT_DATA':
constant:
        entry_i1;
variable:
        value_i1;
constant:
        entry_i2;
variable:
        value_i2;
constant:
        entry_o1;
variable:
        value_o1;
        link_1;
        link_2;
        link_3;
        link_4;
        link_5;
constant:
        box_1 = (('DIAGRAM-A31',
                constant:
                        container = self,
                        model = model,
                        entry_o1 = ('ARROW',
                                constant:
                                        host = self,
                                        entry = "1o1",
                                variable:
                                        value = link_5),
                variable:
                        value_o1 = link_5));
        box_2 = (('DIAGRAM-A32',
                constant:
                        container = self,
                        model = model,
                        entry_i1 = ('ARROW',
                                constant:
                                        host = self,
                                        entry = "2i1",
                                variable:
                                        value = value_i1),
                variable:
                        value_i1 = value_i1,
                constant:
                        entry_c1 = ('ARROW',
                                constant:
                                        host = self,
                                        entry = "2c1",
                                variable:
                                        value = link_5),
                variable:
                        value_c1 = link_5,
                constant:
                        entry_o1 = ('ARROW',
                                constant:
                                        host = self,
                                        entry = "2o1",
                                variable:
                                        value = link_3),
                variable:
                        value_o1 = link_3));
        box_3 = (('DIAGRAM-A33',
                constant:
                        container = self,
                        model = model,
                        entry_c1 = ('ARROW',
                                constant:
                                        host = self,
                                        entry = "3c1",
                                variable:
                                        value = link_5),
                variable:
                        value_c1 = link_5,
                constant:
                        entry_i1 = ('ARROW',
                                constant:
                                        host = self,
                                        entry = "3i1",
                                variable:
                                        value = value_i1),
                variable:
                        value_i1 = value_i1,
                constant:
                        entry_o1 = ('ARROW',
                                constant:
                                        host = self,
                                        entry = "3o1",
                                variable:
                                        value = link_4),
                variable:
                        value_o1 = link_4));
        box_4 = (('DIAGRAM-A34',
                constant:
                        container = self,
                        model = model,
                        entry_i1 = ('ARROW',
                                constant:
                                        host = self,
                                        entry = "4i1",
                                variable:
                                        value = link_3),
                variable:
                        value_i1 = link_3,
                constant:
                        entry_i2 = ('ARROW',
                                constant:
                                        host = self,
                                        entry = "4i2",
                                variable:
                                        value = link_4),
                variable:
                        value_i2 = link_4,
                constant:
                        entry_o1 = ('ARROW',
                                constant:
                                        host = self,
                                        entry = "4o1",
                                variable:
                                        value = link_1),
                variable:
                        value_o1 = link_1));
        box_5 = (('DIAGRAM-A35',
                constant:
                        container = self,
                        model = model,
                        entry_i1 = ('ARROW',
                                constant:
                                        host = self,
                                        entry = "5i1",
                                variable:
                                        value = value_i2),
                variable:
                        value_i1 = value_i2,
                constant:
                        entry_o1 = ('ARROW',
                                constant:
                                        host = self,
                                        entry = "5o1",
                                variable:
                                        value = link_2),
                variable:
                        value_o1 = link_2));
        box_6 = (('DIAGRAM-A36',
                constant:
                        container = self,
                        model = model,
                        entry_i1 = ('ARROW',
                                constant:
                                        host = self,
                                        entry = "6i1",
                                variable:
                                        value = link_1),
                variable:
                        value_i1 = link_1,
                constant:
                        entry_m1 = ('ARROW',
                                constant:
                                        host = self,
                                        entry = "6m1",
                                variable:
                                        value = link_2),
                variable:
                        value_m1 = link_2,
                constant:
                        entry_o1 = ('ARROW',
                                constant:
                                        host = self,
                                        entry = "6o1",
                                variable:
                                        value = value_o1),
                variable:
                        value_o1 = value_o1));
        status = "PUBLICATION";
        revision_date = "28/7/2002";
        creation_date = "27/7/2002";
        title = "A3: Collect Data";
        name = "Collect Data";
        number = 3;
        model;
        x = 44.16574;
        y = 17.1708;
        container;
        con = ('REPORT',
                title = "A3: COLLECT_DATA",
                x = x,
                y = y,
                width = 37,
                height = 9);
[
component(box_1).
component(box_2).
component(box_3).
component(box_4).
component(box_5).
component(box_6):-!.
"5i1"{|REST}:-!,
        entry_i2 ? 'message'{|REST}.
"1o1"{|REST}:-!,
        box_3 << "c1"{|REST},
        box_2 << "c1"{|REST}.
"2o1"{|REST}:-!,
        box_4 << "i1"{|REST}.
"4i1"{|REST}:-!,
        box_2 << "o1"{|REST}.
"4o1"{|REST}:-!,
        box_6 << "i1"{|REST}.
"6i1"{|REST}:-!,
        box_4 << "o1"{|REST}.
"3o1"{|REST}:-!,
        box_4 << "i2"{|REST}.
"4i2"{|REST}:-!,
        box_3 << "o1"{|REST}.
"6o1"{|REST}:-!,
        entry_o1 ? 'message'{|REST}.
"5o1"{|REST}:-!,
        box_6 << "m1"{|REST}.
"6m1"{|REST}:-!,
        box_5 << "o1"{|REST}.
"3c1"{|REST}:-!,
        box_1 << "o1"{|REST}.
"2i1"{|REST}:-!,
        entry_i1 ? 'message'{|REST}.
"3i1"{|REST}:-!,
        entry_i1 ? 'message'{|REST}.
"2c1"{|REST}:-!,
        box_1 << "o1"{|REST}.
"i1"{|REST}:-!,
        box_2 << "i1"{|REST},
        box_3 << "i1"{|REST}.
"i2"{|REST}:-!,
        box_5 << "i1"{|REST}.
"o1"{|REST}:-!,
        box_6 << "o1"{|REST}.
P("5i1",REST*):-!,
        entry_i2 ? P(REST*).
P("1o1",REST*):-!,
        box_3 << P("c1",REST*),
        box_2 << P("c1",REST*).
P("2o1",REST*):-!,
        box_4 << P("i1",REST*).
P("4i1",REST*):-!,
        box_2 << P("o1",REST*).
P("4o1",REST*):-!,
        box_6 << P("i1",REST*).
P("6i1",REST*):-!,
        box_4 << P("o1",REST*).
P("3o1",REST*):-!,
        box_4 << P("i2",REST*).
P("4i2",REST*):-!,
        box_3 << P("o1",REST*).
P("6o1",REST*):-!,
        entry_o1 ? P(REST*).
P("5o1",REST*):-!,
        box_6 << P("m1",REST*).
P("6m1",REST*):-!,
        box_5 << P("o1",REST*).
P("3c1",REST*):-!,
        box_1 << P("o1",REST*).
P("2i1",REST*):-!,
        entry_i1 ? P(REST*).
P("3i1",REST*):-!,
        entry_i1 ? P(REST*).
P("2c1",REST*):-!,
        box_1 << P("o1",REST*).
P("i1",REST*):-!,
        box_2 << P("i1",REST*),
        box_3 << P("i1",REST*).
P("i2",REST*):-!,
        box_5 << P("i1",REST*).
P("o1",REST*):-!,
        box_6 << P("o1",REST*).
]
------------------------------------------------------------------------
class 'COLLECT_DATA' specializing 'COMPOUND_BLOCK':
constant:
        entry_i1;
variable:
        value_i1;
constant:
        entry_i2;
variable:
        value_i2;
constant:
        entry_o1;
variable:
        value_o1;
constant:
        box_1;
        box_2;
        box_3;
        box_4;
        box_5;
        box_6;
        title;
        name;
        number;
        model;
        x;
        y;
        container;
        con;
[
]
------------------------------------------------------------------------
class 'DIAGRAM-A1' specializing '_ENTER_REQUEST':
constant:
        entry_o1;
protecting:
        value_o1;
constant:
        entry_o2;
protecting:
        value_o2;
constant:
        title = "A1: Enter Request";
        name = "Enter Request";
        number = 1;
        model;
        x = 2.49324;
        y = 7.02432;
        container;
        con = ('REPORT',
                title = "A1: ENTER_REQUEST",
                x = x,
                y = y,
                width = 37,
                height = 9);
[
]
------------------------------------------------------------------------
class 'DIAGRAM-A2'
specializing '_CONVERT_MESSAGE_"SEARCH"_TO_"SHOW"_AND_"SEARCH"':
constant:
        entry_i1;
variable:
        value_i1;
constant:
        entry_o1;
protecting:
        value_o1;
constant:
        entry_o2;
protecting:
        value_o2;
constant:
        title = "A2: Convert Message \"Search\" to "
                "\"Show\" and \"Search\"";
        name = "Convert Message \"Search\" to \"Show\" and \"Search\"";
        number = 2;
        model;
        x = 22.43916;
        y = 11.12184;
        container;
        con = ('REPORT',
                title = "A2: CONVERT_MESSAGE_\"SEARCH\"_TO_"
                        "\"SHOW\"_AND_\"SEARCH\"",
                x = x,
                y = y,
                width = 37,
                height = 9);
[
]
------------------------------------------------------------------------
class 'DIAGRAM-A4' specializing '_BROWSE_LIST':
constant:
        entry_c1;
variable:
        value_c1;
constant:
        entry_i1;
variable:
        value_i1;
constant:
        title = "A4: Browse List";
        name = "Browse List";
        number = 4;
        model;
        x = 62.68729;
        y = 21.65856;
        container;
        con = ('REPORT',
                title = "A4: BROWSE_LIST",
                x = x,
                y = y,
                width = 37,
                height = 9);
[
]
------------------------------------------------------------------------
class 'DIAGRAM-A31' specializing '_CONTROL_ENGINE':
constant:
        entry_o1;
protecting:
        value_o1;
constant:
        title = "A31: Control Engine";
        name = "Control Engine";
        number = 1;
        model;
        x = 5.34277;
        y = 4.878;
        container;
        con = ('REPORT',
                title = "A31: CONTROL_ENGINE",
                x = x,
                y = y,
                width = 37,
                height = 9);
[
]
------------------------------------------------------------------------
class 'DIAGRAM-A32' specializing '_CONSULT_RAMBLER':
constant:
        entry_i1;
variable:
        value_i1;
constant:
        entry_c1;
variable:
        value_c1;
constant:
        entry_o1;
protecting:
        value_o1;
constant:
        title = "A32: Consult Rambler";
        name = "Consult Rambler";
        number = 2;
        model;
        x = 18.16526;
        y = 9.56088;
        container;
        con = ('REPORT',
                title = "A32: CONSULT_RAMBLER",
                x = x,
                y = y,
                width = 37,
                height = 9);
[
]
------------------------------------------------------------------------
class 'DIAGRAM-A33' specializing '_CONSULT_GOOGLE':
constant:
        entry_c1;
variable:
        value_c1;
constant:
        entry_i1;
variable:
        value_i1;
constant:
        entry_o1;
protecting:
        value_o1;
constant:
        title = "A33: Consult Google";
        name = "Consult Google";
        number = 3;
        model;
        x = 26.00127;
        y = 15.60984;
        container;
        con = ('REPORT',
                title = "A33: CONSULT_GOOGLE",
                x = x,
                y = y,
                width = 37,
                height = 9);
[
]
------------------------------------------------------------------------
class 'DIAGRAM-A34' specializing '_MERGE_TWO_LISTS':
constant:
        entry_i1;
variable:
        value_i1;
constant:
        entry_i2;
variable:
        value_i2;
constant:
        entry_o1;
protecting:
        value_o1;
constant:
        title = "A34: Merge Two Lists";
        name = "Merge Two Lists";
        number = 4;
        model;
        x = 43.80945;
        y = 15.02448;
        container;
        con = ('REPORT',
                title = "A34: MERGE_TWO_LISTS",
                x = x,
                y = y,
                width = 37,
                height = 9);
[
]
------------------------------------------------------------------------
class 'DIAGRAM-A35' specializing '_CHECK_RESOURCES':
constant:
        entry_i1;
variable:
        value_i1;
constant:
        entry_o1;
protecting:
        value_o1;
constant:
        title = "A35: Check Resources";
        name = "Check Resources";
        number = 5;
        model;
        x = 50.93288;
        y = 21.0732;
        container;
        con = ('REPORT',
                title = "A35: CHECK_RESOURCES",
                x = x,
                y = y,
                width = 37,
                height = 9);
[
]
------------------------------------------------------------------------
class 'DIAGRAM-A36' specializing '_FILTER_LIST':
constant:
        entry_i1;
variable:
        value_i1;
constant:
        entry_m1;
variable:
        value_m1;
constant:
        entry_o1;
protecting:
        value_o1;
constant:
        title = "A36: Filter List";
        name = "Filter List";
        number = 6;
        model;
        x = 59.48147;
        y = 16.58544;
        container;
        con = ('REPORT',
                title = "A36: FILTER_LIST",
                x = x,
                y = y,
                width = 37,
                height = 9);
[
]
------------------------------------------------------------------------
class 'ARROW' specializing 'ALPHA':
constant:
        host;
        entry;
variable:
        value;
[
goal:-!.
'link'{|REST}:-!,
        value == REST.
'message'{|REST}:-!,
        host << {0:entry|REST}.
P(REST*):-
        host << P(entry,REST*).
]
------------------------------------------------------------------------
class 'COMPOUND_BLOCK' specializing 'ALPHA': []
------------------------------------------------------------------------
class 'DUMMY':
con = ('CONSOLE');
[
goal.
--
_{sender:NAME|_}:-
        con ? writeln("Syntax error: dummy link with ",NAME),
        fail.
]
------------------------------------------------------------------------

package "E:\\A_PROLOG\\MOROZOV\\WEB\\ENGINES\\REQUEST":

------------------------------------------------------------------------
class '_ENTER_REQUEST':
entry_o1;
value_o2;
world = ('REQUEST',
        engine = entry_o1,
        pattern = value_o2);
[
goal:-!.
--
show(_):-!,
        world ? show().
]
------------------------------------------------------------------------
class 'REQUEST' specializing 'DIALOG':
constant:
        identifier = "Request";
        title = "";
variable:
        keywords;
constant:
        engine = #;
variable:
        pattern;
constant:
        con = ('CONSOLE');
[
goal:-!,
        pattern == keywords.
--
action("start"):-
        check_keywords(keywords),!,
        engine <- search(keywords),
        hide.
action(_):-!.
--
check_keywords(""):-!,
        con ? warning("Please enter keywords!"),
        fail.
check_keywords(_):-!.
]
------------------------------------------------------------------------

package "E:\\A_PROLOG\\MOROZOV\\LINKS\\MANIFOLD":

------------------------------------------------------------------------
class '_CONVERT_MESSAGE_"SEARCH"_TO_"SHOW"_AND_"SEARCH"':
entry_i1;
entry_o1;
entry_o2;
[
goal:-!.
--
search(_,KEYWORDS):-
        entry_o2 << search(KEYWORDS),
        entry_o1 << show().
]
------------------------------------------------------------------------
class 'SEARCH_TO_SHOW_AND_SEARCH':
engine = #;
demonstrator = #;
con;
r1 = ('REPORT');
r2 = ('REPORT');
r3 = ('REPORT');
[
goal:-!.
--
search(KEYWORDS):-
        engine << search(KEYWORDS),
        demonstrator << show().
]
------------------------------------------------------------------------

package "E:\\A_PROLOG\\MOROZOV\\WEB\\BROWSING\\LIST":

------------------------------------------------------------------------
class '_BROWSE_LIST':
value_i1;
world = ('LIST',
        list_of_resources = value_i1);
[
goal:-!.
--
show(_*):-!,
        world ? show().
]
------------------------------------------------------------------------
class 'LIST' specializing 'DIALOG':
constant:
        identifier = "List";
variable:
        list_of_resources;
        parameters;
constant:
        browser = ('APPLICATION',
                constant:
                        location = auto(".html"),
                variable:
                        parameters = parameters,
                constant:
                        flag = 'maximized',
                        enable_multiple_instances = 'yes');
        check = ('CHECKITEM');
[
goal:-!.
--
action("show_resource"):-
        [list_of_resources],
        check ? check_item(list_of_resources,parameters),!,
        browser ? activate().
action(_):-!.
]
------------------------------------------------------------------------
class '_SELECTOR':
value_i1;
value_o1;
entry_o1;
world = ('SELECTOR',
        list_of_resources = value_i1,
        item = value_o1,
        handler = entry_o1);
[
goal:-!.
--
show(_*):-!,
        world ? show().
]
------------------------------------------------------------------------
class 'SELECTOR' specializing 'DIALOG':
identifier = "Selector";
list_of_resources;
item;
handler = #;
check = ('CHECKITEM');
[
goal:-!.
--
action("process_resource"):-
        [item],
        check ? check_item(list_of_resources,item),!,
        handler ? process(item),
        hide.
action(_):-!.
]
------------------------------------------------------------------------
class '_EDIT':
value_i1;
value_o1;
entry_o1;
world = ('EDIT',
        list_of_resources = value_i1,
        item = value_o1,
        handler = entry_o1);
[
goal:-!.
--
show(_*):-!,
        world ? show().
]
------------------------------------------------------------------------
class 'EDIT' specializing 'DIALOG':
identifier = "Editor";
list_of_resources;
item;
handler = #;
check = ('CHECKITEM');
con = ('CONSOLE');
[
goal:-!.
--
action("select_resource"):-
        FN == con ? input_file_name
                ("Select a file","*.htm*",["HTML Files","*.HTM*"]),!,
        put('item',FN).
action("process_resource"):-
        [item],
        check ? check_item(list_of_resources,item),!,
        handler ? process(item),
        hide.
action(_):-!.
]
------------------------------------------------------------------------
class 'CHECKITEM':
con = ('CONSOLE');
[
goal:-!.
--
check_item([],_):-!,
        con ? note("List is empty!"),
        fail.
check_item(_,#):-!,
        con ? note("Select an item, please!"),
        fail.
check_item(_,_):-!.
]
------------------------------------------------------------------------

package "E:\\A_PROLOG\\MOROZOV\\WEB\\ENGINES\\CONTROL":

------------------------------------------------------------------------
class '_CONTROL_ENGINE':
entry_o1;
value_o1;
world = ('CONTROLDIALOG',
        engine = entry_o1);
[
goal:-!.
--
show(_):-!,
        world ? show().
]
------------------------------------------------------------------------
class 'CONTROLDIALOG' specializing 'DIALOG':
constant:
        engine;
        identifier = "Control";
variable:
        limit_number_of_pages;
        max_page;
constant:
        switch = ('SWITCH',
                limit_number_of_pages = limit_number_of_pages,
                max_page = max_page,
                engine = engine);
        con = ('CONSOLE');
[
goal:-!,
        put('limit_number_of_pages','yes'),
        put('max_page',10).
--
set_engine_mode(COUNTPAGES,MAXPAGE):-!,
        put('limit_number_of_pages',COUNTPAGES),
        put('max_page',MAXPAGE).
]
------------------------------------------------------------------------
class 'SWITCH':
variable:
        limit_number_of_pages;
        max_page;
constant:
        engine;
[
goal:-!,
        check(limit_number_of_pages,max_page).
--
check(COUNTPAGES,MAXPAGE):-!,
        engine <- set_engine_mode(COUNTPAGES,MAXPAGE).
]
------------------------------------------------------------------------

package "E:\\A_PROLOG\\MOROZOV\\WEB\\ENGINES\\RAMBLER":

import 'ENGINE_SADT_INTERFACE' from "Morozov/Web/Engines/Core";
import 'SEARCHENGINE' from "Morozov/Web/Engines/Core";

------------------------------------------------------------------------
class '_CONSULT_RAMBLER' specializing 'ENGINE_SADT_INTERFACE':
world = ('RAMBLER');
[
]
------------------------------------------------------------------------
class 'RAMBLER' specializing 'SEARCHENGINE':
location = "http://search.rambler.ru";
max_waiting_time = 20.0;
tags = ["DL","DIV"];
text = ('TEXT');
[
prepare_request(WORDS1,REQUEST):-!,
        replace_spaces("+","%2B",WORDS1,WORDS2),
        replace_spaces("  "," ",WORDS2,WORDS3),
        replace_spaces(" ","+",WORDS3,WORDS4),
        check_keywords(WORDS4),
        REQUEST ==
                (("/cgi-bin/rambler_search?words=" + WORDS4)
                + "&where=1").
--
extract_reference_from_tree([block("DL",LIST)|_],R):-
        extract_reference_from_block(LIST,R).
extract_reference_from_tree([block("DL",LIST)|_],R):-
        extract_reference_from_tree(LIST,R).
extract_reference_from_tree([_|REST],R):-!,
        extract_reference_from_tree(REST,R).
--
extract_reference_from_block([ref(TEXT,_)|_],ADDRESS2):-
        P == text ? search(TEXT,"URL=HTTP:"),
        text ? split((P + 3),TEXT,_,ADDRESS1),
        refine_address(ADDRESS1,ADDRESS2).
extract_reference_from_block([ref(_,LIST)|_],R):-
        extract_reference_from_tree(LIST,R).
extract_reference_from_block([_|REST],R):-!,
        extract_reference_from_block(REST,R).
--
extract_address_of_next_page([block("DIV",[WORD1|LIST])|_],N,A):-
        string(WORD1),
        parse_list_of_page_numbers(LIST,N,A).
extract_address_of_next_page([_|REST],N,A):-!,
        extract_address_of_next_page(REST,N,A).
--
parse_list_of_page_numbers([ref(_,_),"|"|REST],N,A):-!,
        parse_list_of_page_numbers(REST,N,A).
parse_list_of_page_numbers([ITEM,"|",ref(A,[N|_])|_],N,A):-!,
        text ? convert_to_integer(ITEM),
        text ? convert_to_integer(N).
]
------------------------------------------------------------------------

package "E:\\A_PROLOG\\MOROZOV\\WEB\\ENGINES\\GOOGLE":

import 'ENGINE_SADT_INTERFACE' from "Morozov/Web/Engines/Core";
import 'SEARCHENGINE' from "Morozov/Web/Engines/Core";

------------------------------------------------------------------------
class '_CONSULT_GOOGLE' specializing 'ENGINE_SADT_INTERFACE':
world = ('GOOGLE');
[
]
------------------------------------------------------------------------
class 'GOOGLE' specializing 'SEARCHENGINE':
location = "http://www.google.com";
max_waiting_time = 20.0;
tags = ["DIV","P"];
text = ('TEXT');
[
prepare_request(WORDS1,REQUEST):-!,
        replace_spaces("+","%2B",WORDS1,WORDS2),
        replace_spaces("  "," ",WORDS2,WORDS3),
        replace_spaces(" ","+",WORDS3,WORDS4),
        check_keywords(WORDS4),
        REQUEST == (("/search?q=" + WORDS4) +
                        "&ie=windows-1251&hl=ru&"
                        "btnG=%CF%EE%E8%F1%EA+%E2+Google").
--
extract_reference_from_tree([block("DIV",LIST)|_],R):-
        extract_reference_from_block_div(LIST,R).
extract_reference_from_tree([_|REST],R):-!,
        extract_reference_from_tree(REST,R).
--
extract_reference_from_block_div([block("P",LIST)|_],R):-
        extract_reference_from_block_p(LIST,R).
extract_reference_from_block_div([_|REST],R):-
        extract_reference_from_block_div(REST,R).
--
extract_reference_from_block_p([ref(TEXT,_)|_],ADDRESS):-!,
        refine_address(TEXT,ADDRESS).
extract_reference_from_block_p([_|REST],R):-!,
        extract_reference_from_block_p(REST,R).
--
extract_address_of_next_page([block("DIV",LIST)|_],N,A):-
        parse_list_of_page_numbers(LIST,N,A),!.
extract_address_of_next_page([_|REST],N,A):-!,
        extract_address_of_next_page(REST,N,A).
--
parse_list_of_page_numbers([ITEM,ref(A,[ref(_,_),N|_])|_],N,A):-
        string(ITEM),
        string(N),
        text ? convert_to_integer(ITEM),
        text ? convert_to_integer(N),!.
parse_list_of_page_numbers([_|REST],N,A):-!,
        parse_list_of_page_numbers(REST,N,A).
]
------------------------------------------------------------------------

package "E:\\A_PROLOG\\MOROZOV\\LINKS\\MERGE":

------------------------------------------------------------------------
class '_MERGE_TWO_LISTS':
value_i1;
value_i2;
value_o1;
con;
[
goal:-!,
        con ? clear(),
        merge_lists(value_i1,value_i2,value_o1).
--
show(_*):-!,
        con ? show().
--
merge_lists([],LIST,LIST):-!.
merge_lists([ITEM|REST],LIST2,LIST3):-
        member(ITEM,LIST2),!,
        con ? writeln("Common element: ",ITEM),
        merge_lists(REST,LIST2,LIST3).
merge_lists([ITEM|REST],LIST2,[ITEM|LIST3]):-
        merge_lists(REST,LIST2,LIST3).
--
member(ITEM,[ITEM|_]):-!.
member(ITEM,[_|REST]):-!,
        member(ITEM,REST).
]
------------------------------------------------------------------------

package "E:\\A_PROLOG\\MOROZOV\\WEB\\FILTERS\\CHECK":

------------------------------------------------------------------------
class '_CHECK_RESOURCES':
value_i1;
value_o1;
world = ('CHECK_RESOURCES',
        search_pattern = value_i1);
[
goal:-!,
        value_o1 == self.
--
show(_*):-!,
        world ? show().
--
filter(SWITCH,LIST)
        = world ? filter(SWITCH,LIST).
]
------------------------------------------------------------------------
class 'CHECK_RESOURCES' specializing 'DIALOG':
constant:
        identifier = "Control";
variable:
        search_pattern;
constant:
        receptor = ('RECEPTOR',
                location = "",
                max_waiting_time = 12.0,
                revision_period = 'none',
                attempt_period = 'none');
        report = ('REPORT',
                x = 5,
                y = 5,
                width = 70,
                height = 20,
                title = "Preliminary Check of Files");
protecting:
        limit_of_length;
constant:
        text = ('TEXT');
        con = ('CONSOLE');
[
goal:-!,
        initiate_limit_of_length(limit_of_length),
        con ? writeln(limit_of_length).
--
initiate_limit_of_length(50000):-!.
initiate_limit_of_length(_):-!.
--
filter('no',#)
        = _
        :-
        !.
filter('no',_)
        = _
        :-
        !.
filter('yes',LIST)
        = URL
        :-
        !,
        [search_pattern],
        report ? clear(),
        report ? show(),
        check_resources(LIST,URL).
--
check_resources([URL|_],URL):-
        report ? writeln("I check the resource ",URL),
        PARAMETERS == receptor ? get_parameters(URL),
        select_resource(URL,PARAMETERS).
check_resources([_|REST],URL):-!,
        check_resources(REST,URL).
--
select_resource(URL,entry(_,_,_,_,SIZE)):-!,
        report ? write("The size of the file: "),
        write_size_of_file(SIZE),
        check_resource_if_posible(URL,SIZE).
select_resource(URL,ANSWER):-!,
        report ? writeln("This resource is not available now:"),
        report ? writeln(URL),
        report ? writeln("The answer of the server: ",ANSWER),
        report ? nl().
--
write_size_of_file(-1):-!,
        report ? writeln("unknown.").
write_size_of_file(SIZE):-!,
        report ? writeln(SIZE).
--
check_resource_if_posible(URL,SIZE):-
        [limit_of_length],
        SIZE <= limit_of_length,!,
        report ? writeln(
                "The size of the file is suitable for "
                "preliminary check."),
        TEXT == receptor ? get_text(URL),
        check_text(URL,TEXT).
check_resource_if_posible(URL,_):-!,
        report ? writeln("The file is too big for preliminary check."),
        report ? writeln("I have accepted resource ",URL),
        report ? nl().
--
check_text(URL,TEXT):-
        string(TEXT),
        text ? search(TEXT,search_pattern),!,
        report ? set_color('black','green'),
        report ? writeln(
                "The resource has passed "
                "the check successfully: ",URL),
        report ? set_color('black'),
        report ? writeln("I have accepted the resource ",URL),
        report ? nl().
check_text(URL,ANSWER):-
        string(ANSWER),!,
        report ? set_color('red'),
        report ? writeln("I have rejected the resource ",URL),
        report ? set_color('black'),
        report ? nl(),
        fail.
check_text(URL,ANSWER):-!,
        report ? set_color('blue'),
        report ? writeln("I have accepted the resource ",URL),
        report ? writeln("The answer of server: ",ANSWER),
        report ? set_color('black'),
        report ? nl().
]
------------------------------------------------------------------------

package "E:\\A_PROLOG\\MOROZOV\\WEB\\FILTERS\\ENGINE":

------------------------------------------------------------------------
class '_FILTER_LIST':
value_i1;
value_o1;
value_m1;
world = ('FILTER_LIST',
        input_list = value_i1,
        output_list = value_o1,
        check = value_m1);
[
goal:-!.
--
show(_*):-!,
        world ? show().
]
------------------------------------------------------------------------
class 'FILTER_LIST' specializing 'DIALOG':
constant:
        identifier = "Control";
variable:
        input_list;
        output_list;
        check;
        results = check ?? filter(switch,input_list);
        switch;
[
goal:-!,
        switch_mode(switch).
--
switch_mode('no'):-!,
        output_list == input_list.
switch_mode('yes'):-!,
        output_list == results.
]
------------------------------------------------------------------------

package "E:\\A_PROLOG\\MOROZOV\\WEB\\ENGINES\\CORE":

import 'CONTROLDIALOG' from "Morozov/Web/Engines/Control";

------------------------------------------------------------------------
class 'ENGINE_SADT_INTERFACE':
constant:
        entry_c1;
variable:
        value_o1;
constant:
        world;
variable:
        list_of_resources = world ?? get_resource();
[
goal:-!,
        value_o1 == list_of_resources.
--
show(_*):-!,
        world ? show().
--
search(_,KEYWORDS):-!,
        world ? search(KEYWORDS).
search(KEYWORDS):-!,
        world ? search(KEYWORDS).
--
set_engine_mode(_,COUNTPAGES,MAXPAGE):-!,
        world ? set_engine_mode(COUNTPAGES,MAXPAGE).
]
------------------------------------------------------------------------
class 'SEARCHENGINE' specializing 'ALPHA':
constant:
        control = (('CONTROLDIALOG',
                limit_number_of_pages = limit_number_of_pages,
                max_page = max_page,
                engine = self));
variable:
        limit_number_of_pages;
        max_page;
constant:
        receiver = ('RECEPTOR',
                location = location,
                max_waiting_time = max_waiting_time,
                revision_period = 'none',
                attempt_period = 'none',
                tags = tags);
variable:
        location;
        max_waiting_time = 20.0;
        tags;
constant:
        registry = ('DATABASE');
        engine_output = #;
        debug_output = #;
        text = ('TEXT');
[
goal:-!.
--
show(_*):-!,
        control <- show().
--
set_engine_mode(COUNTPAGES,MAXPAGE):-!,
        control <- set_engine_mode(COUNTPAGES,MAXPAGE).
--
search(WORDS1):-!,
        registry ? clear(),
        prepare_request(WORDS1,URL),
        self << inspect_page(1,URL).
--
replace_spaces(P,T,S1,S3):-
        S2 == text ? replace(S1,P,T),!,
        replace_spaces(P,T,S2,S3).
replace_spaces(_,_,S,S):-!.
--
check_keywords(""):-!,
        fail.
check_keywords("+"):-!,
        fail.
check_keywords(_):-!.
--
inspect_page('no_page',_):-!.
inspect_page(CURRENTPAGE,URL1):-
        check_number_of_page(CURRENTPAGE),!,
        debug_output ? writeln
                ("I inspect page ",CURRENTPAGE," at ",URL1),
        TREE == receiver ? get_trees(URL1),
        report_errors(TREE),
        search_useful_data(TREE,NEXTPAGE,URL2),
        self << inspect_page(NEXTPAGE,URL2).
inspect_page(_,_).
--
check_number_of_page(CURRENTPAGE):-
        limit_number_of_pages == 'yes',!,
        integer(CURRENTPAGE),
        CURRENTPAGE <= max_page.
check_number_of_page(_):-!.
--
report_errors([]):-!.
report_errors([_|_]):-!.
report_errors(TREE):-!,
        debug_output ? writeln("Unexpected answer: ",TREE).
--
search_useful_data(TREE,'no_page',_):-
        debug_output ? writeln("I search references..."),
        extract_reference_from_tree(TREE,REFERENCE),
        engine_output ? found_reference(REFERENCE),
        debug_output ? writeln("Address: ",REFERENCE),
        save_address(REFERENCE),
        fail.
search_useful_data(TREE,NEXTNUMBER,PA):-
        debug_output ? writeln
                ("I search the address of the next page..."),
        extract_address_of_next_page(TREE,PN,PA),
        string(PN),
        NEXTNUMBER == text ? convert_to_integer(PN),
        engine_output ? next_page(NEXTNUMBER,PA),
        debug_output ? writeln("The Address of the next page: ",PA).
search_useful_data(_,_,_):-!,
        debug_output ? writeln("This page was the last one!"),
        fail.
--
refine_address(ADDRESS,ADDRESS):-
        text ? search(ADDRESS,"HTTP://"),!.
refine_address(A1,A2):-
        A2 == text ? replace(A1,"HTTP:/","http://"),!.
refine_address(ADDRESS,ADDRESS):-!.
--
save_address(URL):-
        registry ? find(URL),!.
save_address(URL):-!,
        registry ? append(URL).
--
reset:-
        registry ? clear().
--
get_resource
        = URL
        :-
        registry ? find(URL).
]
------------------------------------------------------------------------

текст статьи