Click here to Skip to main content
15,885,244 members
Articles / Desktop Programming / Win32

Fuzzy Ontology Framework

Rate me:
Please Sign up or sign in to vote.
4.92/5 (12 votes)
17 Mar 2012CPOL19 min read 66.8K   7.4K   37  
Integration of fuzzy OWL ontology modelling with .NET
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using FuzzyFramework.Dimensions;
using FuzzyFramework.Sets;

namespace AWQuery
{
    public class SalesPerson
    {
        //see http://mosesofegypt.net/post/2008/08/31/LINQ-to-Entities-Workarounds-on-what-is-not-supported.aspx
        //on why only a parameterless constructor can be used together with Linq to Entities.
        internal string firstName;
        internal string middleName;
        internal string lastName;
        internal string title;
        internal decimal salesLastYear;
        internal decimal commissionPct;


        #region Dimensions used for attributes of this class
        internal static IContinuousDimension commission = new ContinuousDimension("Commission", "Percentage to be paid to the salesman as a commission", "[0-1]", 0, 1);
        internal static IContinuousDimension sales = new ContinuousDimension("Sales", "Amount of sales the salesman managed to gain.", "$", 0, 10000000);
        #endregion

        #region Sets used for attributes of this class
        internal static FuzzySet lowCommission = new RightLinearSet(commission, "Low Commission", 0.01m, 0.02m);
        internal static FuzzySet highSales = new LeftLinearSet(sales, "High Sales", 1000000, 2000000);
        #endregion

        internal SalesPerson()
        {
        }

        public string Name
        {
            get
            {
                return System.Text.RegularExpressions.Regex.Replace(
                    String.Format("{0} {1} {2}", firstName, middleName, lastName),
                    "[^a-zA-Z0-9]",
                    ""
                );
            }
        }

        public decimal SalesLastYear
        {
            get { return salesLastYear; }
        }

        public decimal CommissionPct
        {
            get { return commissionPct; }
        }

        #region Ad-hoc class attributes
        public double CheapSalesPerson
        {
            get
            {
                return lowCommission.IsMember(this.CommissionPct);
            }
        }

        public double CapableSalesPerson
        {
            get
            {
                return highSales.IsMember(this.SalesLastYear);
            }
        }


        public Nullable<double> CapableAndCheapSalesPerson
        {
            get
            {
                    return Math.Min(this.CheapSalesPerson, this.CapableSalesPerson);
            }
        }
        #endregion
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Student
Czech Republic Czech Republic
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions