zoukankan      html  css  js  c++  java
  • Sql CLR

    using System;
    using System.Data;
    using System.Data.SqlClient;
    using System.Data.SqlTypes;
    using Microsoft.SqlServer.Server;
    using System.IO;
    using System.Text;
    using System.Collections;
    using System.Text.RegularExpressions;

    /// <summary>
    /// 匹配旅游线路多个关键词并获取权重。
    /// </summary>
    /// <param name="searchKeywords">客户端提交关键词(多个关键词之间以|号分隔)</param>
    /// <param name="title">旅游线路标题</param>
    /// <param name="dbKeywords">数据库中保存的搜索关键词(多个关键词之间以|号分隔)</param>
    /// <returns></returns>
    [Microsoft.SqlServer.Server.SqlFunction]
    public static SqlDouble fun_CLR_MatchTripKeywords(string searchKeywords, string title, string dbKeywords)
    {
    //如果没有关键词直接返回1。
    if (string.IsNullOrEmpty(searchKeywords))
    return 1;

    //如果没有索引数据直接返回0。
    if (string.IsNullOrEmpty(title) && string.IsNullOrEmpty(dbKeywords))
    return 0;

    //权重值。
    double boost = 0;

    //分割字符串。
    foreach (string _sk in searchKeywords.Split(new string[] { "|" }, StringSplitOptions.RemoveEmptyEntries))
    {
    //匹配标题。
    if (!string.IsNullOrEmpty(title) && title.IndexOf(_sk, StringComparison.OrdinalIgnoreCase) >= 0)
    boost += 1;

    //匹配数据库关键词字段。
    if (!string.IsNullOrEmpty(dbKeywords) && dbKeywords.IndexOf(_sk, StringComparison.OrdinalIgnoreCase) >= 0)
    boost += 0.8;
    }

    // 返回结果。
    return boost;
    }

  • 相关阅读:
    2018年第九届蓝桥杯国赛总结(JavaB组)
    yzm10的小简介
    论文学习笔记
    Tied Block Convolution:一种共享filter的卷积形态
    AI艺术鉴赏挑战赛
    论文学习笔记
    (转)论文学习笔记
    论文学习笔记
    2020 计蒜之道 预赛 第三场 石子游戏(简单)(暴力DP)
    第六周:生成式对抗网络
  • 原文地址:https://www.cnblogs.com/lxf1117/p/4984327.html
Copyright © 2011-2022 走看看