public HardThreshold(Enums.MediaType MediaType, Enums.Language Language) { this.MediaType = MediaType; this.Language = Language; this.LevelUpCelling_TitleABasePattern = 15; this.LevelUpCelling_TitleAAncestorPattern = 8; this.Relthreshold = 0.05;//rel打分时低于此值的统一无视,记为零分 this.itemclimb = 10; this.itempageminvalidvalue = 3; this.itempagemaxvalue = 5; this.ListSave = 5; this.ItemSave = 1 / 3; this.MaxDateLength = 50; this.List_MinCountItem = 3; this.LeastTitleScore = 200; }
public ListStrategy(Enums.MediaType MediaType, Enums.Language Language) { this.MediaType = MediaType; this.Language = Language; switch (MediaType) { default: case Enums.MediaType.WebNews: List_IgnoreOrderNumber_UpLevel_Init = 1; List_BestItemCount = 20; List_MinAvgTitleLen = Language == Enums.Language.CHINESE ? 4.9 : 10; List_BestAvgTitleLen = Language == Enums.Language.CHINESE ? 18 : 70; List_BestAvgMediaLen = Language == Enums.Language.CHINESE ? 4 : 12; List_BestAvgAuthorLen = Language == Enums.Language.CHINESE ? 3 : 15; List_CombinSiblingPattern_MaxUpLevel = 2; break; case Enums.MediaType.Forum: List_IgnoreOrderNumber_UpLevel_Init = 1; List_BestItemCount = 40; List_MinAvgTitleLen = Language == Enums.Language.CHINESE ? 7 : 12; List_BestAvgTitleLen = Language == Enums.Language.CHINESE ? 16 : 60; List_BestAvgMediaLen = Language == Enums.Language.CHINESE ? 4 : 12; List_BestAvgAuthorLen = Language == Enums.Language.CHINESE ? 6 : 17; List_CombinSiblingPattern_MaxUpLevel = 2; break; case Enums.MediaType.FrontPage: List_IgnoreOrderNumber_UpLevel_Init = 1; List_BestItemCount = 10; List_MinAvgTitleLen = Language == Enums.Language.CHINESE ? 7 : 12; List_BestAvgTitleLen = Language == Enums.Language.CHINESE ? 12 : 70; List_BestAvgMediaLen = Language == Enums.Language.CHINESE ? 4 : 12; List_BestAvgAuthorLen = Language == Enums.Language.CHINESE ? 4 : 17; List_CombinSiblingPattern_MaxUpLevel = 2; break; } this.FieldScore = new FieldScoreStrategy(MediaType, Language); }
public FieldScoreStrategy(Enums.MediaType MediaType, Enums.Language Language) { }
private void Initialize(string Path) { this._id = Guid.NewGuid (); this._createtimestamp = SNDK.Date.CurrentDateTimeToTimestamp (); this._updatetimestamp = SNDK.Date.CurrentDateTimeToTimestamp (); this._usergroups = new List<Usergroup> (); this._path = FixPath (Path); this._mimetype = string.Empty; this._size = 0; this._description = string.Empty; this._copyright = string.Empty; this._type = SorentoLib.Enums.MediaType.Temporary; this._temppath = FixPath (Path); this._temptype = SorentoLib.Enums.MediaType.Temporary; }
public void Update() { // Check if data still exists. if (!File.Exists (this.DataPath)) { // EXCEPTION: Exception.MediaSaveData throw new Exception (string.Format (Strings.Exception.MediaSaveData, this._id)); } if (this._type != this._temptype) { string source = string.Empty; string destination = string.Empty; switch (this._type) { case Enums.MediaType.Temporary: { source = Services.Config.Get<string> (Enums.ConfigKey.path_temp); break; } case Enums.MediaType.TemporaryPublic: { source = Services.Config.Get<string> (Enums.ConfigKey.path_temp); break; } case Enums.MediaType.Public: { source = Services.Config.Get<string> (Enums.ConfigKey.path_media); break; } case Enums.MediaType.Restricted: { source = Services.Config.Get<string> (Enums.ConfigKey.path_media); break; } } switch (this._temptype) { case Enums.MediaType.Temporary: { destination = Services.Config.Get<string> (Enums.ConfigKey.path_temp); break; } case Enums.MediaType.TemporaryPublic: { destination = Services.Config.Get<string> (Enums.ConfigKey.path_temp); break; } case Enums.MediaType.Public: { destination = Services.Config.Get<string> (Enums.ConfigKey.path_media); break; } case Enums.MediaType.Restricted: { destination = Services.Config.Get<string> (Enums.ConfigKey.path_media); break; } } if ((this._path != this._temppath) || (this._type != this._temptype)) { // Remove old symlink if needed. if ((this._type == Enums.MediaType.Public) || (this._type == Enums.MediaType.TemporaryPublic)) { File.Delete (Services.Config.Get<string> (Enums.ConfigKey.path_publicmedia) + this._path); } } if (source != destination) { FileInfo file = new FileInfo (source + this._id); file.MoveTo (destination + this._id); } } this._path = this._temppath; this._type = this._temptype; // Create new symlink if needed. if ((this._temptype == Enums.MediaType.Public) || (this._temptype == Enums.MediaType.TemporaryPublic)) { // Check if path exists, if not create it. if (!System.IO.Directory.Exists (Services.Config.Get<string> (Enums.ConfigKey.path_publicmedia) + System.IO.Path.GetDirectoryName (this._temppath))) { System.IO.Directory.CreateDirectory (Services.Config.Get<string> (Enums.ConfigKey.path_publicmedia) + System.IO.Path.GetDirectoryName (this._temppath)); } // Create a new symlink. UnixFileInfo unixfileinfo = new UnixFileInfo (this.DataPath); unixfileinfo.CreateSymbolicLink (Services.Config.Get<string> (Enums.ConfigKey.path_publicmedia) + this._temppath); } string path = string.Empty; switch (this._type) { case Enums.MediaType.Temporary: { path = Services.Config.Get<string> (Enums.ConfigKey.path_temp); break; } case Enums.MediaType.TemporaryPublic: { path = Services.Config.Get<string> (Enums.ConfigKey.path_temp); break; } case Enums.MediaType.Public: { path = Services.Config.Get<string> (Enums.ConfigKey.path_media); break; } case Enums.MediaType.Restricted: { path = Services.Config.Get<string> (Enums.ConfigKey.path_media); break; } } // Get filesize FileInfo fileinfo = new FileInfo (path + this._id); this._size = fileinfo.Length; // Get mimetype this._mimetype = SNDK.IO.GetMimeType (path + this._id); }
private Media() { this._createtimestamp = 0; this._updatetimestamp = 0; this._path = string.Empty; this._mimetype = string.Empty; this._size = 0; this._description = string.Empty; this._copyright = string.Empty; this._type = SorentoLib.Enums.MediaType.Temporary; this._temppath = string.Empty; this._temptype = SorentoLib.Enums.MediaType.Temporary; }
/// <summary> /// 初始化函数 /// </summary> /// <param name="MediaType"></param> /// <param name="Language"></param> /// <param name="modelpath_title"></param> /// <param name="modelpath_rel"></param> /// <param name="stencilfeature"></param> public SoftStrategy(Enums.MediaType MediaType, Enums.Language Language) { this.MediaType = MediaType; this.Language = Language; this.model_title = Model.Read("SVMmodel/model_title_WebNews"); this.model_rel = Model.Read("SVMmodel/model_rel_WebNews"); //目前在用比较笨的方法来赋值,以后将直接调用文件资源对这些评分标准进行赋值 this.Threshold = new HardThreshold(MediaType, Language); #region stencil定义部分 string FileAdd = Path.Combine("Stencil"); if (File.Exists(FileAdd + "/Stencil_ListTitle")) { this.Stencil_ListTitle = (Feature)JsonConvert.DeserializeObject(File.ReadAllText(FileAdd + "/Stencil_ListTitle"), typeof(Feature)); } else { #region listTitle模版定义部分 this.Stencil_ListTitle = new Feature(1); Feature temp = new Feature(0); foreach (string key in temp.FigureFeatures.Keys) { if (key == "DateParseCount" || key == "AvgNumber" || key == "AvgDateDistance" || key == "DigitCountRate" || key == "DateCountRate") { this.Stencil_ListTitle.FigureFeatures[key] = 0; } } foreach (string key in temp.CharRecordf.Keys) { this.Stencil_ListTitle.CharRecordf[key] = 0; } foreach (string key in temp.CharRecords.Keys) { this.Stencil_ListTitle.CharRecords[key] = 0; } foreach (string key in temp.BoolFeatures.Keys) { this.Stencil_ListTitle.BoolFeatures[key] = 0; } #endregion listtitle模版定义部分 } if (File.Exists(FileAdd + "/Stencil_ListRel")) { this.Stencil_ListRel = (Feature)JsonConvert.DeserializeObject(File.ReadAllText(FileAdd + "/Stencil_ListRel"), typeof(Feature)); } else { #region listRel模版定义部分 this.Stencil_ListRel = new Feature(1); Feature temp = new Feature(0); foreach (string key in temp.FigureFeatures.Keys) { if (key == "DateParseCount" || key == "AvgNumber" || key == "AvgDateDistance" || key == "ItemCount" || key == "AvgDateDistance") { this.Stencil_ListRel.FigureFeatures[key] = 0; } } foreach (string key in temp.BoolFeatures.Keys) { this.Stencil_ListRel.BoolFeatures[key] = 0; } foreach (string key in temp.IdClassnameRecord.Keys) { this.Stencil_ListRel.IdClassnameRecord[key] = 0; } #endregion listRel模版定义部分 } if (File.Exists(FileAdd + "/Stencil_ItemContent")) { this.Stencil_ItemContent = (Feature)JsonConvert.DeserializeObject(File.ReadAllText(FileAdd + "/Stencil_ItemContent"), typeof(Feature)); } else { #region itemcontent模版定义部分 this.Stencil_ItemContent = new Feature(1); Feature temp = new Feature(0); foreach (string key in temp.FigureFeatures.Keys) { if (key == "AllTextLen") { this.Stencil_ItemContent.FigureFeatures[key] = 1; } else { this.Stencil_ItemContent.FigureFeatures[key] = 0; } } foreach (string key in temp.CharRecordf.Keys) { this.Stencil_ItemContent.CharRecordf[key] = 1; } foreach (string key in temp.CharRecords.Keys) { this.Stencil_ItemContent.CharRecords[key] = 1; } foreach (string key in temp.IdClassnameRecord.Keys) { this.Stencil_ItemContent.IdClassnameRecord[key] = 1; } foreach (string key in temp.BoolFeatures.Keys) { this.Stencil_ItemContent.BoolFeatures[key] = 0; } #endregion itemcontent模版定义部分 } if (File.Exists(FileAdd + "/Stencil_ItemOthers")) { this.Stencil_ItemOthers = (Feature)JsonConvert.DeserializeObject(File.ReadAllText(FileAdd + "/Stencil_ItemOthers"), typeof(Feature)); } else { #region itemcontent模版定义部分 this.Stencil_ItemOthers = new Feature(1); Feature temp = new Feature(0); foreach (string key in temp.FigureFeatures.Keys) { if (key == "AllTextLen" || key == "DateParseCount") { this.Stencil_ItemOthers.FigureFeatures[key] = 1; } else { this.Stencil_ItemOthers.FigureFeatures[key] = 0; } } foreach (string key in temp.CharRecordf.Keys) { this.Stencil_ItemOthers.CharRecordf[key] = 1; } foreach (string key in temp.CharRecords.Keys) { this.Stencil_ItemOthers.CharRecords[key] = 1; } foreach (string key in temp.IdClassnameRecord.Keys) { this.Stencil_ItemOthers.IdClassnameRecord[key] = 1; } foreach (string key in temp.BoolFeatures.Keys) { this.Stencil_ItemOthers.BoolFeatures[key] = 0; } #endregion itemcontent模版定义部分 } #endregion stencil定义部分 }