Exemplo n.º 1
0
        // Factory method
        public static RankingFeatureHelper Create(RankingFeature rankingFeature)
        {
            RankingFeatureHelper helper = null;

            if (rankingFeature is StaticRank)
            {
                helper = new StaticRankFeatureHelper((StaticRank)rankingFeature);
            }
            else if (rankingFeature is BucketedStatic)
            {
                helper = new BucketedStaticHelper((BucketedStatic)rankingFeature);
            }
            else if (rankingFeature is BM25)
            {
                helper = new BM25Helper((BM25)rankingFeature);
            }
            else if (rankingFeature is MinSpan)
            {
                helper = new MinSpanHelper((MinSpan)rankingFeature);
            }
            else if (rankingFeature is Dynamic)
            {
                helper = new DynamicHelper((Dynamic)rankingFeature);
            }
            else
            {
                throw new Exception("Unknown Ranking Feature type: " + rankingFeature.GetType().Name);
            }

            return(helper);
        }
Exemplo n.º 2
0
 public static IRankingFeatureFormatter SelectFormatter(RankingFeature rankFeature)
 {
     if (rankFeature is BM25)
     {
         return(new BM25Formatter((BM25)rankFeature));
     }
     else if (rankFeature is BucketedStatic)
     {
         return(new BucketedStaticFormatter((BucketedStatic)rankFeature));
     }
     else if (rankFeature is Dynamic)
     {
         return(new DynamicFeatureFormatter((Dynamic)rankFeature));
     }
     else if (rankFeature is StaticRank)
     {
         return(new StaticRankFormatter((StaticRank)rankFeature));
     }
     else if (rankFeature is MinSpan)
     {
         return(new MinSpanRankFormatter((MinSpan)rankFeature));
     }
     else
     {
         return(new NullRankingFeatureFormatter());
     }
 }