Ignore:
Timestamp:
Sep 8, 2009, 11:45:41 AM (12 years ago)
Author:
angelov
Message:

again with some statistic data files

Location:
trunk/CrypPlugins/MonoalphabeticAnalysis
Files:
2 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/CrypPlugins/MonoalphabeticAnalysis/MonoalphabeticAnalysis.cs

    r419 r476  
    4646        public int AlphabetCounterA = 1;
    4747        public int AlphabetcounterB = 1;
    48        
    49 
     48        public string PathToMonogramStatistics = "CrypPlugins/MonoalphabeticAnalysis_mo_en.txt";
     49        public string PathToDigramStatistics = "CrypPlugins/MonoalphabeticAnalysis_di_en.txt";
     50        private string alphabetCaseInsensitive = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
    5051
    5152
     
    173174            if (cipherTextFrequencyInput_Monograms != "")
    174175            {
    175                    //if Optional Statistical input not used -> use variables from pre-analysed Text (James Clavel's Shogun in our case) 
    176                 if (TextStatisticInput_Monograms == "") textStatisticInput_Monograms = ShogunStatistics.ShogunMonograms;
    177 
     176
     177               //File.WriteAllText("veriinterestingfilewithmonogramstatistic", textStatisticInput_Monograms);
     178               // File.WriteAllText("veriinterestingfilewithdigramstatistic", textStatisticInput_Digrams);
     179               
     180               // ImplementSettings();
     181                //if Optional Statistical input not used -> use variables from pre-analysed Text (James Clavel's Shogun in our case) 
     182                if (textStatisticInput_Monograms == "") textStatisticInput_Monograms = ShogunStatistics.ShogunMonograms;//File.ReadAllText(PathToMonogramStatistics);
     183                if (textStatisticInput_Digrams == "") textStatisticInput_Digrams = ShogunStatistics.ShogunDigrams;//File.ReadAllText(PathToDigramStatistics);
    178184
    179185                 if (GoodAlphabet == null) //first pass
     
    192198
    193199               
    194 
     200               
    195201                 if (GoodAlphabet != null && decipherAttempt_Digrams!="" && AlphabetcounterB < GoodAlphabet.Length)
    196202                 {
     
    286292        AlphabetCounterA = 1;
    287293        AlphabetcounterB = 1;
    288         
     294       
    289295            //throw new NotImplementedException();
    290296        }
     
    359365       public ArrayList InitialMapping(string cyString, string statString)
    360366        {
    361             if (textStatisticInput_Monograms == "") textStatisticInput_Monograms = ShogunStatistics.ShogunMonograms;
    362             ArrayList cipherTextFrequencies = ReturnSortedList(cyString, SortElements.SortElemetsBy.byFrequency);
    363             ArrayList statisticFrequencies = ReturnSortedList(statString, SortElements.SortElemetsBy.byFrequency);
     367            //if (textStatisticInput_Monograms == "") textStatisticInput_Monograms = ShogunStatistics.ShogunMonograms;
     368            ArrayList cipherTextFrequencies = ReturnSortedList(cyString.ToUpper(), SortElements.SortElemetsBy.byFrequency);
     369            ArrayList statisticFrequencies = ReturnSortedList(statString.ToUpper(), SortElements.SortElemetsBy.byFrequency);
     370
     371            char[] alphab = alphabetCaseInsensitive.ToCharArray();
     372           
     373
     374           
     375           //if letter from the alphabet is not listed as frequency, a frequency of 0 must be filled in
     376           foreach (char item1 in alphab)
     377           {
     378                bool found1 = false;
     379                foreach (CollectionElement item2 in cipherTextFrequencies)
     380                {
     381                    if (item1.ToString()==item2.Caption)
     382                    {
     383                        found1 = true;
     384                    }       
     385                }
     386                if (found1==false)
     387                {
     388                    CollectionElement row1 = new CollectionElement(item1.ToString(), 0, "");
     389                    cipherTextFrequencies.Add(row1);
     390                }
     391
     392                found1 = false;
     393                foreach (CollectionElement item3 in statisticFrequencies)
     394                {
     395                    if (item1.ToString() == item3.Caption)
     396                    {
     397                        found1 = true;
     398                    }
     399                }
     400                if (found1 == false)
     401                {
     402                    CollectionElement row2 = new CollectionElement(item1.ToString(), 0, "");
     403                    statisticFrequencies.Add(row2);
     404                }
     405           
     406            }
     407
     408
     409
    364410
    365411            ArrayList mappings = new ArrayList();
     
    413459      public double ReturnAlphabetGoodness()
    414460      {
    415           if (textStatisticInput_Digrams == "") textStatisticInput_Digrams = ShogunStatistics.ShogunDigrams;//if Optional Statistical input not used -> use variables from pre-analysed Text (James Clavel's Shogun)
     461         // if (textStatisticInput_Digrams == "") textStatisticInput_Digrams = ShogunStatistics.ShogunDigrams;//if Optional Statistical input not used -> use variables from pre-analysed Text (James Clavel's Shogun)
    416462
    417463          double[,] statisticDigramSquare = GetDigramFrequencySquare(StatisticTextFrequencyInput_Digrams);   
     
    502548      public void FastAproach()
    503549      {
    504           if (textStatisticInput_Digrams == "") StatisticTextFrequencyInput_Digrams = ShogunStatistics.ShogunDigrams;//if Optional Statistical input not used -> use variables from pre-analysed Text (James Clavel's Shogun)
     550          //if (textStatisticInput_Digrams == "") StatisticTextFrequencyInput_Digrams = ShogunStatistics.ShogunDigrams;//if Optional Statistical input not used -> use variables from pre-analysed Text (James Clavel's Shogun)
    505551
    506552          double[,] statisticDigramSquare = GetDigramFrequencySquare(StatisticTextFrequencyInput_Digrams);
     
    542588              }
    543589
    544               int breakpoint = 0;
     590              //int breakpoint = 0;
    545591
    546592              //Swap two columns
     
    618664        }
    619665
    620 
     666        //IMPLEMENTSETTINGS//
     667
     668        /* public void ImplementSettings()
     669        {
     670            if (settings.CaseSensitivity == 1)
     671            {
     672                PathToMonogramStatistics += "_cs";
     673                PathToDigramStatistics += "_cs";
     674            }
     675
     676           
     677             
     678             switch (settings.Language)
     679            {
     680                case 0:
     681                         PathToMonogramStatistics += "_en";
     682                         PathToDigramStatistics += "_en";
     683                         break;
     684                case 1:
     685                        PathToMonogramStatistics += "_de";
     686                        PathToDigramStatistics += "_de";
     687                        break;
     688
     689                case 2:
     690                        PathToMonogramStatistics += "_fr";
     691                        PathToDigramStatistics += "_fr";
     692                        break;
     693
     694                case 3:
     695                        PathToMonogramStatistics += "_es";
     696                        PathToDigramStatistics += "_es";
     697                        break;
     698            }
     699
     700            PathToMonogramStatistics += ".txt";
     701
     702            PathToDigramStatistics += ".txt";
     703
     704            if (textStatisticInput_Monograms == "") { textStatisticInput_Monograms = File.ReadAllText(PathToMonogramStatistics); }
     705
     706            if (textStatisticInput_Digrams == "") { textStatisticInput_Digrams = File.ReadAllText(PathToDigramStatistics); }
     707            int a = 0;
     708        } */
    621709
    622710        #endregion CUSTOM METHODS
  • trunk/CrypPlugins/MonoalphabeticAnalysis/MonoalphabeticAnalysis.csproj

    r325 r476  
    136136  </PropertyGroup>
    137137  <ItemGroup>
     138    <None Include="MonoalphabeticAnalysis_di_en.txt">
     139      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
     140    </None>
     141    <None Include="MonoalphabeticAnalysis_mo_en.txt">
     142      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
     143    </None>
     144  </ItemGroup>
     145  <ItemGroup>
    138146    <Folder Include="Properties\" />
    139147  </ItemGroup>
  • trunk/CrypPlugins/MonoalphabeticAnalysis/MonoalphabeticAnalysisSettings.cs

    r373 r476  
    4343            }
    4444        }
     45        /*
     46        private int caseSensitivity = 0;
    4547
    46        
     48        [PropertySaveOrder(2)]
     49        [ContextMenu("Case Sensitivity", "If Frequency Test is feeding case sensitive analysis as input the setting should be set.", 7, DisplayLevel.Expert, ContextMenuControlType.ComboBox, null, new string[] { "Case Insensitive", "Case Sensitive" })]
     50        [TaskPane("Case Sensitivity", "If Frequency Test is feeding case sensitive analysis as input the setting should be set.", "", 7, false, DisplayLevel.Expert, ControlType.ComboBox, new string[] { "Case Insensitive", "Case Sensitive" })]
     51        public int CaseSensitivity
     52        {
     53            get { return this.caseSensitivity; }
     54            set
     55            {
     56                if (value != caseSensitivity)
     57                {
     58                    HasChanges = true;
     59                    caseSensitivity = value;
     60                }
     61
     62                OnPropertyChanged("Case Sensitivity");
     63            }
     64        }
     65
     66        private int language = 0;
     67
     68        [PropertySaveOrder(3)]
     69        [ContextMenu("Language", "Choose expected language of cipher text to use the correlated built-in statistic. The option is applicable only when the inputs for frequency statistic data are not used. ", 7, DisplayLevel.Expert, ContextMenuControlType.ComboBox, null, new string[] { "English", "German", "French", "Spanish" })]
     70        [TaskPane("Language", "Choose expected language of cipher text to use the correlated built-in statistic. The option is applicable only when the inputs for frequency statistic data are not used. ", "", 7, false, DisplayLevel.Expert, ControlType.ComboBox, new string[] { "English", "German", "French", "Spanish" })]
     71        public int Language
     72        {
     73            get { return this.language; }
     74            set
     75            {
     76                if (value != language)
     77                {
     78                    HasChanges = true;
     79                    language = value;
     80                }
     81
     82                OnPropertyChanged("Language");
     83            }
     84        }   */
    4785       
    4886
Note: See TracChangeset for help on using the changeset viewer.