Các báo cáo chính

Một phần của tài liệu Về một mô hình CSDL quan hệ với thông tin không chắc chắn dạng ngôn ngữ gần tự nhiên (Trang 71)

1. 4.1 Những phát biểu cơ bản

3.7.2. Các báo cáo chính

3.7.2.1 Báo cáo thống kê nhân viên theo tuổi và bậc lương

Chương trình cho phép liệt kê danh sách nhân viên có tuổi và bậc lương thỏa mãn một điều kiện nào đó, chẳng hạn: Tuổi = Young và Bậc lương = High. Những chức năng như thế này cho phép phân tích lực lượng nhân sự của công ty theo một số nguyên tắc phục vụ cho việc hoạch định chiến lược nhân sự.

KẾT LUẬN

Cho đến nay việc nghiên cứu CSDL với thông tin mờ, không chắc chắn chủ yếu dựa trên cách tiếp cận của lý thuyết tập mờ và lý thuyết khả năng. Luận văn đã chỉ ra rằng ĐSGT cho ta một cách tiếp cận mới đến việc biểu diễn ngữ nghĩa của các khái niệm mờ, nó quan tâm nghiên cứu các mối quan hệ ngữ nghĩa và như vậy nó chứa đựng các thông tin ngữ nghĩa ở mức tổng thể, mức hệ thống hơn. Vì vậy, mặc dù các khoảng mờ biểu thị lân cận về độ tương tự có vẻ giống như cách tiếp cận dựa trên giá trị khoảng, nhưng các lân cận trong cách tiếp cận ĐSGT không được phép tùy tiện mà chúng được hoàn toàn xác định dựa trên các tham số độ đo tính mờ của ngôn ngữ. Nhờ các khoảng lân cận như vậy và nhờ ánh xạ định lượng với tham số là độ đo tính mờ của ngôn ngữ, các giá trị ngôn ngữ có giá trị thực trong miền tham chiếu làm đại diện cùng với hệ lân cận ngữ nghĩa nó cho phép chúng ta chuyển các thao tác dữ liệu trong CSDL ngôn ngữ về các thao tác dữ liệu kinh điển làm cho việc tổ chức thao tác trở nên đơn giản và gần gũi hơn so với các cách tiếp cận khác.

Luận văn đã phân tích ngữ nghĩa của các phép toán trên mô hình mới, đồng thời xây dựng một số khái niệm cũng như định nghĩa về quan hệ mờ. Các tính chất, các bổ đề và định lý được chứng minh cụ thể. Vấn đề phụ thuộc tương tự trong CSDL ngôn ngữ cũng được đề cập. Một ứng dụng thực tế cũng được phát triển nhằm minh chứng cho những thế mạnh của phương pháp tiếp cận thông tin mờ bằng đại số gia tử.

TÀI LIỆU THAM KHẢO

A. TÀI LIỆU THAM KHẢO TIẾNG VIỆT

[1] Hồ Thuần, Hồ Cẩm Hà, Đại số quan hệ và quan điểm sử dụng Null value trên một mô hình cơ sở dữ liệu mờ, Tạp chí tin học và điều khiển học, T17 S4(2001),1- 10.

[2] Nguyễn Công Hào, Các phép toán quan hệ và phụ thuộc hàm mờ dựa trên số mờ hình thang, Tạp chí khoa học Đại học Huế, Số 20 (2003), 33-38.

[3] Nguyễn Cát Hồ, Trần Thái Sơn, Về khoảng cách giữa các giá trị của biến ngôn ngữ trong đại số gia tử, Tạp chí tin học và điều khiển học, T11 S1 (1995), 10-20. [4] Trần Đình Khang, Xây dựng hàm đo trên đại số gia tử và ứng dụng trong lập luận ngôn ngữ, Tạp chí tin học và điều khiển học, T13 S1 (1997), 16-30.

[5] Trần Đình Khang, Tích hợp các đại số gia tử cho suy luận ngôn ngữ, Tạp chí tin học và điều khiển học, T13 S3 (1997), 63-80.

B. TÀI LIỆU THAM KHẢO TIẾNG ANH

[6] T.K. Bhattacharjee and A.K. Mazumdar, Axiomatisation of fuzzy multivalued dependencies in fuzzy relational data model, Fuzzy sets and systems 96 (1998) 343-352

[7] D.A. Chiang, L.R. Chow and N.C. Hsien, Fuzzy information in extended fuzzy relational databases, Fuzzy sets ans systems 92 (1997) 1-20

[8] N. C. Ho, A model of relational databases with linguistic data of hedge algebras - based semantics, Hội thảo quốc gia lần thứ ba về “Nghiên cứu phát triển và ứng dụng CNTT và Truyền thông” ICT.rda’2006, 20-21/05/2006.

[9] N.C. Ho, Fuzziness in structure of linguistic truth values: a foundation for development of fuzzy reasoning. Proc. of Int. Symp. on Multiple-Valued Logic, May 26-28, 1987, Boston University, Boston, Massachusetts, IEEE Computer Society Press,1987, 325-335.

[10] N.C. Ho, Quantifying Hedge Algebras and Interpolation Methods in Approximate Reasoning, Proc. of the 5th Inter. Conf. on Fuzzy Information Processing, Beijing, March 1-4 (2003), p105-112.

[11] N. C. Ho, N. V. Long, Complete and linear hedge algebras, fuzziness measure of vague concepts and linguistic hedges and application, (Best paper Award of the Conference), AIP Conf. Proceed. on Computing Anticipatory Systems,

CASYS’05, Liege, Belgium 8-13 August 2005. ed. Daniel M. Dubois, 331-339. (Best paper Award of the Conference)

[12] N.C. Ho, N.V. Long, Fuzziness Measure on Complete Hedge Algebras and Quantitative Semantics of Terms in Linear Hedge Algebras, Fuzzy Sets and Systems 158 (2007) 452-471

[13] N.C. Ho, N. H. Chau, Quantitative semantics in hedge algebras and interpolation methods, Proc. of ICT , Hanoi (2003)

[14] N.C. Ho, H.V. Nam, Ordered Structure-Based Semantics of Linguistic Terms of Linguistic Variables and Approximate Reasoning, AIP Conf. Proceed. on Computing Anticipatory Systems, CASYS’99, 3th Inter. Conf., 98-116.

[15] N.C. Ho, H.V. Nam, A theory of refinement structure of hedge algebras and its application to linguistic-valued fuzzy logic. In D. Niwinski & M. Zawadowski (Eds), Logic, Algebra and Computer Science, Banach Center Publications Vol. 46 (PWN - Polish Scientific Publishers - 1999).

[16] N.C. Ho H.V. Nam, Towards an Algebraic Foundation for a Zadeh Fuzzy Logic, Fuzzy Set and System 129 (2002) 229-254.

[17] N.C. Ho, H.V. Nam, T.D Khang and L.H. Chau, Hedge Algebras, Linguistic- valued Logic and their Application to Fuzzy Reasoning, Inter.J. of Uncertainty, Fuzziness and Knowledge-Based System 7 (1999) 347-361.

[18] N.C. Ho and W. Wechler, Hedge algebras: An algebraic approach to structures of sets of linguistic domains of linguistic truth variable, Fuzzy Sets and Systems 35 (1990) 281-293

[19] N. Cat Ho and W. Wechler, Extended hedge algebras and their application to Fuzzy logic. Fuzzy Sets and Systems 52 (1992) 259-281

[20] N.C. Ho, Quantifying Hedge Algebras and Interpolation Methods in Approximate Reasoning, Proc. of the 5th Inter. Conf. on Fuzzy Information Processing, Beijing, March 1-4 (2003), 105-112.

[21] N.C. Ho, L.H. Chau, T.D. Khang and H.V. Nam, Hedge Algebras, Linguistic- valued Logic and their Application to Fuzzy Reasoning, International Journal of Uncertainty, Fuzziness and Knowledge-Based System 7 (1999) 347-361.

[22] S. Jyothi, M. Syam Babu, Multidependencies in fuzzy relational databases and lossless join decomposition, Fuzzy sets and systems 88 (1997) 315-332

[23] L. Di Lascio, A. Gisolfi and V. Loia, A New Model for Linguistic Modifiers, International Journal of Approximate Reasoning 15 (1996) 25-47

[24] L. Di Lascio and A. Gisolfi, Averaging Linguistic Truth Values in Fuzzy Approximate Reasoning, International Journal of Intelligent Systems 13 (1998) 301-318

[25] WeipYi Liu, A relational data model with fuzzy inheritance dependencies, Fuzzy sets ans systems 89 (1997) 205-213

[26] M. Umano and Freedom-O, A fuzzy database system, in: M.M. Gupta and E. Sanchez, Eds., Fuzzy Information and Decision Processes (North-Holland,

PHỤ LỤC

THỰC HIỆN CÀI ĐẶT MỘT SỐ THỦ TỤC

Các cấu trúc và hàm, thủ tục mô tả dưới đây được xây dựng trên môi trường Oracle. 1. Các cấu trúc dữ liệu

create table hedge_system_params (

hedge_system_param_id varchar2(50) primary key, hedge_system_param_value varchar2(200)

)

create table hedge_word_list (

hedge_word_id number(5) primary key, hedge_word_text varchar2(200)

)

create table hedge_algebra (

algebra_id number(5) primary key, algebra_name varchar2(50), positive_hedge_group_id number(5), negative_hedge_group_id number(5), w_value number(25,5) , real_max_value number(25,5), real_min_value number(25,5), maximum_level number(3), round_cut_function varchar2(20), qsf_precision number(5), CASE_SENSITIVE varchar2(1)

)

create table hedge_groups (

hedge_group_id number(5) primary key, hedge_group_number number(5), -- group

hedge_word_id number(5), -- foreign key to hedge_word_id of hedge_word_list hedge_sign number(1), -- -1: negative, +1: positive, specifying the hedge belongs to which group, H+ or H-

hedge_fuzziness number(25,5),

hedge_order_sequence number(5) - 0: generator )

create table hedge_relations (

hedge_relation_id number(5),

hedge_row_id number(5), -- foreign key to hedge_word_id of hedge_word_list hedge_column_id number(5), -- foreign key to hedge_word_id hedge_word_list hedge_relation number(1) -- -1: negative, +1: positive

)

create table hedge_master (

hedge_master_id number(5) primary key, hedge_algebra_id number(5),

hedge_master_text varchar2(2000), hedge_master_qsf number(25,5),

hedge_master_mapped_value number(25,5) )

2. Các hàm và thủ tục:

Các hàm và thủ tục dưới đây được viết dưới dạng stored procedure để tiện cho việc sử dụng và tăng hiệu năng thực hiện.

-- Hàm xác định các tham số hệ thống

FUNCTION HA_SYSTEM_PARAM ( hedge_sys_param_id varchar2) RETURN varchar2 IS

param_tmp varchar2(200);

-- Declare program variables as shown above

BEGIN

select hedge_system_param_value into param_tmp from hedge_system_params

where hedge_system_param_id = hedge_sys_param_id; RETURN param_tmp;

EXCEPTION

WHEN no_data_found THEN return null ;

WHEN others THEN

raise_application_error(sqlcode, sqlerrm);

END; -- Function HEDGE_SYSTEM_PARA_VALUE

-- Hàm xác định các tham số của một ĐSGT

FUNCTION HA_HA_PARAMS ( ha_ha_id IN number,

max_level OUT number, w_val OUT NUMBER,

real_max_value OUT NUMBER, real_min_value OUT NUMBER,

alpha_val OUT NUMBER, beta_val OUT NUMBER, p_val OUT NUMBER,

round_cut_func OUT VARCHAR2, precision_val OUT NUMBER, case_sensitive OUT VARCHAR2)

RETURN number IS sql_part number;

BEGIN

sql_part := 1;

select maximum_level, w_value, real_max_value, real_min_value , round_cut_function, qsf_precision, case_sensitive

into max_level, w_val, real_max_value, real_min_value, round_cut_func, precision_val, case_sensitive

from hedge_algebra a where

a.algebra_id = HA_HA_ID;

sql_part := 2;

select count(hedge_sign) into p_val from hedge_algebra a, hedge_groups g where

a.algebra_id = HA_HA_ID

and a.negative_hedge_group_id = g.hedge_group_number and g.hedge_order_sequence <> 0

and g.hedge_sign = -1;

sql_part := 3;

select sum(g.hedge_fuzziness) into alpha_val from hedge_algebra a, hedge_groups g

where

a.algebra_id = HA_HA_ID

and a.negative_hedge_group_id = g.hedge_group_number and g.hedge_order_sequence <> 0

and g.hedge_sign = -1;

sql_part := 4;

select sum(g.hedge_fuzziness) into beta_val from hedge_algebra a, hedge_groups g where

a.algebra_id = HA_HA_ID

and a.positive_hedge_group_id = g.hedge_group_number and g.hedge_order_sequence <> 0

and g.hedge_sign = 1;

RETURN 1;

EXCEPTION

WHEN no_data_found THEN

raise_application_error(-20007,'Undefined hedge algebra with ID# ' || HA_HA_ID);

END; -- Function HA_HA_PARAMS

-- Hàm xác định tên của gia tử dựa trên chỉ số gia tử

FUNCTION HA_HEDGE ( ha_ha_id IN number, hedge_index IN number,

case_sensitive IN VARCHAR2) RETURN varchar2 IS

hedge_word_text hedge_word_list.hedge_word_text%type; -- Declare program variables as shown above

BEGIN

select decode(case_sensitive, 'Y', w.hedge_word_text,

upper(w.hedge_word_text)) into hedge_word_text

from hedge_groups g, hedge_word_list w, hedge_algebra a where

g.hedge_order_sequence = hedge_index and g.hedge_word_id = w.hedge_word_id and a.algebra_id = HA_HA_ID

and (a.positive_hedge_group_id = g.hedge_group_number or a.negative_hedge_group_id = g.hedge_group_number);

RETURN hedge_word_text;

EXCEPTION

WHEN no_data_found THEN

raise_application_error(-20005,'Undefined hedge at sequence# ' || hedge_index );

-- Hàm xác định số lượng từ của một chuỗi

FUNCTION HA_WORD_COUNT

( stringexp IN VARCHAR2, wordseparator IN VARCHAR2) RETURN NUMBER IS

--variable_name datatype;

-- Declare program variables as shown above

BEGIN

RETURN (length(ltrim(rtrim(stringexp))) -

length(replace(ltrim(rtrim(stringexp)),

ha_system_param('WORD_SEPARATOR'))) + 1);

EXCEPTION

WHEN OTHERS THEN

raise_application_error(sqlcode, sqlerrm); return 0;

END; -- Function HA_WORD_COUNT

-- Hàm xác định độ mờ của một chuỗi x FUNCTION HA_FM ( ha_ha_id IN number, full_hedge_word IN VARCHAR2, case_sensitive IN VARCHAR2) RETURN number IS

-- Declare program variables as shown above fuzziness hedge_groups.hedge_fuzziness%type;

first_word hedge_word_list.hedge_word_text%type; remaining_word hedge_word_list.hedge_word_text%type; word_separator varchar2(2);

BEGIN

fuzziness := 1.0;

word_separator := ha_system_param('WORD_SEPARATOR'); remaining_word := full_hedge_word;

while (length(remaining_word) > 0) loop

first_word := ha_next_word(remaining_word, word_separator);

fuzziness := fuzziness * ha_fuzziness(ha_ha_id, first_word, case_sensitive); if instr(remaining_word, word_separator, 1) = 0 then

remaining_word := ''; else

remaining_word := substr(remaining_word, instr(remaining_word, word_separator, 1) + 1, length(remaining_word) - instr(remaining_word, word_separator, 1));

end if; end loop;

RETURN fuzziness;

END; -- Function HA_FM

-- Hàm xác định độ đo tính mờ của các gia tử và phần tử sinh của ĐSGT

FUNCTION HA_FUZZINESS ( HA_HA_ID IN number, hedge_word IN VARCHAR2, case_sensitive IN VARCHAR2) RETURN number IS

fuzziness hedge_groups.hedge_fuzziness%type; -- Declare program variables as shown above

BEGIN

select hedge_fuzziness into fuzziness

from hedge_groups g, hedge_word_list w, hedge_algebra a where g.hedge_word_id = w.hedge_word_id

and (

(case_sensitive = 'Y' and w.hedge_word_text = hedge_word) or

(case_sensitive = 'N' and upper(w.hedge_word_text) = upper(hedge_word))) and a.algebra_id = HA_HA_ID

and (a.positive_hedge_group_id = g.hedge_group_number or a.negative_hedge_group_id = g.hedge_group_number);

RETURN fuzziness;

EXCEPTION

WHEN no_data_found THEN

raise_application_error(-20005,'Undefined fuzziness for "' || hedge_word || '"');

END; -- Function HA_FUZZINESS

-- Hàm xác định phần tử sinh của một ĐSGT

FUNCTION HA_GENERATOR

(ha_id in number, generator_sign IN number, case_sensitive IN VARCHAR2)

RETURN VARCHAR2 IS

--

GENERATOR hedge_word_list.hedge_word_text%type; -- Declare program variables as shown above

BEGIN

select decode(case_sensitive, 'Y', w.hedge_word_text,

from hedge_word_list w, hedge_algebra a, hedge_groups g where

a.algebra_id = ha_id

and g.hedge_order_sequence = 0

and ((a.positive_hedge_group_id = g.hedge_group_number and generator_sign = 1)

or (a.negative_hedge_group_id = g.hedge_group_number and generator_sign = - 1))

and g.hedge_word_id = w.hedge_word_id;

RETURN GENERATOR;

exception

when no_data_found then

raise_application_error(-20001,'Undefined generator'); return '';

when others then

raise_application_error(sqlcode, sqlerrm); return '';

END; -- Function HA_GENERATOR

-- Hàm xác định nhóm của một gia tử (H+ hay H-)

FUNCTION HA_GROUP ( ha_ha_id IN number,

hedge_word IN VARCHAR2, case_sensitive IN VARCHAR2) RETURN number IS

hedge_sign hedge_groups.hedge_sign%type; -- Declare program variables as shown above

select hedge_sign into hedge_sign

from hedge_groups g, hedge_word_list w, hedge_algebra a where g.hedge_word_id = w.hedge_word_id

and

((case_sensitive = 'Y' and w.hedge_word_text = hedge_word) or

(case_sensitive = 'N' and upper(w.hedge_word_text) = upper(hedge_word))) and a.algebra_id = HA_HA_ID

and (a.positive_hedge_group_id = g.hedge_group_number or a.negative_hedge_group_id = g.hedge_group_number);

RETURN hedge_sign;

EXCEPTION

WHEN no_data_found THEN

raise_application_error(-20008,'Undefined hedge group for "' || hedge_word || '" (Upper="' ||case_sensitive || ')"' );

END; -- Function HA_GROUP

-- Hàm xác định ID của một ĐSGT theo chuỗi đầu vào (thuật ngữ)

FUNCTION HA_HA_ID (ha_expression in varchar2, case_sensitive IN VARCHAR2) RETURN number IS

hedge_algebra_id hedge_algebra.algebra_id%type;

--hedge_algebra_id number(10);

last_word varchar2(100);

BEGIN

last_word := ha_last_word(ha_expression);

from hedge_word_list w, hedge_algebra a, hedge_groups g where

((case_sensitive = 'Y' and w.hedge_word_text = last_word)

or (case_sensitive = 'N' and upper(w.hedge_word_text) = upper(last_word))) and w.hedge_word_id = g.hedge_word_id

and (a.positive_hedge_group_id = g.hedge_group_number or a.negative_hedge_group_id = g.hedge_group_number) and g.hedge_order_sequence = 0;

return hedge_algebra_id;

exception

when no_data_found then

raise_application_error(-20002,'Undefined hedge algebra for "' || last_word || '"' ); return -1;

when too_many_rows then

raise_application_error(-20002,'Ambigious hedge algebras for "' || last_word || '". Only one algebra with a generator is allowed.' );

return -1;

when others then

raise_application_error(sqlcode, sqlerrm); return -1; END; FUNCTION HA_HEDGE ( ha_ha_id IN number, hedge_index IN number, case_sensitive IN VARCHAR2) RETURN varchar2 IS

-- Declare program variables as shown above

BEGIN

select decode(case_sensitive, 'Y', w.hedge_word_text,

upper(w.hedge_word_text)) into hedge_word_text

from hedge_groups g, hedge_word_list w, hedge_algebra a where

g.hedge_order_sequence = hedge_index and g.hedge_word_id = w.hedge_word_id and a.algebra_id = HA_HA_ID

and (a.positive_hedge_group_id = g.hedge_group_number or a.negative_hedge_group_id = g.hedge_group_number);

RETURN hedge_word_text;

EXCEPTION

WHEN no_data_found THEN

raise_application_error(-20005,'Undefined hedge at sequence# ' || hedge_index );

END; -- Function HA_HEDGE

-- Hàm xác định thứ tự của một gia tử trong nhóm

FUNCTION HA_HEDGE_SEQUENCE ( ha_ha_id IN number,

hedge_word IN VARCHAR2, case_sensitive IN VARCHAR2) RETURN number IS

hedge_sequence hedge_groups.hedge_order_sequence%type; -- Declare program variables as shown above

BEGIN

select g.hedge_order_sequence into hedge_sequence

where g.hedge_word_id = w.hedge_word_id and

((case_sensitive = 'Y' and w.hedge_word_text = hedge_word) or

(case_sensitive = 'N' and upper(w.hedge_word_text) = upper(hedge_word))) and a.algebra_id = HA_HA_ID

and (a.positive_hedge_group_id = g.hedge_group_number or a.negative_hedge_group_id = g.hedge_group_number);

RETURN hedge_sequence;

EXCEPTION

WHEN no_data_found THEN

raise_application_error(-20006,'Undefined order sequence for "' || hedge_word || '"');

WHEN others THEN raise ;

END; -- Function HA_HEDGE_SEQUENCE

-- Hàm xác định dấu của gia tử

FUNCTION HA_HEDGE_SIGN(ha_algebra_id in number, ha_hedge_word in varchar2, case_sensitive IN VARCHAR2) RETURN number IS

--hedge_algebra_id hedge_algebra.algebra_id%type;

hedge_sign hedge_groups.hedge_sign%type;

--last_word varchar2(100);

BEGIN

select g.hedge_sign into hedge_sign

from hedge_word_list w, hedge_algebra a, hedge_groups g where

((case_sensitive = 'Y' and w.hedge_word_text = ha_hedge_word) or

(case_sensitive = 'N' and upper(w.hedge_word_text) = upper(ha_hedge_word))) and w.hedge_word_id = g.hedge_word_id

and a.algebra_id = ha_algebra_id

and (a.positive_hedge_group_id = g.hedge_group_number or a.negative_hedge_group_id = g.hedge_group_number) and g.hedge_order_sequence <> 0;

return hedge_sign;

exception

when no_data_found then

raise_application_error(-20002,'Undefined hedge "' || ha_hedge_word || '"' ); return -1;

when others then

raise_application_error(sqlcode, sqlerrm); return -1;

END;

-- Hàm xác định từ cuối cùng

FUNCTION HA_LAST_WORD

( ha_expression IN varchar2) RETURN varchar2 IS word_separator varchar2(200);

BEGIN

word_separator := ha_system_param('WORD_SEPARATOR');

return substr(ha_expression, instr(ha_expression, word_separator, -1)+ 1,

length(ha_expression));

EXCEPTION

return '';

END; -- Function HA_LAST_WORD

-- Hàm xác định từ tiếp theo FUNCTION HA_NEXT_WORD ( instring IN varchar2, word_separator In Varchar2) RETURN varchar2 IS -- next_string varchar2(200); post number(10); BEGIN

post := instr(instring, word_separator, 1) - 1; if post <= 0 then

post := length(instring); end if;

RETURN substr(instring, 1, post);

END; -- Function HA_NEXT_WORD

-- Hàm xác định mối quan hệ giữa hai gia tử : +1: Dương tính, -1: Âm tính

FUNCTION HA_RELATION (hedge1 IN varchar2, hedge2 IN varchar2, case_sensitive IN VARCHAR2) RETURN number IS -- --- --- --- hedge_relation_sign number(1);

BEGIN

-- if hedge2 is a generator

-- then relation can be obtained from hedge group

select hedge_relation into hedge_relation_sign

from hedge_relations r, hedge_word_list w1, hedge_word_list w2 where

((case_sensitive = 'Y' and w1.hedge_word_text = hedge1) or

(case_sensitive = 'N' and upper(w1.hedge_word_text) = upper(hedge1)))

and

((case_sensitive = 'Y' and w2.hedge_word_text = hedge2) or

(case_sensitive = 'N' and upper(w2.hedge_word_text) = upper(hedge2)))

and r.hedge_row_id = w1.hedge_word_id and r.hedge_column_id = w2.hedge_word_id;

RETURN hedge_relation_sign;

EXCEPTION

WHEN no_data_found THEN

raise_application_error(-20003,'Undefined relation for "' || hedge1 || '" and "'|| hedge2 || '". Case sensitive=' || case_sensitive);

return 0;

-- Hàm xác định dấu của chuỗi thuật ngữ

FUNCTION HA_SIGN(ha_expression in varchar2, previous_ha_expression in varchar2,

ha_max_level in number, case_sensitive in varchar2) RETURN number IS

ha_tmp hedge_master.hedge_master_text%type; last_word varchar2(50);

first_word hedge_word_list.hedge_word_text%type; second_word hedge_word_list.hedge_word_text%type; remaining_word hedge_word_list.hedge_word_text%type; ha_id hedge_algebra.algebra_id%type;

word_count number(10);

positive_generator hedge_word_list.hedge_word_text%type; negative_generator hedge_word_list.hedge_word_text%type; no_such_hedge_word EXCEPTION; relation_sign number(1); word_separator varchar2(2); BEGIN ha_tmp := ha_expression; word_separator := ha_system_param('WORD_SEPARATOR'); last_word := HA_LAST_WORD(ha_tmp);

word_count := HA_WORD_COUNT(ha_tmp, word_separator);

if word_count > ha_max_level then return (0);

--relation_sign := 1;

ha_id := HA_HA_ID(ha_tmp, case_sensitive);

negative_generator := ha_generator(ha_id, -1, case_sensitive); -- Gets negative generator

positive_generator := ha_generator(ha_id, 1, case_sensitive); -- Gets positive generator

if (word_count = 1) then begin

if (last_word = negative_generator) then return (-1);

else begin

if (last_word = positive_generator) then return (1); end if; end; end if; raise no_such_hedge_word; end; end if;

remaining_word := substr(ha_tmp, instr(ha_tmp, word_separator, 1) + 1,

Một phần của tài liệu Về một mô hình CSDL quan hệ với thông tin không chắc chắn dạng ngôn ngữ gần tự nhiên (Trang 71)

Tải bản đầy đủ (PDF)

(105 trang)