DETERMINING MEMBERSHIP FUNCTION VALUES TO OPTIMIZE RETRIEVAL IN A FUZZY RELATIONAL DATABASE Directed Research Report Directed By: Dr. Lorraine M. Parker Shweta Sanghi May 2005 Table of Contents Page No. 1. Introduction……………………………………………………………………………………................1 1.1. Overview of Fuzzy Relational Databases……………………………......................................2 1.2. Overview of Previous work……………………………………………...................................5 2. Machine Learning Methods to Adjust Weights………………………………………………………….8 3. Methods of Constructing Membership Function……………………………………………………….10 3.1. The Fuzzy Linguistic Approach to Fuzzy Set……………………………………………….10 3.2. Fuzzification………………………………………………………........................................11 3.3. Membership function determination…………………………………………………………12 4. Project Description…………………………………………………………….......................................15 4.1. Testing…..……………………………………………………………………………………15 4.2. Results………………………………………………………………………………………..19 4.3. Obstacles……………………………………………………………………………………..23 5. Future Work………………………………………………………………………………………….…24 References…………………………………………………………………………………….………...25 Appendix A. Stored Procedures………………………………………………………………………...27 Appendix B. Source Code………………………………………………………....................................37 Appendix C. Statistical Method to Construct Membership Weight for Images………………………..79 Appendix D. Instructions to install the Fuzzy Database Research on the Local Machine....................101 1. Introduction Computers have made tremendous progress in the past few decades. They are now decidedly superior to human beings in speed and preciseness of calculation. However, computers do not always satisfy users’ requirements. One reason for this dissatisfaction is the lack of vagueness or imprecision, which are remarkable characteristics of humans. Imprecision is always part of our thinking and reasoning. As an approach, fuzzy database systems, which are able to represent and manipulate imprecise information, have been presented. In these systems, imprecise information can be stored using fuzzy linguistic terms (e.g. young, big) which are frequently used in daily conversation. Although these words are ambiguous or uncertain, communities can agree on their meanings. This paper presents an overview of fuzzy relational database theory and analyzes the previous work on a particular fuzzy database implementation [1] designed to retrieve images using fuzzy constructs whose common-language descriptions were defined by the consensus of a particular user community. Further, this paper describes research aimed at determining the best way of setting the membership values via feedback from the community. The desire is to expand the functioning level of the current prototype in order to implement “smart” database retrieval. It is proposed to determine membership values using the Direct Rating method. This method of determining membership function values (described in section 3.3) is then compared with the original prototype to determine which method is better. 1 1.1 Overview of Fuzzy Relational Database Conventional relational database systems are based on crisp data, which is precise. Fuzzy relational databases extend the conventional relational database model to allow for representation of imprecise data. A fuzzy set is created to describe the linguistic variables in more detail. The linguistic variable “age,” for instance, may have overlapping categories (members) of “young,” “very young,” “middle age,” “old,” and “very old.” Once these categories or members are defined, the fuzzy set is obtained, and a membership function is then developed for each member in the set. Fuzzy logic and fuzzy sets were first introduced by Lotfi A. Zadeh [2]. Fuzzy sets were derived by generalizing the concept of set theory. Fuzzy sets can be thought of as an extension of classical sets. In a classical set (or crisp set), the objects in the set are called elements or members of the set. An element x belonging to a set A is defined as x A, an element that is not a member in A is noted as x A. A characteristic function or membership function A(x) is defined as an element in the universe U having a crisp value of 1 or 0. For every x U, 1 for x A, A x 0 for x A. This can also be expressed as A x 0,1 In crisp sets the membership function takes a value of 1or 0. For fuzzy sets, the membership function takes values in the interval [0, 1]. The range between 0 and 1 is referred to as the membership grade or degree of membership [5]. 2 A fuzzy set A is defined as: A x, A x | x A, A x 0,1 Where A(x) is a membership function belonging to the interval [0, 1]. Fuzzy set theory has equivalent operations to those of crisp set theory. It includes functions such as equality, union and intersection [1]. A Fuzzy Relational Database extends a normal relational database by adding fuzzy logic, fuzzy data and membership functions. Membership functions can be defined as the degree of the truthfulness of the proposition. For example, the predicate “John (X) is tall (A)” is represented by number in unit interval A(x). A(x) = 0.7 means that John is tall to the degree 0.7. It is different from probability. The use of relations is one method of adding fuzzy selection criteria to a query. The rows contain data that is interpreted according to the elements in them and their fuzziness. For instance, consider the following height table. Name Height John 6’0’’ Bill 5’0’’ Janice 4’0’’ Fred 5’8’’ Meri 5’6’’ The elements in the height column are crisp values because they give the exact height of the individual. A range query could be created to find people within a certain range of heights, but it would be more convenient to define the range as a relation: 3 SELECT NAME FROM HEIGHTS WHERE HEIGHT IS SHORT; If SHORT was defined equal to 5’0’’ in the database, only “Bill” would be selected since he is the only short person in the group. A query could also be formulated to include different sets of range, that is, people who are VERY SHORT or of MEDIUM height. One way of approaching this is to create a relation that defines SHORT and its relationship to the other heights. In effect, we are defining the membership function for the fuzzy attribute SHORT. Height Short Membership 4’00’’ 0.00 4’4’’ 0.10 4’8’’ 0.50 5’0’’ 1.00 5’6’’ 0.50 5’8’’ 0.10 6’0’’ 0.00 The query would then receive names from the list based on the threshold. For instance, if we set our threshold for SHORT to be 0.50 or greater, then the query would return both Bill and Meri. A querying language called SQLf [3] has been developed to support a wide range of fuzzy queries (i.e., fuzzy predicates are introduced into the language wherever possible) while also adhering to the conventions used in SQL. The basic principle of SQLf is the introduction of fuzziness into the SELECT-FROM-WHERE block of SQL. Fuzziness is introduced at two levels within the WHERE condition, both in the predicates themselves and in the way they are combined (in the “connectors like and, or, etc”). To illustrate, consider these relations: 4 Employee (Emp#, E-name, Salary, Job, Age, City, Dept#) and Department (Dept#, D-name, Manager, Budget, Location) The query “Find the best 5 employees from Chicago who are well-paid and who are working in a high budget department” may be expressed as: 1. SELECT E.Emp, E.Name 2. FROM Employee E,Department D 3. WHERE E.City=”Chicago” AND E.Salary=”well paid” AND D.Budget=”high” 4. AND E.Dept#=D.Dept# In the above select statement, fuzziness is introduced in the line number 3 by the use of words well and high. 1.2 Overview of previous work A fuzzy relational database [1], which uses a natural language querying system to retrieve images whose common-language descriptions are defined by the consensus of a particular user community, was previously developed. The architecture of this relational database system required two layers to process fuzzy queries. The first layer was a RDBMS architecture and the second layer was a user interface layer of stored procedures in SQL Server to process the fuzzy queries. To query the database, SQLf was used. The syntax to query the database was SELECT (attribute list) FROM (relation List) WHERE (fuzzy conditions) Fuzzy conditions are conditions which use fuzzy predicates such as EYE_COLOR = SLIGHTLY BLUE. For each image, each of the possible values of a fuzzy attribute and its 5 corresponding membership weights were listed in a tuple as shown in Table 1. The features used in the implementation were “eye color” and “face width”. For eye color, possible values were green, blue and brown. For face width, values were broad, average and narrow. A list of fuzzy modifiers and their synonyms was developed. The modifiers selected (to be used with either attribute) were “very”, “medium” and “slightly”. Each modifier was assigned a corresponding range on the (0, 1) membership interval as shown in Table 2. Thus, using the two tables, a query requesting people with “light blue eyes” would return all of the images with EYE_COLOR = BLUE and a membership value between 0.0 and 0.29. To illustrate, an image of a person with eyes that are predominantly green with just a hint of blue and no trace of brown could be represented in the database as shown in Table 1. IMAGE_ID EYE_COLOR WEIGHT (µ) 1 GREEN 0.8 1 BLUE 0.3 1 BROWN 0.0 Table 1: Using Membership Values (Weights) for Each Attribute Modifier Range_From Range_To Midpoint “Very” 0.75 1.0 0.87 “Medium” 0.30 0.74 .52 “Slightly” 0.29 .20 0.0 Table 2: Modifier Ranges and Midpoints 6 Random values between [0, 1] were assigned as weights or membership values to each attribute of every image when the program was initialized for each particular user community. Each modifier had a threshold value that was at the midpoint of the modifier’s range. Threshold value was designed to steady each attribute’s membership value within the modifier ranges so it accurately represented each community’s consensus. The users, after viewing the result of their query, provided the feedback as to whether the image met their criteria or they believed the image would be better defined using a stronger or a weaker modifier. According to the user’s response, the weight of the attribute was increased or decreased by 0.01. For example, after viewing the result of query EYE_COLOR = VERY BLUE, if the user decided that the image should be defined by a stronger modifier then the weight was adjusted towards the threshold for very blue but if the user decided that the image should be defined by a weaker modifier then the weight was decreased by 0.01. Thus, by adjusting the membership weight so that it was as deep in the range as possible (i.e., at the midpoint), the community opinion was strengthened with concurring feedback. This method of constructing membership value from the subjective information is denoted as the Random Method. The Fuzzy Relational Database was designed to have a natural query language interface where a user would enter a query such as, “List names of the persons with very brown eyes”. The natural query language interface parsed the user query into the actual query and the modifier/attribute pair. This data was stored into separate data files, which the fuzzy relational database took as input. It then created a fuzzy query, queried the database and produced the result. After getting user feedback, the membership weights were adjusted. This process went on until a community consensus was reached. 7 2. Machine Learning Methods to Adjust Weights The field of machine learning is concerned with the question of how to construct computer programs that automatically improve with experience. Machine learning is said to occur in a program that can modify some aspect of itself, often referred to as its state, so that on a subsequent execution with the same input, a different (hopefully better) output is produced. Machine Learning is defined as, “A computer program is said to learn from Experience E with respect to some class of tasks and performance measure P, if its performance at tasks in T, as measured by P, improves with experience E.”[4] Learning systems learn through use of some sort of feedback or evolution or reaction to its response of experience E. Broadly speaking machine learning can be divided into two types Supervised Learning: Supervised learning is where the learning algorithm is provided with a set of inputs for the algorithm along with the corresponding correct outputs, and learning involves the algorithm comparing its current actual output with the correct or target outputs, so that it knows what its error is, and modify things accordingly. For example, supervised learning is used in back propagation algorithm to train neural networks. Unsupervised learning: Unsupervised learning is where the system is not told the "right answer". It is not trained on pairs consisting of an input and the desired output. Unsupervised clustering algorithms can be used to train the system. The purpose of the current fuzzy database implementation is to retrieve images by using fuzzy queries whose common-language descriptions are defined by the consensus of a particular 8 user community. In everyday life, these language descriptions are subjective. A person may be described as having dark brown hair and a narrow face by one user and other user can describe that person differently. Therefore the terms like “dark brown” and “narrow” are not objective definitions but rather reflect a person’s (or a group’s) definition of those terms. These definitions depend on factors like culture and experience, and may change over time. Although it is difficult to design a system which satisfies each user’s perception of facial definitions, a consensus can be reached so that it satisfies most users of that community. Since learning is based on feedback provided by the user community and the system does not know the right answer, it is using unsupervised learning. According to the definition of machine learning, the system can defined as Task T: Retrieval of images according to the criteria defined Performance Measure P: Percent of community satisfaction Training Experience E: User feedback 9 3. Methods of Constructing Membership Function A membership function (MF) is a curve that defines how each point in the input space is mapped to a membership value (or degree of membership) between 0 and 1. The input space is sometimes referred to as the universe of discourse, a fancy name for a simple concept. Summary of Membership Functions Fuzzy sets describe vague concepts (fast runner, hot weather, weekend days). A fuzzy set admits the possibility of partial membership in it. (Friday is sort of a weekend day, the weather is rather hot). The degree an object belongs to a fuzzy set is denoted by a membership value between 0 and 1. (Friday is a weekend day to the degree 0.8). A membership function associated with a given fuzzy set maps an input value to its appropriate membership value. 3.1 The Fuzzy Linguistic Approach to Fuzzy Set The linguistic approach is Zadeh’s original idea [2]. It is based on two main concepts: the linguistic variable and the linguistic term. A linguistic variable represents a concept that is measurable in some way, either objectively or subjectively, like temperature or will. Linguistic variables are characteristics of an object or situation. Linguistic terms rate the characteristic denoted by one linguistic variable. A linguistic term is a fuzzy set, and the linguistic variable defines its domain. Every adequate representation of fuzzy sets involves the basic understanding of five related conceptual symbols: 10 the set of elements θєΘ, as in “image” from “group of images” the linguistic variable V, that is a label for one of the attributes of the elements θєΘ, as in “eye color” of “image”; the linguistic term A, which is an adjective or adverb describing the linguistic variable, which is a subjective measure of V, as in “blue” describing “eye color”; a referential set X С R, that is a measurable numerical interval, for the particular attribute V, as in “[0,100] blue” for “eye color”; a subjective numeric attribution µA(θ), of the membership value, i.e., the membership degree of the element θ, labeled by the linguistic variable V as described by A. 3.2 Fuzzification The first step in every fuzzy system consists of converting the inputs from the traditional crisp universe to the fuzzy universe. This step is known as fuzzification or fuzzy encoding, and identifies that there is an acceptance of uncertainty assigned to the input value. Every input value is associated with a linguistic variable. For each linguistic variable, it should be assigned a set of linguistic terms that subjectively describe the variable. Most of the time, linguistic terms are words that describe the magnitude of the linguistic variable, as “hot” and “large”, or how far they are from a goal value, as in “exact” or “far”. Each linguistic term is a fuzzy set and has its own membership function. It is expected that for a linguistic variable to be useful, the union of the support of the linguistic terms cover its entire domain. It is also expected that there some intersection between the support of linguistic terms that describe similar concepts. So, when talking about temperature, for instance, one would expect to see some values that will be, at the 11 same time, described as “cold” and “freezing”. Usually, adjacent linguistic terms have 10 to 50% superposition. Given all the fuzzy sets which correspond to each linguistic variable, fuzzification means to determine the membership value of each input value in each fuzzy set. 3.3 Membership Function Determination Mainly, there are six methods used in experiments with the aim of constructing membership functions [14]: Polling: do you agree that John is tall? (Yes/No) Direct rating (point estimation): classify John according to his tallness. In general, the question is: “How F is a?” Reverse Rating: identify the person who is tall to the degree 0.6? In general, identify a who is F to the degree µF (a). Interval Estimation (set valued statistics): give an interval in which you think the height of John lies. Membership function exemplification: What is the degree of belonging of John to the set of tall people? In general, “To what degree a is F?” Pairwise comparison: which person John or Joe, is taller (and by how much?) 1: Polling In polling one subscribes to the point of view that fuzziness arises from interpersonal disagreements. The question “Do you agree that a is F?” is asked to different individuals. The answers are polled and an average is taken to construct the membership function. Polling is also one of the natural ways of eliciting membership functions for the likelihood interpretation. 12 2: Direct Rating Direct rating seems to be the most straightforward way to come up with a membership function. This approach subscribes to the point of view that fuzziness arises from individual subjective vagueness. The subject is required to classify a with respect to F over and over again in time. The experiment has to be carefully designed so that it will be hard for the subject to remember past answers. The same question is asked to the same subject over and over again, and the membership is constructed using the assumption of probabilistic errors and by estimating a few key parameters as is usual for this type of construction. Chameau & Santamarina (1987a) use several subjects and aggregate their answers as opposed to asking a single subject same questions over and over. 3: Reverse Rating In this method, the subject is given a membership degree and then asked to identify the object for which that degree corresponds to the fuzzy term in question. This method can be used for individuals by repeating the same question for the same membership function as well as for a group of individuals. Once the subject’s (or subjects’) responses are recorded, the conditional distributions can be taken to be normally distributed and the unknown parameters (mean and variance) can be estimated as usual. This method also requires evaluations to be made on at least interval scales to determine membership function. 4: Interval Estimation The subject is asked to give an interval that describes the Fness of a. Let Ii be the setvalued observation (the interval) and mi the frequency with which Ii is observed. Then R = (Ii; mi) defines a random set. It means that mi population is defining the interval in which the fuzzy term lies. The rest of the population defines the different interval for the Fness of a. 13 5: Membership Exemplification The subject is asked to write the degree which is appropriate for “large”, “very large”, “small” on scale of 0 to 100. The same question is asked to the group of individuals. The results are analyzed to determine membership function. 6: Pairwise Comparison The subject is asked a question “which is a better example of a bird: an eagle or a pelican?”, and based on answer (say, an eagle is chosen) to that question, another question is asked: “How much more of a bird is an eagle than pelican?” Weights are then derived from the principal eigenvector of the square reciprocal matrix of pairwise comparison between all contributing attributes. In all of the elicitation methods, Chameau & Santamarina [15] obtain the membership functions based on averaging or aggregation of the responses from several assessors. In that sense they do not subscribe to the individualistic interpretation of fuzziness. Chameau & Santamarina justify this approach by assuming that fuzziness is a property of the phenomenon rather than a property attributed by the observer. All of the above described approaches are called manual methods of determining membership function because expert/experts are required to obtain membership function. All the manual approaches suffer from the deficiency that they rely on very subjective interpretation of words, the foibles of human experts and generally all the knowledge acquisition problems that are well documented [6] with knowledge based systems. 14 4. Project Description This research aims to determine the best way of setting the membership values using feedback from the community for the fuzzy relational database. The purpose of the fuzzy database implementation is to retrieve images by using fuzzy queries whose common-language descriptions are defined by the consensus of a particular user community. The fuzzy set, which is presentation of fuzzy attribute values of the images, is determined through membership function. How best to determine the membership function is the first question to answer? It is proposed to construct membership values by the Direct Rating method. This approach subscribes to the point of view that fuzziness arises from individual subjective vagueness. This method of constructing the membership function will then be compared with the present prototype which uses the random method as explained in section 1.2 to determine which method gives the most user satisfaction with minimum feedback from the community. 4.1. Testing The previous implementation was modified to alter the method of assigning the membership value, which was based on direct rating method, for the blue eye color attribute of each image. User feedback for both the prototypes was taken in two sessions, which were training and testing. The user interface of both the prototypes was altered to make it user friendly. The source code with changes can be referenced in Appendix B. In the direct rating method, random weights were not assigned to the blue eye color attribute of the images as was done in previous prototype [1]. In the training session, the question put to the community was “How blue are the eyes? and they responded using a simple indicator on a sliding scale. The left most bar on the sliding scale represented that the eyes were not blue 15 whereas the right most bar on the sliding scale represented that the eye were 100% blue. The training session was comprised of 21 people. The values given for blue eye color attribute were recorded into the database as shown in Figure 1. Frequency Distribution of Image ID 1 14 12 10 Frequency Image 1 Scores 0-29 30-74 75-100 0 1 0 0 25 1 0 0 33 0 1 0 39 0 1 0 44 0 1 0 46 0 1 0 52 0 1 0 53 0 1 0 54 0 1 0 62 0 1 0 65 0 1 0 69 0 1 0 70 0 1 0 71 0 1 0 74 0 1 0 75 0 0 1 86 0 0 1 93 0 0 1 99 0 0 1 100 0 0 1 100 0 0 1 2 13 6 8 6 4 2 0 0-29 30-74 75-100 Frequency Range Figure 1: Scores and Distribution for Image 1 The first column in Figure 1 represents the community’s view of the degree to which image 1 had blue eyes. Frequency distribution method was chosen to summarize the community feedback for each attribute in order to achieve maximum user satisfaction. A frequency distribution table was created that grouped scores into non overlapping intervals called frequency 16 ranges. The frequency ranges were chosen based on range values of the very (75-100), medium (30-74), slightly (0 -29) modifiers. The number of scores that fell into each frequency range was calculated. The counts, or frequencies, of scores were then listed in their respective frequency ranges. The base of the rectangles in the histogram corresponds to the frequency ranges, and height of each rectangle equals the number of scores in that range. The frequency histogram for each of the 40 images can be referenced in Appendix C. Based on Table 2; each image acquired the threshold membership value for the maximum frequency range. For example, 13 people out of 21 chose the medium blue eye color for the image 1, while 6 people out of 21 said that the image had very blue eyes. Therefore, the membership value of 0.52 was assigned to the blue eye color attribute of the image id 1. Weights were similarly assigned for each of the 40 images as shown in Figure 2. In the random method, random weights were assigned initially to the blue eye color attribute of the images. The training session which comprised of 21 people was conducted to learn membership weights. Based on the community feedback, membership weight of the blue eye color attribute of each image was adjusted as explained in section 1.2. 17 Figure 2: Membership Weights for Direct Rating Method A testing session was conducted to compare both methods of eliciting membership values and to determine which method gives the better community satisfaction. In the testing session, 18 the fuzzy relational database was queried for “slightly”, “medium” and “very” blue eye color of the images based on the membership value assigned by the random method and the direct rating method. The community was asked whether, they were satisfied with the result or not. The percentage of user satisfaction was calculated. The percentage of user satisfaction of random method and direct rating method can be referenced in Appendix C. The line graph in figure 3 represents the comparison of user satisfaction for 40 images. For example, for image id 1, user satisfaction was 89% for the direct rating method and 67% for the random method. % of User Satisfaction Comparison % User Satisfaction 120 100 80 60 Random Method Direct Rating Method 40 20 0 1 4 7 10 13 16 19 22 25 28 31 34 37 40 Image ID Figure 3: Comparison of Percentage of user satisfaction for all images 4.2 Results The proposed direct rating method was the better method to determine membership function values, compared to the random method. The reasons are: 19 The direct rating method is more efficient because it reaches consensus with fewer iterations. For example, the random method can assign 1.0 membership value initially to an image whose eyes are not blue. It would take at least 100 feedbacks to reach a weight of 0.0, provided each user’s perception is the same. It is based on maximum vote. The threshold value is assigned based on the maximum value of frequency distribution table. It achieved a higher user satisfaction in 80% cases compared to random method. It is efficient even for smaller communities. For random method to be efficient in all cases, the community should comprise of at least 100 people. The extreme case for random method will be when the random method assigns 1.0 membership value initially to an image whose eyes are not blue. It would take at least 100 feedbacks to assign 0.0 weights, provided each user’s perception is same. However, there were many factors that affected the results. The images were described by the community, not the database designers. Thus, it was expected that each user could describe the same images differently. Therefore a term like “very blue eye” is not objective but rather reflects a person’s definition of those terms. These definitions depend on factors like culture and experience, and may change over time. For those images that got less than 25% user satisfaction, the pictures were not very clear. It was very hard to make out the eye color. It would have been better if the focus of the image was more on eye. This was true for both methods. But in this real world, perfect pictures can not be guaranteed in such a system. 20 There were some images whose user satisfaction was between 35% and 70% for the direct rating method because the frequency distribution of the attribute for two ranges was very close. Although, the maximum user’s satisfaction range was picked, but over all satisfaction was low. For example see Figure 4. Nine users out of 21 said that the eyes were medium blue, and 10 out of 21 said that the eyes were slightly blue eye. The membership weight of 0.2 was assigned to the image to reach maximum satisfaction but testing revealed 44% of user satisfaction. 0 0 0 0 0 0 14 16 20 25 30 33 42 50 56 56 67 69 73 90 95 0-29 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 10 30-74 75-100 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 0 1 0 1 9 2 Frequency Distribution of Image ID 33 12 10 8 Frequency Image 33 Scores 6 4 2 0 0-29 30-74 75-100 Frequency Range Figure 4 It is suggested that frequency distribution should be recalculated by removing 0 score value of the attribute. For example in case of Figure 4, after removing 0 score, 4 out of 15 users said that the eyes were slightly blue eye, and 9 users out of 15 said that the eyes 21 were medium blue. The membership weight of 0.52 could be assigned to the image 33. This requires further testing. The community which trained the prototype and the tested the prototype was not same. 21 users trained the both prototypes. 27 users tested the direct rating method and 15 users tested the random method. The varied community may be the one reason for not reaching community’s consensus more than 80% for all images. There may be other reasons such as communities may never agree that often. This requires further testing. The community did not define the range of modifiers. It was defined by the database designer. One user can describe range between 25 and 35 as slightly and other user can describe the same range as medium. One strategy could be to designate certain user as “expert” whose opinions would be weighted more heavily than the rest of the group’s. The expert would define the range of modifiers and educate the rest of community about the range of modifiers. Other strategy could be learning the range of modifiers from the community feedback. This requires further investigation. The slightly modifier includes those images that have no blue eye color. The results would have improved by excluding images with no blue eye color. For example in Figure 4, only six people would have described the image as slightly, if 0 score is ignored. It is believed that if these factors were taken into account the direct rating method would reach higher satisfaction. But this requires more study. 22 4.3 Obstacles There were many obstacles that had to be overcome to conduct this research. The main obstacle was learning and installing Microsoft .Net and SQL Server. Installation of the previous prototype on the local machine caused lots of problems because of inadequate documentation. Instructions to install this application locally can be referenced in Appendix D. Problems like changes in the user interface to use a slide bar, making the user interface friendly to conduct experiments, finding a way to display all images were other challenges that took time. 23 5. Future Work The research raised some questions, which can be explored in future fuzzy relational database research. One suggested area is in using unsupervised machine learning techniques such as Least Mean Square algorithm or clustering techniques to adjust weights in order to reach maximum satisfaction. Different strategies can be used to train the system. One strategy could be to designate certain users as “experts” by community whose opinions would be weighted more heavily than the rest of the group’s. Rather than using random values, these experts would initially be shown the images and their descriptions would establish the initial membership values; the remaining users would then modify the weights from that point forward. Other strategy could be start learning by initializing weights with random values and learn until certain percentage of satisfaction reached, then stop learning and again start learning after certain period like after a month or year or after the level of dissatisfaction reaches a particular percentage. Another area of future interest could be improvements in user interface. Instead of showing whole image, the focus can be more on attribute in study. For example, while training images for eye color, if focus would have been on eyes then results may have been better. User interface should be improved to make it more users friendly. Another area of interest would be defining the range of modifiers. One strategy could be to designate certain user as “expert” whose opinions would be weighted more heavily than the rest of the group’s. The expert would define the range of modifiers and educate the rest of community about the range of modifiers. Other strategy could be learning the range of modifiers from the community feedback. Another area of future interest would be to find the best method to handle unclear pictures. 24 References [1] Joy,Karen and Dattatri, Smita ,” Implementing a Fuzzy Relational Database and Querying System With Community Defined Membership Values “, VCU Directed Research Report, November 2004. [2] Zadeh, L. A. (1965). “Fuzzy Sets.” Information and Control, 8, 338-353. [3] Bosc, P. & Pivert, O. (1995). ”SQLf: A Relational Database Language for Fuzzy Querying.” IEEE Transactions on Fuzzy Systems, 3, 1-17. [4] Mitchell, Tom M. “Introduction to Machine Learning” in Machine Learning (7th ed.), McGraw Hill Publishers, 2-5. [5] Turksen, I.B., Measurement of membership functions and their acquisition, Fuzzy Sets and Systems, 40:5--38, 1991. [6] Motoda, H., Mizoguchi, R., Boose, J. H., and Gaines, B. R., Knowledge Acquisition Tools, Methods, and Mediating Representations, Proceedings of the First Japanese Knowledge Acquisition for Knowledge-Based Systems Workshop: JKAW-90, Ohmsha, Japan. [7] Norwich, A.M. & Turksen, I.B., The construction of membership functions, Fuzzy Sets and Possibility Theory: Recent Developments. [8] Watanabe, N., Statistical Methods for Estimating Membership Functions, Japanese Journal of Fuzzy Theory and Systems, 5(4), 1979. [9] John, R. I., Fuzzy Inference Systems: Problems and Some Solutions, De Montfort University Computing Science Research, http://www.cse.dmu.ac.uk/%7Erij/newrep/newrep.html [10] Eminov, Mubariz, Querying a Database by Fuzzification of Attribute Values. [11] Wang, Li-Juan & Wang, Xi-Zhao & Ha, Ming-Hu & Yin-Shan, Mining the Weights of Similarity Measure Through Learning. 25 [12] Tashiro, H. & Ohki, N. & Yokoyama, T. & Matsushita, Y., Managing Subjective Information in Fuzzy Database Systems, 156 – 161. [13] Baklarz, George, Using Neural Nets to Optimize Retrieval in a Fuzzy Relational Database, 191 – 200. [14] Bilgic, Taner & Turksen, I.B, Measurement of membership functions: Theoretical and Empirical work, 17 – 21. [15] Chameau, J. L. & Santamarina, J. C. (1987a), Membership Part I: Comparing Methods of Measurement, 287-301. 26 Appendix A Stored Procedures A. Fetch_All_Images /* Database Research Spring 2005 Shweta Sanghi Fetch_All_Images, stored procedure, fetches all images from the database for training */ CREATE PROCEDURE [Fetch_All_Images] AS SET ANSI_NULLS ON exec('select * from Person P') GO B. Fetch_Data /* Database Research Spring 2005 Shweta Sanghi Fetch_Data, stored procedure, is used to fetch the data from the database based on old method of assigning weights. It interprets the fuzzy modifiers and translates them into SQL Queries for our database */ CREATE PROCEDURE [Fetch_Data] @query as varchar(10), @s1 as varchar(50), @s2 as varchar(50) AS SET ANSI_NULLS ON declare @f_query as varchar(500), @high as float,@low as float print @high if @s2 = 'Blue' or @s2='Green' or @s2='Brown' begin 27 select @high =high from Range where modifier=@s1 select @low= low from Range where modifier=@s1 print @s2 exec('select * from Person P,Color C where P.ID=C.ID and C.weight <= '+@high+' and C.weight >= '+@low+' and C.Color='+'"'+@s2+'"') end if @s2 = 'Broad' or @s2 = 'Average' or @s2='Narrow' begin select @high = high from Range where modifier=@s1 select @low =low from Range where modifier=@s1 exec('select * from Person P,Face F where P.ID=F.ID and F.weight >= '+@low+' and F.weight <= '+@high+' and F.Face='+'"'+@s2+'"') end GO C. Fetch_Direct_Data /* Database Research Spring 2005 Shweta Sanghi Fetch_Direct_Data, stored procedure, is used to fetch the data from the database based on direct rating method of assigning weights. It interprets the fuzzy modifiers and translates them into SQL Queries for our database */ CREATE PROCEDURE [Fetch_Direct_Data] @query as varchar(10), @s1 as varchar(50), @s2 as varchar(50) AS SET ANSI_NULLS ON declare @f_query as varchar(500), @high as float,@low as float print @high if @s2 = 'Blue' or @s2='Green' or @s2='Brown' 28 begin select @high =high from Range where modifier=@s1 select @low= low from Range where modifier=@s1 print @s2 exec('select * from Person P,ColorDirect C where P.ID=C.ID and C.weight <= '+@high+' and C.weight >= '+@low+' and C.Color='+'"'+@s2+'"') end if @s2 = 'Broad' or @s2 = 'Average' or @s2='Narrow' begin select @high = high from Range where modifier=@s1 select @low =low from Range where modifier=@s1 exec('select * from Person P,Face F where P.ID=F.ID and F.weight >= '+@low+' and F.weight F.Face='+'"'+@s2+'"') end GO <= '+@high+' and D. initialize_weights /* Database Research Spring 2005 Karen Joy and Smita Dattatri Updated by Shweta Sanghi This procedure is used to initialize the weights associated with the “Eye Color” and the “Face Width “ attributes. This procedures assigns a random weight to each of the entries in the “Color” and the “ Face” table. We have used a cursor that loops through each record in the “Face” and the “Color” table and assigns a random value to the corresponding weights in each row. This procedure is not invoked via the application .It is executed directly on the database to initialize the weights.*/ CREATE PROCEDURE [initialize_weights] as declare @id as int,@color as varchar(20),@face as varchar(20) DECLARE color_weight CURSOR for select ID,color from color OPEN color_weight FETCH NEXT FROM color_weight into @ID,@color 29 WHILE @@FETCH_STATUS = 0 BEGIN print 'ID' print @id print 'color' print @color update color set weight=rand() where ID=@id and color=@color FETCH NEXT FROM color_weight into @ID,@color END CLOSE color_weight DEALLOCATE color_weight DECLARE face_weight CURSOR for select ID,face from face OPEN face_weight FETCH NEXT FROM face_weight into @ID,@face WHILE @@FETCH_STATUS = 0 BEGIN print 'ID+Face' print @id print 'Face' print @face update Face set weight=rand() where ID=@id and Face=@face FETCH NEXT FROM face_weight into @ID,@face END CLOSE face_weight DEALLOCATE face_weight GO 30 E. Insert_Test_Data /* Database Research Spring 2005 Shweta Sanghi Insert_Test_Data, stored procedure, is used to insert the user’s satisfaction information direct rating method into Test table*/ CREATE PROCEDURE .[Insert_Test_Data] @ID as int, @ValueBlue as int, @TypeBlue as varchar(50) AS SET ANSI_NULLS ON if @TypeBlue = 'very' begin insert into Test (ID,VeryBlue) values(@ID,@ValueBlue) end else begin if @TypeBlue = 'medium' begin insert into Test (ID,MediumBlue) values(@ID,@ValueBlue) end else begin if @TypeBlue = 'less' begin insert into Test (ID,LessBlue) values(@ID,@ValueBlue) end end end GO 31 for F. Insert_TestOld_Data /* Database Research Spring 2005 Shweta Sanghi Insert_TestOld_Data, stored procedure, is used to insert the user’s satisfaction information for previous prototype method into TestOld table*/ CREATE PROCEDURE .[Insert_TestOld_Data] @ID as int, @ValueBlue as int, @TypeBlue as varchar(50) AS SET ANSI_NULLS ON if @TypeBlue = 'very' begin insert into TestOld (ID,VeryBlue) values(@ID,@ValueBlue) end else begin if @TypeBlue = 'medium' begin insert into TestOld (ID,MediumBlue) values(@ID,@ValueBlue) end else begin if @TypeBlue = 'less' begin insert into TestOld (ID,LessBlue) values(@ID,@ValueBlue) end end end GO 32 G. Insert_Train_Data /* Database Research Spring 2005 Shweta Sanghi Insert_Train_Data, stored procedure, is used to insert the user’s view for blue eye color of image.*/ CREATE PROCEDURE .[Insert_Train_Data] @ID as int, @TrainBlue as int AS SET ANSI_NULLS ON insert into Train (ID,TrainBlue) values(@ID,@TrainBlue) GO H. Update_Data /* Database Research Spring 2005 Karen Joy and Smita Dattatri Updated by Shweta Sanghi This procedure is used to fetch the data from the database. It interprets the fuzzy modifiers and translates them into SQL Queries for our database.*/ CREATE PROCEDURE [Update_Data] @ID as int, @color as varchar(50), @more_less as varchar(50), @modifier as varchar(50) AS SET ANSI_NULLS ON declare @threshold as float,@existing_weight as float,@new_weight as float if @color = 'Blue' or @color='Green' or @color='Brown' begin select @threshold =threshold from Range where modifier=@modifier select @existing_weight=Weight from Color where ID=@ID and Color=@color set @new_weight=@existing_weight 33 if @more_less = 'meets' begin if @existing_weight < @threshold begin set @new_weight = @existing_weight + .01 end if @existing_weight > @threshold begin set @new_weight = @existing_weight - .01 end end else begin if @more_less = 'more' begin if @modifier = 'very' begin if @existing_weight > @threshold begin set @new_weight = @existing_weight - .01 end if @existing_weight < @threshold begin set @new_weight = @existing_weight + .01 end end else begin set @new_weight = @existing_weight + .01 end end else begin if @modifier='slightly' begin if @existing_weight > @threshold begin set @new_weight = @existing_weight - .01 end if @existing_weight < @threshold begin set @new_weight = @existing_weight + .01 end end else 34 begin set @new_weight = @existing_weight - .01 end end end update Color set weight=@new_weight where ID=@ID and color=@color end if @color = 'Broad' or @color = 'Average' or @color='Narrow' begin select @threshold =threshold from Range where modifier=@modifier select @existing_weight=Weight from Face where ID=@ID and Face=@color set @new_weight=@existing_weight if @more_less = 'meets' begin if @existing_weight < @threshold begin set @new_weight = @existing_weight + .01 end if @existing_weight > @threshold begin set @new_weight = @existing_weight - .01 end end else begin if @more_less = 'more' begin if @modifier = 'very' begin if @existing_weight > @threshold begin set @new_weight = @existing_weight - .01 end if @existing_weight < @threshold begin set @new_weight = @existing_weight + .01 end end else begin set @new_weight = @existing_weight + .01 35 end end else begin if @modifier='slightly' begin if @existing_weight > @threshold begin set @new_weight = @existing_weight - .01 end if @existing_weight < @threshold begin set @new_weight = @existing_weight + .01 end end else begin set @new_weight = @existing_weight - .01 end end end update Face set weight=@new_weight where ID=@ID and Face=@color end GO 36 Appendix B Source Code Source Code for Direct Rating Method 'Database Research Spring 2005 'Shweta 'This form takes user id as input and invokes the stored procedure "Fetch_All_Images" 'which queries the database to retrieve all images with slide bar for user input. 'If the user presses the update button then user’s input is stored into the database 'by the stored procedure called “Insert_Train_Data”. Imports System.IO Imports System.Data.SqlClient Public Class learn Inherits System.Windows.Forms.Form #Region " Windows Form Designer generated code " Public Sub New() MyBase.New() 'This call is required by the Windows Form Designer. InitializeComponent() 'Add any initialization after the InitializeComponent() call End Sub 'Form overrides dispose to clean up the component list. Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing Then If Not (components Is Nothing) Then components.Dispose() End If End If MyBase.Dispose(disposing) End Sub 'Required by the Windows Form Designer Private components As System.ComponentModel.IContainer 'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. Friend WithEvents Label1 As System.Windows.Forms.Label Friend WithEvents Panel1 As System.Windows.Forms.Panel Friend WithEvents Button3 As System.Windows.Forms.Button 37 Friend WithEvents Button1 As System.Windows.Forms.Button Friend WithEvents Button2 As System.Windows.Forms.Button <System.Diagnostics.DebuggerStepThrough()> Private InitializeComponent() Me.Button3 = New System.Windows.Forms.Button Me.Label1 = New System.Windows.Forms.Label Me.Panel1 = New System.Windows.Forms.Panel Me.Button1 = New System.Windows.Forms.Button Me.Button2 = New System.Windows.Forms.Button Me.SuspendLayout() ' 'Button3 ' Me.Button3.Font = New System.Drawing.Font("Verdana", System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, Byte)) Me.Button3.Location = New System.Drawing.Point(560, 640) Me.Button3.Name = "Button3" Me.Button3.Size = New System.Drawing.Size(88, 23) Me.Button3.TabIndex = 0 Me.Button3.Text = " Cancel" ' 'Label1 ' Me.Label1.Font = New System.Drawing.Font("Verdana", System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, Byte)) Me.Label1.Location = New System.Drawing.Point(280, 0) Me.Label1.Name = "Label1" Me.Label1.Size = New System.Drawing.Size(616, 23) Me.Label1.TabIndex = 1 Me.Label1.Text = "Label1" ' 'Panel1 ' Me.Panel1.Location = New System.Drawing.Point(0, 32) Me.Panel1.Name = "Panel1" Me.Panel1.Size = New System.Drawing.Size(864, 600) Me.Panel1.TabIndex = 2 ' 'Button1 ' Me.Button1.Font = New System.Drawing.Font("Verdana", System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, Byte)) Me.Button1.Location = New System.Drawing.Point(176, 640) Me.Button1.Name = "Button1" Me.Button1.Size = New System.Drawing.Size(104, 23) Me.Button1.TabIndex = 3 Me.Button1.Text = "More" ' 'Button2 ' Me.Button2.Font = New System.Drawing.Font("Verdana", System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, Byte)) Me.Button2.Location = New System.Drawing.Point(352, 640) 38 Sub 9.75!, CType(0, 12.0!, CType(0, 9.75!, CType(0, 9.75!, CType(0, Me.Button2.Name = "Button2" Me.Button2.Size = New System.Drawing.Size(120, 23) Me.Button2.TabIndex = 4 Me.Button2.Text = "Update" ' 'learn ' Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13) Me.ClientSize = New System.Drawing.Size(872, 669) Me.Controls.Add(Me.Button2) Me.Controls.Add(Me.Button1) Me.Controls.Add(Me.Panel1) Me.Controls.Add(Me.Label1) Me.Controls.Add(Me.Button3) Me.Name = "learn" Me.Text = "Training Images " Me.ResumeLayout(False) End Sub #End Region 'user defined variables Dim User As New Integer 'variable storing user id Dim ds As New DataSet 'varibale storing dataset which is the result of the query Dim al As New ArrayList 'varibale storing image set which has image and slide bar Dim nextPix As Integer 'variable indicating the first picture to be displayed on a page Dim remainingPix As Integer 'variable indicating the remaining pictures to be displayed on a page 'Connection String used to connect to the database. 'vikas=Name Of the Computer 'DBResearch=Name of the database Dim con As New System.Data.SqlClient.SqlConnection("data source=vikas;initial catalog=DBResearch;user id=dbresearch;password=dbresearch") 'Procedure takes user id from main form and assigns to variable called User 'Public Sub initialize(ByVal s1 As Integer) ' User = s1 'End Sub*/ 'Event handling for cancel button. It closes the database connection and exit the project Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click con.Close() Me.Dispose() Me.Close() End End Sub ' This function is invoked when the form is loaded.The stored procedure "Fetch_All_Images" is 39 'invoked. This stored procedure executes the query and returns the result set Private Sub learn_Load(ByVal System.EventArgs) Handles MyBase.Load Dim I As Integer Dim Count As Integer sender As Object, ByVal e As 'Making connection to database and executes the stored procedure called "Fetch_All_Images" 'and put the dataset in da variable Dim cmd As New System.Data.SqlClient.SqlCommand("Fetch_All_Images", con) cmd.CommandType = CommandType.StoredProcedure Try Dim da As New System.Data.SqlClient.SqlDataAdapter(cmd) da.Fill(ds) Catch ex As Exception MessageBox.Show(ex.ToString) End Try 'displays the number of rows returned as a result of query (use for debugging) 'MessageBox.Show(ds.Tables(0).Rows().Count) 'This block executes the each dataset row, creates image set ' and displays on the form If (ds.Tables(0).Rows().Count) > 0 Then Count = ds.Tables(0).Compute("COUNT(ID)", "") 'The following block of code creates a new object of ImageSet for each 'record in the which result set which contains the image and the slide bar 'associated with it. It also reads the image in binary format from the database 'and displays it appropriately. For I = 0 To Count - 1 Dim S As New ImageSet Dim bits As Byte() = CType(ds.Tables(0).Rows(I).Item(2), Byte()) Dim memorybits As New MemoryStream(bits) Dim bitmap As New Bitmap(memorybits) S.picture.Image = bitmap al.Add(S) al(I).ID = ds.Tables(0).Rows(I).Item(0) Next I 'variable indicating the first picture to be displayed on a page nextPix = 0 'variable indicating the remaining pictures to be displayed remainingPix = al.Count 40 'The following block of code places the components on the Group Box and 'then places the group box on the panel to be displayed. placeComponents(nextPix) 'This procedure is evoked so that update button is disabled 'until form displays last page of the query. At the last page, more button is disabled updateButtons() 'label on the Panel. Label1.Text() = "Please Answer the following question." Else MessageBox.Show("No images match your criteria") End If End Sub 'The following block of code places the components on the Group Box and 'then places the group box on the panel to be displayed. Private Sub placeComponents(ByVal Position1 As Integer) Dim X As Integer, Y As Integer Y = 8 Dim I As Integer 'limit the display to 6 images Dim lastPix As Integer 'determing the last picture for the current page If remainingPix <= 6 Then lastPix = Position1 + remainingPix - 1 Else : lastPix = Position1 + 5 End If For I = Position1 To lastPix Dim G As New GroupBox G.Location() = New Point(8 + X, Y) G.Size() = New Size(268, 295) 'was (288,350) al(I).picture.Location = New Point(50, 24) al(I).picture.size = New Size(200, 200) 'was (224,120) al(I).label_response.location = New Point(50, 230) 'was (32, 250) al(I).label_response.size = New Size(176, 24) al(I).user_response.size = New Size(200, 24) al(I).user_response.location = New Point(50, 260) G.Controls.Add(al(I).picture) G.Controls.Add(al(I).user_response) G.Controls.Add(al(I).label_response) Panel1.Controls.Add(G) 'Allows to display multiple rows of records. X = 300 + X If ((I Mod 6) = 2) Then Y = 295 + 5 + Y 41 'was (32, 275) X = 0 End If Next 'update the number of picutes left to be displayed If remainingPix > 6 Then remainingPix = remainingPix - 6 Else remainingPix = 0 End If 'update first picture on next page nextPix = nextPix + 6 End Sub 'set up buttons depending on number of images in query result 'This procedure is evoked so that update button is disabled 'until form displays last page of the query. At the last page, more button is disabled Private Sub updateButtons() If al.Count <= 6 Or remainingPix = 0 Then Me.Button1.Enabled = False Me.Button2.Enabled = True Else Me.Button1.Enabled = True Me.Button2.Enabled = False End If End Sub '---------------------------------------------------------------'The class ImagesSet is a user defined class which has the image 'and the slide bar as its components. Public Class ImageSet Public picture As PictureBox Public user_response As HScrollBar Public label_response As Label Public ID As Integer Public Sub New() picture = New PictureBox user_response = New HScrollBar label_response = New Label label_response.Text = "How blue are the eyes?" label_response.Font = New System.Drawing.Font("Verdana", FontStyle.Bold) user_response.Minimum = 0 user_response.Maximum = 109 ID = 0 End Sub End Class 'Event Handling for More Button. It clears the panel, 'builds and displays next page 42 8, 'set up buttons depending on number of images in query result Private Sub Button1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click 'clear existing pictures Panel1.Controls.Clear() 'build and display next page placeComponents(nextPix) Panel1.Show() 'set up buttons depending on number of images in query result updateButtons() End Sub 'Event Handling for update button. It evokes the stored produce called "Insert_Train_Data" 'to insert into database the users's response Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click Dim I As Integer ' Dim UserId As Integer Dim TrainBlue As Integer ' UserId = User 'con.Open() 'This block of code records the value of slide bar movement by the user in 'order to update the corresponding rows person the 'stored procedure Update_Data is invoked. For I = 0 To al.Count - 1 in the database.For TrainBlue = al(I).User_Response.value Dim daptr = New SqlDataAdapter daptr.SelectCommand = New SqlCommand daptr.SelectCommand.CommandType = CommandType.StoredProcedure daptr.SelectCommand.CommandText = "dbo.Insert_Train_Data" daptr.SelectCommand.Connection = con 'daptr.SelectCommand.Parameters.Add("@UserID", UserId) daptr.SelectCommand.Parameters.Add("@ID", al(I).ID) daptr.SelectCommand.Parameters.Add("@TrainBlue", TrainBlue) con.Open() Try daptr.SelectCommand.ExecuteNonQuery() Catch ex As Exception MessageBox.Show("Failed to execute query") End Try con.Close() Next Dim MessageLearn As MessageLearn MessageLearn = New MessageLearn Me.Dispose() MessageLearn.Show() End Sub End Class 'Database Research Spring 2005 43 each 'Shweta Sanghi 'Main form is the start up form of the project. This forms asks the user whether he wants to provide 'training samples needed to elicit membership function or wants to provide feedback. 'If he wants to train then the learn form is evoked otherwise query form is evoked 'Also it passes used id which is input by the user to learn form or query form Public Class main Inherits System.Windows.Forms.Form #Region " Windows Form Designer generated code " Public Sub New() MyBase.New() 'This call is required by the Windows Form Designer. InitializeComponent() 'Add any initialization after the InitializeComponent() call End Sub 'Form overrides dispose to clean up the component list. Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing Then If Not (components Is Nothing) Then components.Dispose() End If End If MyBase.Dispose(disposing) End Sub 'Required by the Windows Form Designer Private components As System.ComponentModel.IContainer 'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. Friend WithEvents RadioButton1 As System.Windows.Forms.RadioButton Friend WithEvents RadioButton2 As System.Windows.Forms.RadioButton Friend WithEvents Button1 As System.Windows.Forms.Button Friend WithEvents Button2 As System.Windows.Forms.Button Friend WithEvents Label2 As System.Windows.Forms.Label Friend WithEvents Label1 As System.Windows.Forms.Label <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent() Me.RadioButton1 = New System.Windows.Forms.RadioButton Me.RadioButton2 = New System.Windows.Forms.RadioButton Me.Button1 = New System.Windows.Forms.Button Me.Button2 = New System.Windows.Forms.Button Me.Label2 = New System.Windows.Forms.Label Me.Label1 = New System.Windows.Forms.Label Me.SuspendLayout() 44 ' 'RadioButton1 ' Me.RadioButton1.Font = New System.Drawing.Font("Verdana", 12.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.RadioButton1.Location = New System.Drawing.Point(264, 160) Me.RadioButton1.Name = "RadioButton1" Me.RadioButton1.TabIndex = 2 Me.RadioButton1.Text = "Train " Me.RadioButton1.TextAlign = System.Drawing.ContentAlignment.TopCenter ' 'RadioButton2 ' Me.RadioButton2.Font = New System.Drawing.Font("Verdana", 12.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.RadioButton2.Location = New System.Drawing.Point(264, 224) Me.RadioButton2.Name = "RadioButton2" Me.RadioButton2.TabIndex = 3 Me.RadioButton2.Text = "Test" Me.RadioButton2.TextAlign = System.Drawing.ContentAlignment.TopCenter ' 'Button1 ' Me.Button1.Font = New System.Drawing.Font("Verdana", 12.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.Button1.Location = New System.Drawing.Point(104, 320) Me.Button1.Name = "Button1" Me.Button1.Size = New System.Drawing.Size(160, 32) Me.Button1.TabIndex = 4 Me.Button1.Text = "Ok" ' 'Button2 ' Me.Button2.Font = New System.Drawing.Font("Verdana", 12.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.Button2.Location = New System.Drawing.Point(456, 320) Me.Button2.Name = "Button2" Me.Button2.Size = New System.Drawing.Size(144, 32) Me.Button2.TabIndex = 5 Me.Button2.Text = "Cancel" ' 'Label2 ' Me.Label2.Font = New System.Drawing.Font("Verdana", 12.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.Label2.Location = New System.Drawing.Point(136, 96) Me.Label2.Name = "Label2" Me.Label2.Size = New System.Drawing.Size(384, 23) Me.Label2.TabIndex = 5 Me.Label2.Text = "Choose operation that you would like to do" ' 'Label1 45 ' Me.Label1.Font = New System.Drawing.Font("Verdana", 14.0!, System.Drawing.FontStyle.Bold) Me.Label1.Location = New System.Drawing.Point(24, 16) Me.Label1.Name = "Label1" Me.Label1.Size = New System.Drawing.Size(656, 32) Me.Label1.TabIndex = 0 Me.Label1.Text = "Welcome to Fuzzy Relational Database for Images Retrieval" Me.Label1.TextAlign = System.Drawing.ContentAlignment.TopCenter ' 'main ' Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13) Me.ClientSize = New System.Drawing.Size(704, 373) Me.Controls.Add(Me.Label2) Me.Controls.Add(Me.Button2) Me.Controls.Add(Me.Button1) Me.Controls.Add(Me.RadioButton2) Me.Controls.Add(Me.RadioButton1) Me.Controls.Add(Me.Label1) Me.Name = "main" Me.Text = "Fuzzy Relational Database" Me.ResumeLayout(False) End Sub #End Region 'Event handling procedure for cancel button to exit from the project Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click Me.Dispose() Me.Close() End End Sub 'Event handling procedure for ok button. According to the user’s response, 'either query form is evoked or learn form is evoked having user id as input Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click If (RadioButton1.Checked() = True) Then Dim f As learn f = New learn Me.Hide() f.Show() ElseIf (RadioButton2.Checked() = True) Then Dim f As TestslightlyBlue f = New TestslightlyBlue f.initialize() Me.Hide() f.Show() Else MessageBox.Show("Please choose operation or press cancel button.") 46 End If End Sub End Class Database Research Spring 2005 'Shweta Sanghi 'This form informs the user that the update opearation was successful and asks the user ' whether he/she would like to run another train. Public Class MessageLearn Inherits System.Windows.Forms.Form #Region " Windows Form Designer generated code " Public Sub New() MyBase.New() 'This call is required by the Windows Form Designer. InitializeComponent() 'Add any initialization after the InitializeComponent() call End Sub 'Form overrides dispose to clean up the component list. Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing Then If Not (components Is Nothing) Then components.Dispose() End If End If MyBase.Dispose(disposing) End Sub 'Required by the Windows Form Designer Private components As System.ComponentModel.IContainer 'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. Friend WithEvents Label1 As System.Windows.Forms.Label Friend WithEvents Label2 As System.Windows.Forms.Label Friend WithEvents Button1 As System.Windows.Forms.Button Friend WithEvents Button2 As System.Windows.Forms.Button <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent() Me.Label1 = New System.Windows.Forms.Label Me.Label2 = New System.Windows.Forms.Label Me.Button1 = New System.Windows.Forms.Button Me.Button2 = New System.Windows.Forms.Button Me.SuspendLayout() ' 'Label1 ' 47 Me.Label1.Font = New System.Drawing.Font("Verdana", System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, Byte)) Me.Label1.Location = New System.Drawing.Point(88, 24) Me.Label1.Name = "Label1" Me.Label1.Size = New System.Drawing.Size(312, 24) Me.Label1.TabIndex = 0 Me.Label1.Text = "Thanks for your help in research" ' 'Label2 ' Me.Label2.Font = New System.Drawing.Font("Verdana", System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, Byte)) Me.Label2.Location = New System.Drawing.Point(128, 64) Me.Label2.Name = "Label2" Me.Label2.Size = New System.Drawing.Size(216, 24) Me.Label2.TabIndex = 1 Me.Label2.Text = "Please Press Next Button" ' 'Button1 ' Me.Button1.Font = New System.Drawing.Font("Verdana", System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, Byte)) Me.Button1.Location = New System.Drawing.Point(112, 112) Me.Button1.Name = "Button1" Me.Button1.Size = New System.Drawing.Size(75, 32) Me.Button1.TabIndex = 2 Me.Button1.Text = "Next" ' 'Button2 ' Me.Button2.Font = New System.Drawing.Font("Verdana", System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, Byte)) Me.Button2.Location = New System.Drawing.Point(288, 112) Me.Button2.Name = "Button2" Me.Button2.Size = New System.Drawing.Size(80, 32) Me.Button2.TabIndex = 3 Me.Button2.Text = "End" ' 'MessageLearn ' Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13) Me.ClientSize = New System.Drawing.Size(488, 173) Me.Controls.Add(Me.Button2) Me.Controls.Add(Me.Button1) Me.Controls.Add(Me.Label2) Me.Controls.Add(Me.Label1) Me.Location = New System.Drawing.Point(5000, 7000) Me.Name = "MessageLearn" Me.Text = "Message" Me.ResumeLayout(False) End Sub 48 12.0!, CType(0, 12.0!, CType(0, 12.0!, CType(0, 12.0!, CType(0, #End Region 'Event handling for yes button. It displays the learn form Private Sub Button1_Click(ByVal sender As System.Object, System.EventArgs) Handles Button1.Click Dim f As learn f = New learn f.Show() Me.Dispose() End Sub 'Event handling for No button to exit the project Private Sub Button2_Click(ByVal sender As System.Object, System.EventArgs) Handles Button2.Click Me.Dispose() Me.Close() End End Sub Private Sub Label2_Click(ByVal sender System.EventArgs) Handles Label2.Click As System.Object, ByVal e As ByVal e As ByVal e As End Sub End Class 'Database Research Spring 2005 'Shweta Sanghi 'This form informs the user that the update opearation was successful and asks the user ' whether he/she would like to run another test. Public Class MessageTest Inherits System.Windows.Forms.Form #Region " Windows Form Designer generated code " Public Sub New() MyBase.New() 'This call is required by the Windows Form Designer. InitializeComponent() 'Add any initialization after the InitializeComponent() call End Sub 'Form overrides dispose to clean up the component list. Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing Then If Not (components Is Nothing) Then components.Dispose() End If End If MyBase.Dispose(disposing) End Sub 49 'Required by the Windows Form Designer Private components As System.ComponentModel.IContainer 'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. Friend WithEvents Label1 As System.Windows.Forms.Label Friend WithEvents Label2 As System.Windows.Forms.Label Friend WithEvents Button1 As System.Windows.Forms.Button Friend WithEvents Button2 As System.Windows.Forms.Button <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent() Me.Label1 = New System.Windows.Forms.Label Me.Label2 = New System.Windows.Forms.Label Me.Button1 = New System.Windows.Forms.Button Me.Button2 = New System.Windows.Forms.Button Me.SuspendLayout() ' 'Label1 ' Me.Label1.Font = New System.Drawing.Font("Verdana", 12.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.Label1.Location = New System.Drawing.Point(88, 24) Me.Label1.Name = "Label1" Me.Label1.Size = New System.Drawing.Size(312, 24) Me.Label1.TabIndex = 0 Me.Label1.Text = "Thanks for your help in research" ' 'Label2 ' Me.Label2.Font = New System.Drawing.Font("Verdana", 12.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.Label2.Location = New System.Drawing.Point(120, 72) Me.Label2.Name = "Label2" Me.Label2.Size = New System.Drawing.Size(216, 24) Me.Label2.TabIndex = 1 Me.Label2.Text = "Please Press Next Button" ' 'Button1 ' Me.Button1.Font = New System.Drawing.Font("Verdana", 12.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.Button1.Location = New System.Drawing.Point(112, 112) Me.Button1.Name = "Button1" Me.Button1.Size = New System.Drawing.Size(75, 32) Me.Button1.TabIndex = 2 Me.Button1.Text = "Next" ' 'Button2 ' Me.Button2.Font = New System.Drawing.Font("Verdana", 12.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.Button2.Location = New System.Drawing.Point(288, 112) 50 Me.Button2.Name = "Button2" Me.Button2.Size = New System.Drawing.Size(80, 32) Me.Button2.TabIndex = 3 Me.Button2.Text = "End" ' 'MessageTest ' Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13) Me.ClientSize = New System.Drawing.Size(488, 173) Me.Controls.Add(Me.Button2) Me.Controls.Add(Me.Button1) Me.Controls.Add(Me.Label2) Me.Controls.Add(Me.Label1) Me.Location = New System.Drawing.Point(5000, 7000) Me.Name = "MessageTest" Me.Text = "Message" Me.ResumeLayout(False) End Sub #End Region 'Event handling for yes button. It displays the Form1 form for testing Private Sub Button1_Click(ByVal sender As System.Object, ByVal e System.EventArgs) Handles Button1.Click Dim f As TestslightlyBlue f = New TestslightlyBlue f.initialize() f.Show() Me.Dispose() End Sub 'Event handling for No button to exit the project Private Sub Button2_Click(ByVal sender As System.Object, ByVal e System.EventArgs) Handles Button2.Click Me.Dispose() Me.Close() End End Sub As As End Class ‘Database Research Summer 2004 'Karen Joy and Smita Dattatri 'Database Research Spring 2005 'Updated by Shweta Sanghi 'This form reads the file which contains the Fuzzy Query and displays that on the screen 'giving the user a chance to change the query.The user can then click on the "Submit" button which submits the 'fuzzy query to the intermediate layer(stored procedures)in order to be processed. Imports System.io Public Class QueryForm Inherits System.Windows.Forms.Form 51 #Region " Windows Form Designer generated code " Public Sub New() MyBase.New() 'This call is required by the Windows Form Designer. InitializeComponent() 'Add any initialization after the InitializeComponent() call End Sub 'Form overrides dispose to clean up the component list. Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing Then If Not (components Is Nothing) Then components.Dispose() End If End If MyBase.Dispose(disposing) End Sub 'Required by the Windows Form Designer Private components As System.ComponentModel.IContainer 'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. Friend WithEvents TextBox1 As System.Windows.Forms.TextBox Friend WithEvents TextBox2 As System.Windows.Forms.TextBox Friend WithEvents Button1 As System.Windows.Forms.Button Friend WithEvents Button2 As System.Windows.Forms.Button <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent() Me.TextBox1 = New System.Windows.Forms.TextBox Me.TextBox2 = New System.Windows.Forms.TextBox Me.Button1 = New System.Windows.Forms.Button Me.Button2 = New System.Windows.Forms.Button Me.SuspendLayout() ' 'TextBox1 ' Me.TextBox1.Font = New System.Drawing.Font("Verdana", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.TextBox1.Location = New System.Drawing.Point(40, 40) Me.TextBox1.Multiline = True Me.TextBox1.Name = "TextBox1" Me.TextBox1.ScrollBars = System.Windows.Forms.ScrollBars.Both Me.TextBox1.Size = New System.Drawing.Size(512, 50) Me.TextBox1.TabIndex = 0 Me.TextBox1.Text = "TextBox1" ' 'TextBox2 ' 52 Me.TextBox2.Font = New System.Drawing.Font("Verdana", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.TextBox2.Location = New System.Drawing.Point(40, 136) Me.TextBox2.Multiline = True Me.TextBox2.Name = "TextBox2" Me.TextBox2.ScrollBars = System.Windows.Forms.ScrollBars.Both Me.TextBox2.Size = New System.Drawing.Size(512, 50) Me.TextBox2.TabIndex = 1 Me.TextBox2.Text = "TextBox2" ' 'Button1 ' Me.Button1.Font = New System.Drawing.Font("Verdana", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.Button1.Location = New System.Drawing.Point(104, 256) Me.Button1.Name = "Button1" Me.Button1.Size = New System.Drawing.Size(136, 40) Me.Button1.TabIndex = 1 Me.Button1.Text = "Submit Query" ' 'Button2 ' Me.Button2.Font = New System.Drawing.Font("Verdana", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.Button2.Location = New System.Drawing.Point(304, 256) Me.Button2.Name = "Button2" Me.Button2.Size = New System.Drawing.Size(136, 40) Me.Button2.TabIndex = 3 Me.Button2.Text = "Cancel" ' 'QueryForm ' Me.AcceptButton = Me.Button1 Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13) Me.BackColor = System.Drawing.SystemColors.Control Me.ClientSize = New System.Drawing.Size(592, 366) Me.Controls.Add(Me.Button2) Me.Controls.Add(Me.Button1) Me.Controls.Add(Me.TextBox2) Me.Controls.Add(Me.TextBox1) Me.Name = "QueryForm" Me.Text = "Query" Me.ResumeLayout(False) End Sub #End Region 'user defined variables Dim User As Integer 'variable storing user id Dim modifier As String 'varibale storing values such as slightly, medium, very Dim color_face As String 'variable storing values such as Blue, Brown, Green, blue, green, brown, broad, narrow 53 Dim strarry(20) As String 'This function is invoked when the form is loaded. 'It reads the input file called input.txt which contains the Fuzzy Query 'It also reads the input file called input1.txt to read the modifiers Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load 'Reads the file which contains the Fuzzy Query Dim myfileStream As New IO.FileStream("C:\input.txt", IO.FileMode.Open, IO.FileAccess.Read) Dim myreader As New IO.StreamReader(myfileStream) Try TextBox1.Clear() Dim line2 As New String("") Do line2 = line2 + myreader.ReadLine + vbCrLf Loop Until myreader.Peek = -1 TextBox1.AppendText(line2) Catch ex As Exception TextBox1.AppendText("File is empty") Finally myreader.Close() End Try Dim myfileStream1 As New IO.FileStream("C:\input1.txt", IO.FileMode.Open, IO.FileAccess.Read) Dim myreader1 As New IO.StreamReader(myfileStream1) Try TextBox2.Clear() Dim line1 As New String("") Dim i As Integer i = 0 Do 'line1 = line1 + myreader1.ReadLine + vbCrLf strarry(i) = New String(myreader1.ReadLine()) i = i + 1 Loop Until myreader1.Peek = -1 TextBox2.AppendText(strarry(0) + vbCrLf + strarry(1)) Catch ex As Exception ' TextBox2.AppendText("File is empty") TextBox2.AppendText(ex.ToString) Finally myreader1.Close() End Try End Sub 'Procedure takes input from main form and assigns user id to variable called User 'Public Sub initialize(ByVal us1 As Integer) ' User = us1 'End Sub 'Event handling for Submit button. It evokes and initializes the Form1 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim f As TestVeryBlue f = New TestVeryBlue Dim s1 As String = TextBox2.Lines(0) 54 Dim s2 As String = TextBox2.Lines(1) 'f.initialize(TextBox1.Text, s1, s2) Me.Hide() f.Show() End Sub 'Event handling procedure for cancel button to exit the project Private Sub Button2_Click(ByVal sender As System.Object, ByVal System.EventArgs) Handles Button2.Click Me.Dispose() Me.Close() End e As End Sub End Class ‘Database Research Summer 2004 'Karen Joy and Smita Dattatri 'Database Research Spring 2005 'Updated by Shweta Sanghi 'This form invokes the stored procedure "Fetch Data" which interprets the Fuzzy query and 'returns the set of rows to be displayed on the User Interface.This form also invokes a 'stored procedure called "Insert_Test_data" which updates the database depending on the feedback 'given by the user. Imports System.IO Imports System.Data.SqlClient Public Class TestMediumBlue Inherits System.Windows.Forms.Form #Region " Windows Form Designer generated code " Public Sub New() MyBase.New() 'This call is required by the Windows Form Designer. InitializeComponent() 'Add any initialization after the InitializeComponent() call End Sub 'Form overrides dispose to clean up the component list. Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing Then If Not (components Is Nothing) Then components.Dispose() End If End If MyBase.Dispose(disposing) 55 End Sub 'Required by the Windows Form Designer Private components As System.ComponentModel.IContainer 'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. Friend WithEvents Panel1 As System.Windows.Forms.Panel Friend WithEvents Button2 As System.Windows.Forms.Button Friend WithEvents Button1 As System.Windows.Forms.Button Friend WithEvents Label1 As System.Windows.Forms.Label Friend WithEvents Button3 As System.Windows.Forms.Button Friend WithEvents Panel2 As System.Windows.Forms.Panel <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent() Me.Panel1 = New System.Windows.Forms.Panel Me.Button3 = New System.Windows.Forms.Button Me.Button1 = New System.Windows.Forms.Button Me.Button2 = New System.Windows.Forms.Button Me.Label1 = New System.Windows.Forms.Label Me.Panel2 = New System.Windows.Forms.Panel Me.Panel1.SuspendLayout() Me.SuspendLayout() ' 'Panel1 ' Me.Panel1.Controls.Add(Me.Button3) Me.Panel1.Controls.Add(Me.Button1) Me.Panel1.Controls.Add(Me.Button2) Me.Panel1.Dock = System.Windows.Forms.DockStyle.Bottom Me.Panel1.Location = New System.Drawing.Point(0, 637) Me.Panel1.Name = "Panel1" Me.Panel1.Size = New System.Drawing.Size(872, 32) Me.Panel1.TabIndex = 2 ' 'Button3 ' Me.Button3.Anchor = System.Windows.Forms.AnchorStyles.Bottom Me.Button3.Location = New System.Drawing.Point(216, 0) Me.Button3.Name = "Button3" Me.Button3.Size = New System.Drawing.Size(104, 24) Me.Button3.TabIndex = 4 Me.Button3.Text = "More" ' 'Button1 ' Me.Button1.Anchor = System.Windows.Forms.AnchorStyles.Bottom Me.Button1.BackColor = System.Drawing.Color.LightGray Me.Button1.Font = New System.Drawing.Font("Verdana", 8.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.Button1.Location = New System.Drawing.Point(384, 0) Me.Button1.Name = "Button1" Me.Button1.Size = New System.Drawing.Size(104, 24) Me.Button1.TabIndex = 1 Me.Button1.Text = "Update" 56 ' 'Button2 ' Me.Button2.Anchor = System.Windows.Forms.AnchorStyles.Bottom Me.Button2.BackColor = System.Drawing.Color.LightGray Me.Button2.Font = New System.Drawing.Font("Verdana", 8.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.Button2.Location = New System.Drawing.Point(552, 0) Me.Button2.Name = "Button2" Me.Button2.Size = New System.Drawing.Size(104, 24) Me.Button2.TabIndex = 3 Me.Button2.Text = "Cancel" ' 'Label1 ' Me.Label1.Font = New System.Drawing.Font("Verdana", 12.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.Label1.Location = New System.Drawing.Point(280, 0) Me.Label1.Name = "Label1" Me.Label1.Size = New System.Drawing.Size(552, 24) Me.Label1.TabIndex = 4 Me.Label1.Text = "Label1" ' 'Panel2 ' Me.Panel2.Location = New System.Drawing.Point(0, 32) Me.Panel2.Name = "Panel2" Me.Panel2.Size = New System.Drawing.Size(864, 600) Me.Panel2.TabIndex = 5 ' 'TestMediumBlue ' Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13) Me.ClientSize = New System.Drawing.Size(872, 669) Me.Controls.Add(Me.Panel2) Me.Controls.Add(Me.Label1) Me.Controls.Add(Me.Panel1) Me.Name = "TestMediumBlue" Me.Text = "Testing Direct Method" Me.WindowState = System.Windows.Forms.FormWindowState.Maximized Me.Panel1.ResumeLayout(False) Me.ResumeLayout(False) End Sub #End Region 'user defined variables Dim User As Integer 'variable storing user id Dim Query As String 'variable storing the query Dim modifier As String 'varibale storing values such as slightly, medium, very Dim color_face As String 'variable storing values such as Blue, Brown, Green, blue, green, brown, broad, narrow 57 Dim ds As New DataSet 'varibale storing dataset which is the result of the query Dim al As New ArrayList 'varibale storing image set which has image and check boxes Dim nextPix As Integer 'variable indicating the first picture to be displayed on a page Dim remainingPix As Integer 'variable indicating the remaining pictures to be displayed on a page 'Connection String used to connect to the database. 'vikas=Name Of the Computer 'DBResearch=Name of the database Dim con As New source=vikas;initial id=dbresearch;password=dbresearch") System.Data.SqlClient.SqlConnection("data catalog=DBResearch;user 'Event handling procedure for the 'Update' button . It evokes the stored produce called "Insert_Test_Data" 'to insert into database the users's response Private Sub Button1_Click(ByVal sender System.EventArgs) Handles Button1.Click Dim I As Integer ' Dim UserId As Integer Dim TestBlue As Integer 'UserId = User As System.Object, ByVal e As 'con.Open() 'This block of code checks which check boxes were clicked by the user and for which 'person in order to update the corresponding rows in the database.For each person the 'stored procedure Insert_Test_Data is invoked. For I = 0 To al.Count - 1 If (al(I).meets_criteria.Checked() = True) Then TestBlue = 0 ElseIf (al(I).no_criteria_meet.Checked() = True) Then TestBlue = 1 End If Dim daptr = New SqlDataAdapter daptr.SelectCommand = New SqlCommand daptr.SelectCommand.CommandType = CommandType.StoredProcedure daptr.SelectCommand.CommandText = "dbo.Insert_Test_Data" daptr.SelectCommand.Connection = con 'daptr.SelectCommand.Parameters.Add("@UserID", UserId) daptr.SelectCommand.Parameters.Add("@ID", al(I).ID) daptr.SelectCommand.Parameters.Add("@ValueBlue", TestBlue) daptr.SelectCommand.Parameters.Add("@TypeBlue", "medium") con.Open() Try daptr.SelectCommand.ExecuteNonQuery() Catch ex As Exception MessageBox.Show("Failed to execute query") 58 End Try con.Close() Next Dim TestVeryBlue As TestVeryBlue TestVeryBlue = New TestVeryBlue TestVeryBlue.initialize() Me.Dispose() TestVeryBlue.Show() End Sub 'This function is invoked when the form is loaded.The stored procedure "Fetch_Data" is 'invoked and the fuzzy modifiers are passed as parameters to this stored procedure. 'This stored procedure interprets the fuzzy modifiers and returns the result set that 'matches the criteria. Private Sub TestMediumBlue_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim I As Integer Dim Count As Integer 'Making connection to database and executes the stored procedure called "Fetch_Data" 'and put the dataset in da variable Dim cmd As New System.Data.SqlClient.SqlCommand("Fetch_Direct_Data", con) cmd.CommandType = CommandType.StoredProcedure cmd.Parameters.Add(New SqlParameter("@query", SqlDbType.VarChar, 100)) cmd.Parameters("@query").Value = Query cmd.Parameters.Add(New SqlParameter("@s1", SqlDbType.VarChar, 100)) cmd.Parameters("@s1").Value = modifier cmd.Parameters.Add(New SqlParameter("@s2", SqlDbType.VarChar, 100)) cmd.Parameters("@s2").Value = color_face Try Dim da As New System.Data.SqlClient.SqlDataAdapter(cmd) da.Fill(ds) Catch ex As Exception MessageBox.Show(ex.ToString) End Try 'displays the number of rows returned as a result of query (use for debugging) 'MessageBox.Show(ds.Tables(0).Rows().Count) 'This block executes the each dataset row, creates image set ' and displays on the form If (ds.Tables(0).Rows().Count) > 0 Then Count = ds.Tables(0).Compute("COUNT(ID)", "") 59 'The following block of code creates a new object of ImageSet for each 'record in the which result set which contains the image and the Check Boxes 'associated with it. It also reads the image in binary format from the database 'and displays it appropriately. For I = 0 To Count - 1 Dim S As New ImageSet(color_face) Dim bits As Byte() = CType(ds.Tables(0).Rows(I).Item(2), Byte()) Dim memorybits As New MemoryStream(bits) Dim bitmap As New Bitmap(memorybits) S.picture.Image = bitmap al.Add(S) al(I).ID = ds.Tables(0).Rows(I).Item(0) Next I 'variable indicating the first picture to be displayed on a page nextPix = 0 'variable indicating the remaining pictures to be displayed remainingPix = al.Count 'The following block of code places the components on the Group Box and 'then places the group box on the panel to be displayed. placeComponents(nextPix) 'This procedure is evoked so that update button is disabled 'until form displays last page of the query. At the last page, more button is disabled updateButtons() 'Changes the labels on the Panel depending on the query. If color_face = "Green" Or color_face = "Blue" Or color_face = "Brown" Or color_face = "green" Or color_face = "blue" Or color_face = "brown" Then Label1.Text() = "People with " + modifier + " " + color_face + " Eyes" Else Label1.Text() = "People With " + modifier + " " + color_face + " Faces" End If Else MessageBox.Show("No images match your criteria") End If End Sub 'The following block of code places the components on the Group Box and 'then places the group box on the panel to be displayed. Private Sub placeComponents(ByVal Position1 As Integer) Dim X As Integer, Y As Integer 60 Y = 8 Dim I As Integer 'limit the display to 6 images Dim lastPix As Integer 'determing the last picture for the current page If remainingPix <= 6 Then lastPix = Position1 + remainingPix - 1 Else : lastPix = Position1 + 5 End If For I = Position1 To lastPix Dim G As New GroupBox G.Location() = New Point(8 + X, Y) G.Size() = New Size(268, 295) 'was (288,350) al(I).picture.Location = New Point(50, 24) al(I).picture.size = New Size(200, 200) 'was (224,120) al(I).meets_criteria.location = New Point(32, 225) 'was (32, 250) al(I).meets_criteria.size = New Size(176, 24) al(I).no_criteria_meet.size = New Size(176, 24) al(I).no_criteria_meet.location = New Point(32, 250) 'was (32, 275) G.Controls.Add(al(I).picture) G.Controls.Add(al(I).meets_criteria) G.Controls.Add(al(I).no_criteria_meet) Panel2.Controls.Add(G) 'Allows to display multiple rows of records. X = 300 + X If ((I Mod 6) = 2) Then Y = 295 + 5 + Y X = 0 End If Next 'update the number of picutes left to be displayed If remainingPix > 6 Then remainingPix = remainingPix - 6 Else remainingPix = 0 End If 'update first picture on next page nextPix = nextPix + 6 End Sub 'set up buttons depending on number of images in query result 'This procedure is evoked so that update button is disabled 'until form displays last page of the query. At the last page, more button is disabled Private Sub updateButtons() 61 If al.Count <= 6 Or remainingPix = 0 Then Me.Button3.Enabled = False Me.Button1.Enabled = True Else Me.Button3.Enabled = True Me.Button1.Enabled = False End If End Sub 'Procedure takes input from query form and assigns them to variables Public Sub initialize() Query = "select * from person where color.color = 'blue';" modifier = "Medium" color_face = "Blue" End Sub 'Event handling for 'Cancel' button. It closes the database connection and exit the project Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click con.Close() Me.Dispose() Me.Close() End End Sub 'Event handling for 'More' button 'It clears the panel, builds and displays next page 'set up buttons depending on number of images in query result Private Sub Button3_Click(ByVal sender As System.Object, ByVal System.EventArgs) Handles Button3.Click 'clear existing pictures Panel2.Controls.Clear() 'build and display next page placeComponents(nextPix) Panel2.Show() 'set up buttons depending on number of images in query result updateButtons() End Sub '---------------------------------------------------------------'The class ImagesSet is a user defined class which has the image 'and the check boxes as its components. Public Class ImageSet Public picture As PictureBox Public meets_criteria As RadioButton Public no_criteria_meet As RadioButton Public ID As Integer Public Sub New(ByVal color_face As String) picture = New PictureBox 62 e As meets_criteria = New RadioButton no_criteria_meet = New RadioButton meets_criteria.Text = "Satisfied with result" meets_criteria.Checked = True 'Changes the labels on the Check Boxes depending on the query. no_criteria_meet.Text = "Not satisfied with result" ID = 0 End Sub End Class End Class 'Database Research Summer 2004 'Karen Joy and Smita Dattatri 'Database Research Spring 2005 'Updated by Shweta Sanghi 'This form invokes the stored procedure "Fetch Data" which interprets the Fuzzy query and 'returns the set of rows to be displayed on the User Interface.This form also invokes a 'stored procedure called "Insert_Test_data" which updates the database depending on the feedback 'given by the user. Imports System.IO Imports System.Data.SqlClient Public Class TestslightlyBlue Inherits System.Windows.Forms.Form #Region " Windows Form Designer generated code " Public Sub New() MyBase.New() 'This call is required by the Windows Form Designer. InitializeComponent() 'Add any initialization after the InitializeComponent() call End Sub 'Form overrides dispose to clean up the component list. Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing Then If Not (components Is Nothing) Then components.Dispose() End If End If MyBase.Dispose(disposing) End Sub 63 'Required by the Windows Form Designer Private components As System.ComponentModel.IContainer 'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. Friend WithEvents Panel1 As System.Windows.Forms.Panel Friend WithEvents Button2 As System.Windows.Forms.Button Friend WithEvents Button1 As System.Windows.Forms.Button Friend WithEvents Label1 As System.Windows.Forms.Label Friend WithEvents Button3 As System.Windows.Forms.Button Friend WithEvents Panel2 As System.Windows.Forms.Panel <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent() Me.Panel1 = New System.Windows.Forms.Panel Me.Button3 = New System.Windows.Forms.Button Me.Button1 = New System.Windows.Forms.Button Me.Button2 = New System.Windows.Forms.Button Me.Label1 = New System.Windows.Forms.Label Me.Panel2 = New System.Windows.Forms.Panel Me.Panel1.SuspendLayout() Me.SuspendLayout() ' 'Panel1 ' Me.Panel1.Controls.Add(Me.Button3) Me.Panel1.Controls.Add(Me.Button1) Me.Panel1.Controls.Add(Me.Button2) Me.Panel1.Dock = System.Windows.Forms.DockStyle.Bottom Me.Panel1.Location = New System.Drawing.Point(0, 637) Me.Panel1.Name = "Panel1" Me.Panel1.Size = New System.Drawing.Size(872, 32) Me.Panel1.TabIndex = 2 ' 'Button3 ' Me.Button3.Anchor = System.Windows.Forms.AnchorStyles.Bottom Me.Button3.Location = New System.Drawing.Point(216, 0) Me.Button3.Name = "Button3" Me.Button3.Size = New System.Drawing.Size(104, 24) Me.Button3.TabIndex = 4 Me.Button3.Text = "More" ' 'Button1 ' Me.Button1.Anchor = System.Windows.Forms.AnchorStyles.Bottom Me.Button1.BackColor = System.Drawing.Color.LightGray Me.Button1.Font = New System.Drawing.Font("Verdana", 8.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.Button1.Location = New System.Drawing.Point(384, 0) Me.Button1.Name = "Button1" Me.Button1.Size = New System.Drawing.Size(104, 24) Me.Button1.TabIndex = 1 Me.Button1.Text = "Update" ' 'Button2 64 ' Me.Button2.Anchor = System.Windows.Forms.AnchorStyles.Bottom Me.Button2.BackColor = System.Drawing.Color.LightGray Me.Button2.Font = New System.Drawing.Font("Verdana", 8.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.Button2.Location = New System.Drawing.Point(552, 0) Me.Button2.Name = "Button2" Me.Button2.Size = New System.Drawing.Size(104, 24) Me.Button2.TabIndex = 3 Me.Button2.Text = "Cancel" ' 'Label1 ' Me.Label1.Font = New System.Drawing.Font("Verdana", 12.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.Label1.Location = New System.Drawing.Point(280, 0) Me.Label1.Name = "Label1" Me.Label1.Size = New System.Drawing.Size(552, 24) Me.Label1.TabIndex = 4 Me.Label1.Text = "Label1" ' 'Panel2 ' Me.Panel2.Location = New System.Drawing.Point(0, 32) Me.Panel2.Name = "Panel2" Me.Panel2.Size = New System.Drawing.Size(864, 600) Me.Panel2.TabIndex = 5 ' 'TestslightlyBlue ' Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13) Me.ClientSize = New System.Drawing.Size(872, 669) Me.Controls.Add(Me.Panel2) Me.Controls.Add(Me.Label1) Me.Controls.Add(Me.Panel1) Me.Name = "TestslightlyBlue" Me.Text = "Testing Direct Method" Me.WindowState = System.Windows.Forms.FormWindowState.Maximized Me.Panel1.ResumeLayout(False) Me.ResumeLayout(False) End Sub #End Region 'user defined variables Dim User As Integer 'variable storing user id Dim Query As String 'variable storing the query Dim modifier As String 'varibale storing values such as slightly, medium, very Dim color_face As String 'variable storing values such as Blue, Brown, Green, blue, green, brown, broad, narrow Dim ds As New DataSet 'varibale storing dataset which is the result of the query 65 Dim al As New ArrayList 'varibale storing image set which has image and check boxes Dim nextPix As Integer 'variable indicating the first picture to be displayed on a page Dim remainingPix As Integer 'variable indicating the remaining pictures to be displayed on a page 'Connection String used to connect to the database. 'vikas=Name Of the Computer 'DBResearch=Name of the database Dim con As New source=vikas;initial id=dbresearch;password=dbresearch") System.Data.SqlClient.SqlConnection("data catalog=DBResearch;user 'Event handling procedure for the 'Update' button . It evokes the stored produce called "Insert_Test_Data" 'to insert into database the users's response Private Sub Button1_Click(ByVal sender System.EventArgs) Handles Button1.Click Dim I As Integer ' Dim UserId As Integer Dim TestBlue As Integer 'UserId = User As System.Object, ByVal e As 'con.Open() 'This block of code checks which check boxes were clicked by the user and for which 'person in order to update the corresponding rows in the database.For each person the 'stored procedure Insert_Test_Data is invoked. For I = 0 To al.Count - 1 If (al(I).meets_criteria.Checked() = True) Then TestBlue = 0 ElseIf (al(I).no_criteria_meet.Checked() = True) Then TestBlue = 1 End If Dim daptr = New SqlDataAdapter daptr.SelectCommand = New SqlCommand daptr.SelectCommand.CommandType = CommandType.StoredProcedure daptr.SelectCommand.CommandText = "dbo.Insert_Test_Data" daptr.SelectCommand.Connection = con 'daptr.SelectCommand.Parameters.Add("@UserID", UserId) daptr.SelectCommand.Parameters.Add("@ID", al(I).ID) daptr.SelectCommand.Parameters.Add("@ValueBlue", TestBlue) daptr.SelectCommand.Parameters.Add("@TypeBlue", "less") con.Open() Try daptr.SelectCommand.ExecuteNonQuery() Catch ex As Exception MessageBox.Show("Failed to execute query") End Try 66 con.Close() Next Dim TestMediumBlue As TestMediumBlue TestMediumBlue = New TestMediumBlue TestMediumBlue.initialize() Me.Dispose() TestMediumBlue.Show() End Sub 'This function is invoked when the form is loaded.The stored procedure "Fetch_Data" is 'invoked and the fuzzy modifiers are passed as parameters to this stored procedure. 'This stored procedure interprets the fuzzy modifiers and returns the result set that 'matches the criteria. Private Sub TestslightlyBlue_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim I As Integer Dim Count As Integer 'Making connection to database and executes the stored procedure called "Fetch_Data" 'and put the dataset in da variable Dim cmd As New System.Data.SqlClient.SqlCommand("Fetch_Direct_Data", con) cmd.CommandType = CommandType.StoredProcedure cmd.Parameters.Add(New SqlParameter("@query", SqlDbType.VarChar, 100)) cmd.Parameters("@query").Value = Query cmd.Parameters.Add(New SqlParameter("@s1", SqlDbType.VarChar, 100)) cmd.Parameters("@s1").Value = modifier cmd.Parameters.Add(New SqlParameter("@s2", SqlDbType.VarChar, 100)) cmd.Parameters("@s2").Value = color_face Try Dim da As New System.Data.SqlClient.SqlDataAdapter(cmd) da.Fill(ds) Catch ex As Exception MessageBox.Show(ex.ToString) End Try 'displays the number of rows returned as a result of query (use for debugging) 'MessageBox.Show(ds.Tables(0).Rows().Count) 'This block executes the each dataset row, creates image set ' and displays on the form If (ds.Tables(0).Rows().Count) > 0 Then Count = ds.Tables(0).Compute("COUNT(ID)", "") 67 'The following block of code creates a new object of ImageSet for each 'record in the which result set which contains the image and the Check Boxes 'associated with it. It also reads the image in binary format from the database 'and displays it appropriately. For I = 0 To Count - 1 Dim S As New ImageSet(color_face) Dim bits As Byte() = CType(ds.Tables(0).Rows(I).Item(2), Byte()) Dim memorybits As New MemoryStream(bits) Dim bitmap As New Bitmap(memorybits) S.picture.Image = bitmap al.Add(S) al(I).ID = ds.Tables(0).Rows(I).Item(0) Next I 'variable indicating the first picture to be displayed on a page nextPix = 0 'variable indicating the remaining pictures to be displayed remainingPix = al.Count 'The following block of code places the components on the Group Box and 'then places the group box on the panel to be displayed. placeComponents(nextPix) 'This procedure is evoked so that update button is disabled 'until form displays last page of the query. At the last page, more button is disabled updateButtons() 'Changes the labels on the Panel depending on the query. If color_face = "Green" Or color_face = "Blue" Or color_face = "Brown" Or color_face = "green" Or color_face = "blue" Or color_face = "brown" Then Label1.Text() = "People with " + modifier + " " + color_face + " Eyes" Else Label1.Text() = "People With " + modifier + " " + color_face + " Faces" End If Else MessageBox.Show("No images match your criteria") End If End Sub 'The following block of code places the components on the Group Box and 'then places the group box on the panel to be displayed. Private Sub placeComponents(ByVal Position1 As Integer) Dim X As Integer, Y As Integer Y = 8 68 Dim I As Integer 'limit the display to 6 images Dim lastPix As Integer 'determing the last picture for the current page If remainingPix <= 6 Then lastPix = Position1 + remainingPix - 1 Else : lastPix = Position1 + 5 End If For I = Position1 To lastPix Dim G As New GroupBox G.Location() = New Point(8 + X, Y) G.Size() = New Size(268, 295) 'was (288,350) al(I).picture.Location = New Point(50, 24) al(I).picture.size = New Size(200, 200) 'was (224,120) al(I).meets_criteria.location = New Point(32, 225) 'was (32, 250) al(I).meets_criteria.size = New Size(176, 24) al(I).no_criteria_meet.size = New Size(176, 24) al(I).no_criteria_meet.location = New Point(32, 250) 'was (32, 275) G.Controls.Add(al(I).picture) G.Controls.Add(al(I).meets_criteria) G.Controls.Add(al(I).no_criteria_meet) Panel2.Controls.Add(G) 'Allows to display multiple rows of records. X = 300 + X If ((I Mod 6) = 2) Then Y = 295 + 5 + Y X = 0 End If Next 'update the number of picutes left to be displayed If remainingPix > 6 Then remainingPix = remainingPix - 6 Else remainingPix = 0 End If 'update first picture on next page nextPix = nextPix + 6 End Sub 'set up buttons depending on number of images in query result 'This procedure is evoked so that update button is disabled 'until form displays last page of the query. At the last page, more button is disabled Private Sub updateButtons() If al.Count <= 6 Or remainingPix = 0 Then 69 Me.Button3.Enabled = False Me.Button1.Enabled = True Else Me.Button3.Enabled = True Me.Button1.Enabled = False End If End Sub 'Procedure takes input from query form and assigns them to variables Public Sub initialize() Query = "select * from person where color.color = 'blue';" modifier = "slightly" color_face = "Blue" End Sub 'Event handling for 'Cancel' button. It closes the database connection and exit the project Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click con.Close() Me.Dispose() Me.Close() End End Sub 'Event handling for 'More' button 'It clears the panel, builds and displays next page 'set up buttons depending on number of images in query result Private Sub Button3_Click(ByVal sender As System.Object, ByVal System.EventArgs) Handles Button3.Click 'clear existing pictures Panel2.Controls.Clear() 'build and display next page placeComponents(nextPix) Panel2.Show() 'set up buttons depending on number of images in query result updateButtons() End Sub '---------------------------------------------------------------'The class ImagesSet is a user defined class which has the image 'and the check boxes as its components. Public Class ImageSet Public picture As PictureBox Public meets_criteria As RadioButton Public no_criteria_meet As RadioButton Public ID As Integer Public Sub New(ByVal color_face As String) picture = New PictureBox meets_criteria = New RadioButton 70 e As no_criteria_meet = New RadioButton meets_criteria.Text = "Satisfied with result" meets_criteria.Checked = True 'Changes the labels on the Check Boxes depending on the query. no_criteria_meet.Text = "Not satisfied with result" ID = 0 End Sub End Class End Class ‘Database Research Summer 2004 'Karen Joy and Smita Dattatri 'Database Research Spring 2005 'Updated by Shweta Sanghi 'This form invokes the stored procedure "Fetch Data" which interprets the Fuzzy query and 'returns the set of rows to be displayed on the User Interface.This form also invokes a 'stored procedure called "Insert_Test_data" which updates the database depending on the feedback 'given by the user. Imports System.IO Imports System.Data.SqlClient Public Class TestVeryBlue Inherits System.Windows.Forms.Form #Region " Windows Form Designer generated code " Public Sub New() MyBase.New() 'This call is required by the Windows Form Designer. InitializeComponent() 'Add any initialization after the InitializeComponent() call End Sub 'Form overrides dispose to clean up the component list. Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing Then If Not (components Is Nothing) Then components.Dispose() End If End If MyBase.Dispose(disposing) End Sub 'Required by the Windows Form Designer 71 Private components As System.ComponentModel.IContainer 'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. Friend WithEvents Panel1 As System.Windows.Forms.Panel Friend WithEvents Button2 As System.Windows.Forms.Button Friend WithEvents Button1 As System.Windows.Forms.Button Friend WithEvents Label1 As System.Windows.Forms.Label Friend WithEvents Button3 As System.Windows.Forms.Button Friend WithEvents Panel2 As System.Windows.Forms.Panel <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent() Me.Panel1 = New System.Windows.Forms.Panel Me.Button3 = New System.Windows.Forms.Button Me.Button1 = New System.Windows.Forms.Button Me.Button2 = New System.Windows.Forms.Button Me.Label1 = New System.Windows.Forms.Label Me.Panel2 = New System.Windows.Forms.Panel Me.Panel1.SuspendLayout() Me.SuspendLayout() ' 'Panel1 ' Me.Panel1.Controls.Add(Me.Button3) Me.Panel1.Controls.Add(Me.Button1) Me.Panel1.Controls.Add(Me.Button2) Me.Panel1.Dock = System.Windows.Forms.DockStyle.Bottom Me.Panel1.Location = New System.Drawing.Point(0, 637) Me.Panel1.Name = "Panel1" Me.Panel1.Size = New System.Drawing.Size(872, 32) Me.Panel1.TabIndex = 2 ' 'Button3 ' Me.Button3.Anchor = System.Windows.Forms.AnchorStyles.Bottom Me.Button3.Location = New System.Drawing.Point(216, 0) Me.Button3.Name = "Button3" Me.Button3.Size = New System.Drawing.Size(104, 24) Me.Button3.TabIndex = 4 Me.Button3.Text = "More" 'Button1 ' Me.Button1.Anchor = System.Windows.Forms.AnchorStyles.Bottom Me.Button1.BackColor = System.Drawing.Color.LightGray Me.Button1.Font = New System.Drawing.Font("Verdana", 8.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.Button1.Location = New System.Drawing.Point(384, 0) Me.Button1.Name = "Button1" Me.Button1.Size = New System.Drawing.Size(104, 24) Me.Button1.TabIndex = 1 Me.Button1.Text = "Update" ' 'Button2 ' Me.Button2.Anchor = System.Windows.Forms.AnchorStyles.Bottom 72 Me.Button2.BackColor = System.Drawing.Color.LightGray Me.Button2.Font = New System.Drawing.Font("Verdana", 8.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.Button2.Location = New System.Drawing.Point(552, 0) Me.Button2.Name = "Button2" Me.Button2.Size = New System.Drawing.Size(104, 24) Me.Button2.TabIndex = 3 Me.Button2.Text = "Cancel" ' 'Label1 ' Me.Label1.Font = New System.Drawing.Font("Verdana", 12.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.Label1.Location = New System.Drawing.Point(280, 0) Me.Label1.Name = "Label1" Me.Label1.Size = New System.Drawing.Size(552, 24) Me.Label1.TabIndex = 4 Me.Label1.Text = "Label1" ' 'Panel2 ' Me.Panel2.Location = New System.Drawing.Point(0, 32) Me.Panel2.Name = "Panel2" Me.Panel2.Size = New System.Drawing.Size(864, 600) Me.Panel2.TabIndex = 5 ' 'TestVeryBlue ' Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13) Me.ClientSize = New System.Drawing.Size(872, 669) Me.Controls.Add(Me.Panel2) Me.Controls.Add(Me.Label1) Me.Controls.Add(Me.Panel1) Me.Name = "TestVeryBlue" Me.Text = "Testing Direct Method" Me.WindowState = System.Windows.Forms.FormWindowState.Maximized Me.Panel1.ResumeLayout(False) Me.ResumeLayout(False) End Sub #End Region 'user defined variables Dim User As Integer 'variable storing user id Dim Query As String 'variable storing the query Dim modifier As String 'varibale storing values such as slightly, medium, very Dim color_face As String 'variable storing values such as Blue, Brown, Green, blue, green, brown, broad, narrow Dim ds As New DataSet 'varibale storing dataset which is the result of the query Dim al As New ArrayList 'varibale storing image set which has image and check boxes 73 Dim nextPix As Integer 'variable indicating the first picture to be displayed on a page Dim remainingPix As Integer 'variable indicating the remaining pictures to be displayed on a page 'Connection String used to connect to the database. 'vikas=Name Of the Computer 'DBResearch=Name of the database Dim con As New source=vikas;initial id=dbresearch;password=dbresearch") System.Data.SqlClient.SqlConnection("data catalog=DBResearch;user 'Event handling procedure for the 'Update' button . It evokes the stored produce called "Insert_Test_Data" 'to insert into database the users's response Private Sub Button1_Click(ByVal sender System.EventArgs) Handles Button1.Click Dim I As Integer ' Dim UserId As Integer Dim TestBlue As Integer 'UserId = User As System.Object, ByVal e As 'con.Open() 'This block of code checks which check boxes were clicked by the user and for which 'person in order to update the corresponding rows in the database.For each person the 'stored procedure Insert_Test_Data is invoked. For I = 0 To al.Count - 1 If (al(I).meets_criteria.Checked() = True) Then TestBlue = 0 ElseIf (al(I).no_criteria_meet.Checked() = True) Then TestBlue = 1 End If Dim daptr = New SqlDataAdapter daptr.SelectCommand = New SqlCommand daptr.SelectCommand.CommandType = CommandType.StoredProcedure daptr.SelectCommand.CommandText = "dbo.Insert_Test_Data" daptr.SelectCommand.Connection = con 'daptr.SelectCommand.Parameters.Add("@UserID", UserId) daptr.SelectCommand.Parameters.Add("@ID", al(I).ID) daptr.SelectCommand.Parameters.Add("@ValueBlue", TestBlue) daptr.SelectCommand.Parameters.Add("@TypeBlue", "very") con.Open() Try daptr.SelectCommand.ExecuteNonQuery() Catch ex As Exception MessageBox.Show("Failed to execute query") End Try con.Close() 74 Next Dim MessageTest As MessageTest MessageTest = New MessageTest Me.Dispose() MessageTest.Show() End Sub 'This function is invoked when the form is loaded.The stored procedure "Fetch_Data" is 'invoked and the fuzzy modifiers are passed as parameters to this stored procedure. 'This stored procedure interprets the fuzzy modifiers and returns the result set that 'matches the criteria. Private Sub TestVeryBlue_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim I As Integer Dim Count As Integer 'Making connection to database and executes the stored procedure called "Fetch_Data" 'and put the dataset in da variable Dim cmd As New System.Data.SqlClient.SqlCommand("Fetch_Direct_Data", con) cmd.CommandType = CommandType.StoredProcedure cmd.Parameters.Add(New SqlParameter("@query", SqlDbType.VarChar, 100)) cmd.Parameters("@query").Value = Query cmd.Parameters.Add(New SqlParameter("@s1", SqlDbType.VarChar, 100)) cmd.Parameters("@s1").Value = modifier cmd.Parameters.Add(New SqlParameter("@s2", SqlDbType.VarChar, 100)) cmd.Parameters("@s2").Value = color_face Try Dim da As New System.Data.SqlClient.SqlDataAdapter(cmd) da.Fill(ds) Catch ex As Exception MessageBox.Show(ex.ToString) End Try 'displays the number of rows returned as a result of query (use for debugging) 'MessageBox.Show(ds.Tables(0).Rows().Count) 'This block executes the each dataset row, creates image set ' and displays on the form If (ds.Tables(0).Rows().Count) > 0 Then Count = ds.Tables(0).Compute("COUNT(ID)", "") 'The following block of code creates a new object of ImageSet for each 'record in the which result set which contains the image and the Check Boxes 75 'associated with it. It also reads the image in binary format from the database 'and displays it appropriately. For I = 0 To Count - 1 Dim S As New ImageSet(color_face) Dim bits As Byte() = CType(ds.Tables(0).Rows(I).Item(2), Byte()) Dim memorybits As New MemoryStream(bits) Dim bitmap As New Bitmap(memorybits) S.picture.Image = bitmap al.Add(S) al(I).ID = ds.Tables(0).Rows(I).Item(0) Next I 'variable indicating the first picture to be displayed on a page nextPix = 0 'variable indicating the remaining pictures to be displayed remainingPix = al.Count 'The following block of code places the components on the Group Box and 'then places the group box on the panel to be displayed. placeComponents(nextPix) 'This procedure is evoked so that update button is disabled 'until form displays last page of the query. At the last page, more button is disabled updateButtons() 'Changes the labels on the Panel depending on the query. If color_face = "Green" Or color_face = "Blue" Or color_face = "Brown" Or color_face = "green" Or color_face = "blue" Or color_face = "brown" Then Label1.Text() = "People with " + modifier + " " + color_face + " Eyes" Else Label1.Text() = "People With " + modifier + " " + color_face + " Faces" End If Else MessageBox.Show("No images match your criteria") End If End Sub 'The following block of code places the components on the Group Box and 'then places the group box on the panel to be displayed. Private Sub placeComponents(ByVal Position1 As Integer) Dim X As Integer, Y As Integer Y = 8 Dim I As Integer 'limit the display to 6 images Dim lastPix As Integer 76 'determing the last picture for the current page If remainingPix <= 6 Then lastPix = Position1 + remainingPix - 1 Else : lastPix = Position1 + 5 End If For I = Position1 To lastPix Dim G As New GroupBox G.Location() = New Point(8 + X, Y) G.Size() = New Size(268, 295) 'was (288,350) al(I).picture.Location = New Point(50, 24) al(I).picture.size = New Size(200, 200) 'was (224,120) al(I).meets_criteria.location = New Point(32, 225) 'was (32, 250) al(I).meets_criteria.size = New Size(176, 24) al(I).no_criteria_meet.size = New Size(176, 24) al(I).no_criteria_meet.location = New Point(32, 250) 'was (32, 275) G.Controls.Add(al(I).picture) G.Controls.Add(al(I).meets_criteria) G.Controls.Add(al(I).no_criteria_meet) Panel2.Controls.Add(G) 'Allows to display multiple rows of records. X = 300 + X If ((I Mod 6) = 2) Then Y = 295 + 5 + Y X = 0 End If Next 'update the number of picutes left to be displayed If remainingPix > 6 Then remainingPix = remainingPix - 6 Else remainingPix = 0 End If 'update first picture on next page nextPix = nextPix + 6 End Sub 'set up buttons depending on number of images in query result 'This procedure is evoked so that update button is disabled 'until form displays last page of the query. At the last page, more button is disabled Private Sub updateButtons() If al.Count <= 6 Or remainingPix = 0 Then Me.Button3.Enabled = False Me.Button1.Enabled = True Else Me.Button3.Enabled = True Me.Button1.Enabled = False 77 End If End Sub 'Procedure takes input from query form and assigns them to variables Public Sub initialize() Query = "select * from person where color.color = 'blue';" modifier = "very" color_face = "Blue" End Sub 'Event handling for 'Cancel' button. It closes the database connection and exit the project Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click con.Close() Me.Dispose() Me.Close() End End Sub 'Event handling for 'More' button 'It clears the panel, builds and displays next page 'set up buttons depending on number of images in query result Private Sub Button3_Click(ByVal sender As System.Object, ByVal System.EventArgs) Handles Button3.Click 'clear existing pictures Panel2.Controls.Clear() 'build and display next page placeComponents(nextPix) Panel2.Show() 'set up buttons depending on number of images in query result updateButtons() End Sub '---------------------------------------------------------------'The class ImagesSet is a user defined class which has the image 'and the check boxes as its components. Public Class ImageSet Public picture As PictureBox Public meets_criteria As RadioButton Public no_criteria_meet As RadioButton Public ID As Integer Public Sub New(ByVal color_face As String) picture = New PictureBox meets_criteria = New RadioButton no_criteria_meet = New RadioButton meets_criteria.Text = "Satisfied with result" meets_criteria.Checked = True 'Changes the labels on the Check Boxes depending on the query. no_criteria_meet.Text = "Not satisfied with result" ID = 0 End Sub End Class End Class 78 e As Appendix C Statistical Method to Construct Membership Weight for Images For each image, following is shown Table of Scores representing user’s view on blue eye color Frequency Distribution table for image Graph based on frequency distribution Frequency Distribution of Image ID 1 14 12 10 Frequency Image 1 Scores 0-29 30-74 75-100 0 1 0 0 25 1 0 0 33 0 1 0 39 0 1 0 44 0 1 0 46 0 1 0 52 0 1 0 53 0 1 0 54 0 1 0 62 0 1 0 65 0 1 0 69 0 1 0 70 0 1 0 71 0 1 0 74 0 1 0 75 0 0 1 86 0 0 1 93 0 0 1 99 0 0 1 100 0 0 1 100 0 0 1 2 13 6 8 6 4 2 0 0-29 30-74 Frequency Range 79 75-100 Image 3 Scores 0 0 0 0 0 0 2 3 7 12 12 18 20 21 27 34 47 50 55 63 80 0-29 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 10 0-29 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 15 30-74 75-100 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 0 1 0 1 9 2 30-74 75-100 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 1 0 1 0 1 0 0 1 5 1 Frequency Distribution of Image ID 2 12 10 8 Frequency 0 0 0 0 3 6 14 21 24 25 44 46 50 52 53 59 64 69 70 79 97 6 4 2 0 0-29 30-74 75-100 Frequency Range Frequency Distribution of Image ID 3 16 14 12 Frequency Image 2 Scores 10 8 6 4 2 0 0-29 30-74 Frequency Range 80 75-100 Image 5 Scores 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 5 5 6 27 29 55 0-29 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 17 0-29 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 20 30-74 75-100 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 1 0 1 0 4 0 30-74 75-100 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 Frequency Distribution of Image ID 4 18 16 14 12 Frequency 0 0 0 0 0 0 0 0 0 0 0 7 10 11 17 20 23 42 52 58 69 10 8 6 4 2 0 0-29 30-74 75-100 Frequency Range Frequency Distribution of Image ID 5 25 20 Frequency Image 4 Scores 15 10 5 0 0-29 30-74 Frequency Range 81 75-100 Image 7 Scores 0 0 0 0 0 0 0 0 0 5 7 10 10 12 12 14 15 17 45 73 93 0-29 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 20 0-29 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 18 30-74 75-100 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 30-74 75-100 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 0 1 2 1 Frequency Distribution of Image ID 6 25 20 Frequency 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 5 7 13 27 72 15 10 5 0 0-29 30-74 75-100 Frequency Range Frequency Distribution of Image ID 7 20 18 16 14 Frequency Image 6 Scores 12 10 8 6 4 2 0 0-29 30-74 Frequency Range 82 75-100 Image 9 Scores 0 0 0 0 0 6 9 10 12 20 33 34 35 37 39 40 46 60 65 78 83 0-29 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 19 0-29 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 10 30-74 75-100 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 2 0 30-74 75-100 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 0 1 0 1 9 2 Frequency Distribution of Image ID 8 20 18 16 14 Frequency 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 10 31 36 12 10 8 6 4 2 0 0-29 30-74 75-100 Frequency Range Frequency Distribution of Image ID 9 12 10 8 Frequency Image 8 Scores 6 4 2 0 0-29 30-74 Frequency Range 83 75-100 Image 11 Scores 65 76 80 83 93 93 95 95 96 98 99 100 100 100 100 100 100 100 100 100 100 0-29 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 30-74 75-100 0 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 8 12 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 30-74 75-100 1 0 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 1 20 Frequency Distribution of Image ID 10 14 12 10 Frequency 0-29 8 6 4 2 0 0-29 30-74 75-100 Frequency Range Frequency Distribution of Image ID 11 25 20 Frequency Image 10 Scores 16 38 42 49 61 65 71 71 72 82 84 86 88 94 95 100 100 100 100 100 100 15 10 5 0 0-29 30-74 Frequency Range 84 75-100 Image 13 Scores 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 13 0-29 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 21 30-74 75-100 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 0 1 7 1 30-74 75-100 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Frequency Distribution of Image ID 12 14 12 10 Frequency 0-29 0 0 0 0 0 5 10 13 14 20 24 25 27 33 40 47 51 60 70 72 83 8 6 4 2 0 0-29 30-74 75-100 Frequency Range Frequency Distribution of Image ID 13 25 20 Frequency Image 12 Scores 15 10 5 0 0-29 30-74 Frequency Range 85 75-100 Image 15 Scores 0 0 0 0 0 0 1 6 20 20 20 24 27 27 30 33 38 40 42 56 100 0-29 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 10 0-29 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 14 30-74 75-100 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 0 1 0 1 9 2 30-74 75-100 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 1 0 1 0 1 0 1 0 0 1 6 1 Frequency Distribution of Image ID 14 12 10 8 Frequency 0 0 1 11 12 12 16 17 25 26 31 31 46 50 50 52 61 65 71 79 86 6 4 2 0 0-29 30-74 75-100 Frequency Range Frequency Distribution of Image ID 15 16 14 12 Frequency Image 14 Scores 10 8 6 4 2 0 0-29 30-74 Frequency Range 86 75-100 Image 17 Scores 0 10 13 18 20 22 24 25 27 30 30 31 35 40 48 52 54 64 71 82 92 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 30-74 75-100 0 0 0 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 0 1 0 1 0 1 0 1 15 4 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 9 30-74 75-100 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 0 1 0 1 10 2 0-29 Frequency Distribution of Image ID 16 16 14 12 Frequency 0-29 6 25 33 48 48 50 50 50 51 54 58 58 59 59 60 61 62 82 87 91 100 10 8 6 4 2 0 0-29 30-74 75-100 Frequency Range Frequency Distribution of Image ID 17 12 10 8 Frequency Image 16 Scores 6 4 2 0 0-29 30-74 Frequency Range 87 75-100 Image 19 Scores 3 8 10 21 27 31 39 39 41 46 48 50 57 60 61 61 67 72 80 82 100 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 21 0-29 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 5 30-74 75-100 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 30-74 75-100 0 0 0 0 0 0 0 0 0 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 0 1 0 1 0 1 13 3 Frequency Distribution of Image ID 18 25 20 Frequency 0-29 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 8 15 10 5 0 0-29 30-74 75-100 Frequency Range Frequency Distribution of Image ID 19 14 12 10 Frequency Image 18 Scores 8 6 4 2 0 0-29 30-74 Frequency Range 88 75-100 Image 21 Scores 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 3 11 0-29 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 11 0-29 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 21 30-74 75-100 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 0 1 9 1 30-74 75-100 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Frequency Distribution of Image ID 20 12 10 8 Frequency 0 0 0 0 5 10 10 17 17 21 22 34 39 41 47 48 50 54 58 60 93 6 4 2 0 0-29 30-74 75-100 Frequency Range Frequency Distribution of Image ID 21 25 20 Frequency Image 20 Scores 15 10 5 0 0-29 30-74 Frequency Range 89 75-100 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 3 30-74 75-100 0 0 0 0 0 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 10 8 Image 23 Scores 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 22 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 21 30-74 75-100 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0-29 Frequency Distribution of Image ID 22 12 10 8 Frequency 0-29 6 10 24 30 31 33 46 50 58 59 67 69 71 78 79 80 80 88 93 100 100 6 4 2 0 0-29 30-74 75-100 Frequency Range Frequency Distribution of Image ID 23 25 20 Frequency Image 22 Scores 15 10 5 0 0-29 30-74 Frequency Range 90 75-100 Image 25 Scores 0-29 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 5 16 24 56 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 30-74 75-100 0 0 0 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 7 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 20 30-74 75-100 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 Frequency Distribution of Image ID 24 14 12 10 Frequency 0-29 8 6 4 2 0 0-29 30-74 75-100 Frequency Range Frequency Distribution of Image ID 25 25 20 Frequency Image 24 Scores 14 27 30 34 44 65 66 67 73 75 75 76 76 77 84 86 100 100 100 100 100 15 10 5 0 0-29 30-74 Frequency Range 91 75-100 Image 27 Scores 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 10 15 29 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 21 0-29 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 21 30-74 75-100 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 30-74 75-100 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Frequency Distribution of Image ID 26 25 20 Frequency 0-29 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 7 15 10 5 0 0-29 30-74 75-100 Frequency Range Frequency Distribution of Image ID 27 25 20 Frequency Image 26 Scores 15 10 5 0 0-29 30-74 Frequency Range 92 75-100 Image 29 Scores 9 12 14 16 22 24 30 31 34 36 41 45 54 57 57 57 57 63 65 69 71 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 21 0-29 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 30-74 75-100 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 30-74 75-100 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 15 0 Frequency Distribution of Image ID 28 25 20 Frequency 0-29 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 15 10 5 0 0-29 30-74 75-100 Frequency Range Frequency Distribution of Image ID 29 16 14 12 Frequency Image 28 Scores 10 8 6 4 2 0 0-29 30-74 Frequency Range 93 75-100 Image 31 Scores 0 0 0 16 18 27 29 46 49 50 51 63 63 66 66 69 76 80 100 100 100 0-29 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 19 0-29 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 7 30-74 75-100 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 2 0 30-74 75-100 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 0 1 0 1 0 1 0 1 0 1 9 5 Frequency Distribution of Image ID 30 20 18 16 14 Frequency 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 15 52 71 12 10 8 6 4 2 0 0-29 30-74 75-100 Frequency Range Frequency Distribution of Image ID 31 10 9 8 7 Frequency Image 30 Scores 6 5 4 3 2 1 0 0-29 30-74 Frequency Range 94 75-100 Image 33 Scores 0 0 0 0 0 0 14 16 20 25 30 33 42 50 56 56 67 69 73 90 95 0-29 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 20 0-29 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 10 30-74 75-100 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 30-74 75-100 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 0 1 0 1 9 2 Frequency Distribution of Image ID 32 25 20 Frequency 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 11 35 15 10 5 0 0-29 30-74 75-100 Frequency Range Frequency Distribution of Image ID 33 12 10 8 Frequency Image 32 Scores 6 4 2 0 0-29 30-74 Frequency Range 95 75-100 Image 35 Scores 0 0 32 39 40 49 50 61 62 63 87 90 95 99 100 100 100 100 100 100 100 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 30-74 75-100 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 1 0 1 0 1 0 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 5 10 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 30-74 75-100 0 0 0 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 8 11 0-29 Frequency Distribution of Image ID 34 12 10 8 Frequency 0-29 0 0 13 23 23 25 31 37 50 50 58 87 88 94 94 100 100 100 100 100 100 6 4 2 0 0-29 30-74 75-100 Frequency Range Frequency Distribution of Image ID 35 12 10 8 Frequency Image 34 Scores 6 4 2 0 0-29 30-74 Frequency Range 96 75-100 Image 37 Scores 33 46 54 59 60 62 65 69 71 73 73 84 85 88 93 98 100 100 100 100 100 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 30-74 75-100 0 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 8 12 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 30-74 75-100 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 11 10 0-29 Frequency Distribution of Image ID 36 14 12 10 Frequency 0-29 0 30 33 39 48 50 52 59 70 76 84 86 92 92 98 98 100 100 100 100 100 8 6 4 2 0 0-29 30-74 75-100 Frequency Range Frequency Distribution of Image ID 37 12 10 8 Frequency Image 36 Scores 6 4 2 0 0-29 30-74 Frequency Range 97 75-100 Image 39 Scores 0-29 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 12 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 30-74 75-100 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 10 11 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 21 30-74 75-100 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Frequency Distribution of Image ID 38 12 10 8 Frequency 0-29 6 4 2 0 0-29 30-74 75-100 Frequency Range Frequency Distribution of Image ID 39 25 20 Frequency Image 38 Scores 39 40 53 56 64 67 67 70 73 73 82 93 94 95 99 100 100 100 100 100 100 15 10 5 0 0-29 30-74 Frequency Range 98 75-100 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 7 13 26 45 0-29 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 20 30-74 75-100 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 Frequency Distribution of Image ID 40 25 20 Frequency Image 40 Scores 15 10 5 0 0-29 30-74 Frequency Range 99 75-100 Membership Value Construction by Random Method Membership Value Construction by Direct Rating User's ID Color Weight Modifier Satisfaction % 1 Blue 0.25 Slightly Blue 67 2 Blue 0.22 Slightly Blue 27 3 Blue 0.45 Medium Blue 40 4 Blue 0.74 Medium Blue 40 5 Blue 0.2 Slightly Blue 13 6 Blue 0.68 Medium Blue 7 7 Blue 0.2 Slightly Blue 27 8 Blue 0.2 Slightly Blue 7 9 Blue 0.84 Very Blue 27 10 Blue 0.87 Very Blue 67 11 Blue 0.61 Medium Blue 53 12 Blue 0.2 Slightly Blue 33 13 Blue 0.72 Medium Blue 0 14 Blue 0.2 Slightly Blue 7 15 Blue 0.2 Slightly Blue 47 16 Blue 0.86 Very Blue 33 17 Blue 0.22 Slightly Blue 13 18 Blue 0.2 Slightly Blue 0 19 Blue 0.53 Medium Blue 67 20 Blue 0.52 Medium Blue 53 21 Blue 0.39 Medium Blue 0 22 Blue 0.22 Slightly Blue 80 23 Blue 0.51 Medium Blue 0 24 Blue 0.87 Very Blue 73 25 Blue 0.52 Medium Blue 0 26 Blue 0.74 Very Blue 0 27 Blue 0.2 Slightly Blue 0 28 Blue 0.75 Very Blue 7 29 Blue 0.2 Slightly Blue 44 30 Blue 0.2 Slightly Blue 13 31 Blue 0.87 Very Blue 60 32 Blue 0.2 Slightly Blue 0 33 Blue 0.52 Medium Blue 53 34 Blue 0.53 Medium Blue 73 35 Blue 0.87 Very Blue 100 36 Blue 0.54 Medium Blue 93 37 Blue 0.64 Medium Blue 73 38 Blue 0.54 Medium Blue 53 39 Blue 0.39 Medium Blue 0 40 Blue 0.2 Slightly Blue 7 ID 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 100 User's Satisfaction % Color Weight Modifier Blue 0.52 Medium Blue 89 Blue 0.2 Slightly Blue 56 Blue 0.2 Slightly Blue 44 Blue 0.2 Slightly Blue 37 Blue 0.2 Slightly Blue 4 Blue 0.2 Slightly Blue 7 Blue 0.2 Slightly Blue 44 Blue 0.2 Slightly Blue 7 Blue 0.2 Slightly Blue 70 Blue 0.87 Very Blue 67 Blue 0.87 Very Blue 81 Blue 0.2 Slightly Blue 48 Blue 0.2 Slightly Blue 4 Blue 0.2 Slightly Blue 52 Blue 0.2 Slightly Blue 26 Blue 0.52 Medium Blue 78 Blue 0.52 Medium Blue 41 Blue 0.2 Slightly Blue 4 Blue 0.52 Medium Blue 48 Blue 0.2 Slightly Blue 52 Blue 0.2 Slightly Blue 4 Blue 0.52 Medium Blue 93 Blue 0.2 Slightly Blue 4 Blue 0.87 Very Blue 63 Blue 0.2 Slightly Blue 11 Blue 0.2 Slightly Blue 4 Blue 0.2 Slightly Blue 11 Blue 0.2 Slightly Blue 15 Blue 0.52 Medium Blue 67 Blue 0.2 Slightly Blue 15 Blue 0.52 Medium Blue 96 Blue 0.2 Slightly Blue 4 Blue 0.2 Slightly Blue 44 Blue 0.87 Very Blue 89 Blue 0.87 Very Blue 93 Blue 0.87 Very Blue 89 Blue 0.52 Medium Blue 93 Blue 0.87 Very Blue 78 Blue 0.2 Slightly Blue 4 Blue 0.2 Slightly Blue 4 Appendix D Instructions to install the Fuzzy Database Research on the Local Machine 1) Install VB.NET 2) Install SQL Server Note: Order does not matter 3) Install the folder called Fuzzy Research The contents of this folder are as follows: Folder DB: Contains the VB.NET code for our application. One will have to install VB.NET to be able to view or modify the code. Folder TestDeploy : Contains the executable for our application. In order to install the application go to the subfolder Debug and double click on the windows installer program "TestDeploy StoredProcedures.doc: Contains all the stored procedures currently being used by the application To install database in SQL Sever, there will be one of the following file/ files: o DATABASE_BACKUP_SEPT162004: Contains a backup of the database. o DBResearch.mdf and DBResearch_log.LDF 4) Create two files called input.txt and input1.txt in the directory C:\ 1) Input.txt contains the sql statement to be generated by NLI. For example select * from person where color.color = 'blue'; 2) Input1.txt contains the fuzzy modifier which is also generated by NLI. It should have the format of 'fuzzy modifier' crlf 'attribute to be modified'. For Example medium blue 5) Depending upon type of database file present in the database, restoring the database into SQL Server will require following steps: o Restore the database backup called DATABASE_BACKUP_SEPT162004 which is in Folder, onto SQL Server where Database name: DBResearch using the Enterprise Manager instructions titled "How to restore a backup from a backup device". o Restore the database using DBResearch.mdf and DBResearch_log.LDF file which is in the folder in the SQL Server Enterprise. Go to the databases tab. Right click onto databases. Under All Tasks menu, choose Attach Database. 101 Select the DBResearch.mdf file in the MDF file of database to attach text box. Press ok. Under databases tab, DBResearch database will appear 6) In SQL Server Enterprise Manager, click on the databases. Then go tools menu. Choose SQL Server Configuration Properties. In the security tab, choose option SQL Server and Windows Authentication 7) In SQL Server Enterprise, expand security. In login, Choose new login. In general tab, name = dbresearch, choose SQL Server authentication, password: dbresearch, choose database called DBResearch. In Data Access tab, click DBResearch and permit public and db_owner 8) Setup ODBC in Administrator Tools of the Control Panel. Use Windows Authorization. 9) Change the data source indicated in Public Class Form1 on line 116 to the name of local machine which can be found out by going to properties of my computer. Compile the project to see results. 102