private List <IFCData> FilerReplaceData(List <IFCData> allIFCRow) { allIFCRow = allIFCRow.OrderBy(o => o.Properties).ToList(); List <string> redundID = new List <string>(); //被替換之P21ID List <IFCData> combainData = new List <IFCData>(); for (int i = 0; i < allIFCRow.Count; i++) { IFCData nowData = allIFCRow[i]; if (redundID.Contains(nowData.P21Id)) //已被取代之IFC資料不處理 { continue; } combainData.Add(nowData); for (int j = i + 1; j < allIFCRow.Count; j++) { if (nowData.Properties == allIFCRow[j].Properties) { ReplaceTable.Add(new IFCReplaceRecord(allIFCRow[j].P21Id, nowData.P21Id)); //被替換者-保留者 redundID.Add(allIFCRow[j].P21Id); } else { break; } } } return(combainData); }
private void CreateIndex() { IFCModel.EnsureIndex(x => x["P21Id"]); IFCModel.EnsureIndex(x => x["EntityName"]); IFCModel.EnsureIndex(x => x["GlobalId"]); ReplaceTable.EnsureIndex(x => x.KeyElement); ReplaceTable.EnsureIndex(x => x.ValueElement); InverseTable.EnsureIndex(x => x.KeyElement); }
public IFCObject GetObjectByP21Id(string p21Id) { IFCReplaceRecord replace = ReplaceTable.FindOne(x => x.KeyElement == p21Id); if (replace == null) //不是被取代的P21Id { return(new IFCObject(IFCModel.FindOne(x => x["P21Id"] == p21Id))); } else //須找到取代的資料 { IFCObject obj = new IFCObject(IFCModel.FindOne(x => x["P21Id"] == replace.ValueElement)); obj.P21Id = p21Id; return(obj); } }
/// <summary> /// 翻訳テーブル読み込み /// </summary> public void LoadProperNounTable() { string fileName = Common.File.CombinePath(Common.File.GetApplicationDirectory(), ProperNounTableFileName); if (!Common.File.ExistsFile(fileName)) { //ファイル見つからない return; } //コメント削除用 var regexComment = new Regex(@"#.*$", RegexOptions.IgnoreCase); //DirectoryName用 var regexDirectoryName = new Regex(@"^\[(.*?)\]", RegexOptions.IgnoreCase); //テキスト用 var regexText = new Regex(@"^([^\t]*)\t([^\t]*)$", RegexOptions.IgnoreCase); var regexTextNoTab = new Regex(@"^([^\t]*)($|\t)", RegexOptions.IgnoreCase); System.Text.RegularExpressions.MatchCollection mc; string nowDirectoryName = ""; this.ReplaceTableListMaxID = 0; //ファイルの解析 using (var sr = new System.IO.StreamReader(fileName, System.Text.Encoding.UTF8)) { while (sr.Peek() > -1) { //1行データ string lineText = sr.ReadLine(); //コメント削除 lineText = regexComment.Replace(lineText, ""); //前後の空白取り除き lineText = lineText.Trim(); if (lineText.Equals("")) { //データなければ次の行へ continue; } //DirectoryName用 mc = regexDirectoryName.Matches(lineText); if (mc.Count >= 1) { nowDirectoryName = mc[0].Groups[1].Value; continue; } //テキスト用 mc = regexText.Matches(lineText); if (mc.Count >= 1) { var replaceTable = new ReplaceTable(); replaceTable.ID = this.ReplaceTableListMaxID++; replaceTable.DirectoryName = nowDirectoryName; replaceTable.OriginalText = mc[0].Groups[1].Value; replaceTable.ReplaceText = mc[0].Groups[2].Value; this.ReplaceTableList.Add(replaceTable); continue; } //テキスト用(タブなし) mc = regexTextNoTab.Matches(lineText); if (mc.Count >= 1) { var replaceTable = new ReplaceTable(); replaceTable.ID = this.ReplaceTableListMaxID++; replaceTable.DirectoryName = nowDirectoryName; replaceTable.OriginalText = mc[0].Groups[1].Value; replaceTable.ReplaceText = replaceTable.OriginalText; this.ReplaceTableList.Add(replaceTable); continue; } } //閉じる sr.Close(); } //文字の長い順でソートする this.ReplaceTableList.Sort(CompareByTextLength); }
/// <summary> /// 名詞部分をダミーのテキストに置換 /// </summary> /// <param name="orgText"></param> /// <returns></returns> public string ReplaceDummyText(string directoryName, string orgText, DataType dataType) { var replaceText = new StringBuilder(); replaceText.Append(orgText); if (dataType == DataType.StoryDefs) { //StoryDefsの場合 var regexStoryDefs = new Regex(@"(\[.+?\])"); System.Text.RegularExpressions.MatchCollection mc = regexStoryDefs.Matches(replaceText.ToString()); if (mc.Count >= 1) { foreach (Match item in mc) { var replaceTable = new ReplaceTable(); replaceTable.ID = this.ReplaceTableListMaxID++; replaceTable.DirectoryName = directoryName; replaceTable.OriginalText = item.Groups[1].Value; replaceTable.ReplaceText = replaceTable.OriginalText; this.ReplaceTableList.Add(replaceTable); } //文字の長い順でソートする this.ReplaceTableList.Sort(CompareByTextLength); } } foreach (var replaceTable in this.ReplaceTableList) { if (replaceTable.DirectoryName == "" || replaceTable.DirectoryName == directoryName) { var regexReplace = new Regex(@"(^|\s*|"")" + "(" + this.escapeText(replaceTable.OriginalText) + ")" + @"($|\s|""|,|\.|\?|\!)"); System.Text.RegularExpressions.MatchCollection mc = regexReplace.Matches(replaceText.ToString()); if (mc.Count >= 1) { string checkText = replaceText.ToString(); replaceText.Clear(); int lastIndex = 0; foreach (Match item in mc) { replaceText.Append(checkText.Substring(lastIndex, item.Index - lastIndex)); replaceText.Append(item.Groups[1].Value); //前部分 replaceText.Append(replaceTable.IDText); //ID埋め込み replaceText.Append(item.Groups[3].Value); //後ろ部分 lastIndex = item.Index + item.Length; } replaceText.Append(checkText.Substring(lastIndex)); } } } return(replaceText.ToString()); }
/// <summary> /// 文字長い順でソート /// </summary> /// <param name="a"></param> /// <param name="b"></param> /// <returns></returns> private static int CompareByTextLength(ReplaceTable a, ReplaceTable b) { return(b.OriginalText.Length - a.OriginalText.Length); }
/// <summary> /// 翻訳テーブル読み込み /// </summary> public void LoadProperNounTable() { string fileName = Common.File.CombinePath (Common.File.GetApplicationDirectory(), ProperNounTableFileName); if ( !Common.File.ExistsFile( fileName ) ) { //ファイル見つからない return; } //コメント削除用 var regexComment = new Regex( @"#.*$" , RegexOptions.IgnoreCase ); //DirectoryName用 var regexDirectoryName = new Regex( @"^\[(.*?)\]" , RegexOptions.IgnoreCase ); //テキスト用 var regexText = new Regex( @"^([^\t]*)\t([^\t]*)$" , RegexOptions.IgnoreCase ); var regexTextNoTab = new Regex( @"^([^\t]*)($|\t)" , RegexOptions.IgnoreCase ); System.Text.RegularExpressions.MatchCollection mc; string nowDirectoryName = ""; this.ReplaceTableListMaxID = 0; //ファイルの解析 using ( var sr = new System.IO.StreamReader( fileName , System.Text.Encoding.UTF8 ) ) { while ( sr.Peek() > -1 ) { //1行データ string lineText = sr.ReadLine(); //コメント削除 lineText = regexComment.Replace( lineText , "" ); //前後の空白取り除き lineText = lineText.Trim(); if ( lineText.Equals( "" ) ) { //データなければ次の行へ continue; } //DirectoryName用 mc = regexDirectoryName.Matches( lineText ); if ( mc.Count >= 1 ) { nowDirectoryName = mc[0].Groups[1].Value; continue; } //テキスト用 mc = regexText.Matches( lineText ); if ( mc.Count >= 1 ) { var replaceTable = new ReplaceTable(); replaceTable.ID = this.ReplaceTableListMaxID++; replaceTable.DirectoryName = nowDirectoryName; replaceTable.OriginalText = mc[0].Groups[1].Value; replaceTable.ReplaceText = mc[0].Groups[2].Value; this.ReplaceTableList.Add( replaceTable ); continue; } //テキスト用(タブなし) mc = regexTextNoTab.Matches( lineText ); if ( mc.Count >= 1 ) { var replaceTable = new ReplaceTable(); replaceTable.ID = this.ReplaceTableListMaxID++; replaceTable.DirectoryName = nowDirectoryName; replaceTable.OriginalText = mc[0].Groups[1].Value; replaceTable.ReplaceText = replaceTable.OriginalText; this.ReplaceTableList.Add( replaceTable ); continue; } } //閉じる sr.Close(); } //文字の長い順でソートする this.ReplaceTableList.Sort( CompareByTextLength ); }
/// <summary> /// 文字長い順でソート /// </summary> /// <param name="a"></param> /// <param name="b"></param> /// <returns></returns> private static int CompareByTextLength( ReplaceTable a , ReplaceTable b ) { return b.OriginalText.Length - a.OriginalText.Length; }
/// <summary> /// 名詞部分をダミーのテキストに置換 /// </summary> /// <param name="orgText"></param> /// <returns></returns> public string ReplaceDummyText( string directoryName , string orgText , DataType dataType ) { var replaceText = new StringBuilder(); replaceText.Append( orgText ); if ( dataType == DataType.StoryDefs ) { //StoryDefsの場合 var regexStoryDefs = new Regex( @"(\[.+?\])" ); System.Text.RegularExpressions.MatchCollection mc = regexStoryDefs.Matches( replaceText.ToString() ); if ( mc.Count >= 1 ) { foreach ( Match item in mc ) { var replaceTable = new ReplaceTable(); replaceTable.ID = this.ReplaceTableListMaxID++; replaceTable.DirectoryName = directoryName; replaceTable.OriginalText = item.Groups[1].Value; replaceTable.ReplaceText = replaceTable.OriginalText; this.ReplaceTableList.Add( replaceTable ); } //文字の長い順でソートする this.ReplaceTableList.Sort( CompareByTextLength ); } } foreach ( var replaceTable in this.ReplaceTableList ) { if ( replaceTable.DirectoryName == "" || replaceTable.DirectoryName == directoryName ) { var regexReplace = new Regex( @"(^|\s*|"")" + "(" + this.escapeText(replaceTable.OriginalText) + ")" + @"($|\s|""|,|\.|\?|\!)" ); System.Text.RegularExpressions.MatchCollection mc = regexReplace.Matches( replaceText.ToString() ); if ( mc.Count >= 1 ) { string checkText = replaceText.ToString(); replaceText.Clear(); int lastIndex = 0; foreach ( Match item in mc ) { replaceText.Append( checkText.Substring( lastIndex , item.Index - lastIndex ) ); replaceText.Append( item.Groups[1].Value );//前部分 replaceText.Append( replaceTable.IDText );//ID埋め込み replaceText.Append( item.Groups[3].Value );//後ろ部分 lastIndex = item.Index + item.Length; } replaceText.Append( checkText.Substring( lastIndex ) ); } } } return replaceText.ToString(); }
public ObjectOutputStream(OutputStream @out) { //verifySubclass(); bout = new BlockDataOutputStream(@out); handles = new HandleTable(10, (float) 3.00); subs = new ReplaceTable(10, (float) 3.00); enableOverride = false; writeStreamHeader(); bout.setBlockDataMode(true); //if (extendedDebugInfo) { // debugInfoStack = new DebugTraceInfoStack(); //} else { // debugInfoStack = null; //} }
protected ObjectOutputStream() { //SecurityManager sm = System.getSecurityManager(); //if (sm != null) { // sm.checkPermission(SUBCLASS_IMPLEMENTATION_PERMISSION); //} bout = null; handles = null; subs = null; enableOverride = true; //debugInfoStack = null; }