public void ScanErrors( int count, int numberOfTasks, int numberOfProcessers, KeywordPair allocationPair, string taffFilename, Validations validations) { // Check TASKS, COUNT and PROCESSORS bool countExists = validations.CheckRequiredValueExist( count.ToString(), TaffKeywords.ALLOCATIONS_COUNT); bool taskExists = validations.CheckRequiredValueExist( numberOfTasks.ToString(), TaffKeywords.ALLOCATIONS_TASKS); bool processorsExists = validations.CheckRequiredValueExist( numberOfProcessers.ToString(), TaffKeywords.ALLOCATIONS_PROCESSORS); // Checking whether the number of allocation is the same as the defined COUNT if (countExists && taskExists && processorsExists) { validations.CheckValidQuantity( allocationPair.CalculateNumOfPair().ToString(), count.ToString(), TaffKeywords.OPENING_ALLOCATION, ErrorCode.MISSING_SECTION); validations.CheckValidQuantity( Allocations.Count.ToString(), count.ToString(), TaffKeywords.OPENING_ALLOCATION, ErrorCode.MISSING_SECTION); } }
public CffTasks() { TasksSection = new PairSection( CffKeywords.OPENING_TASKS, CffKeywords.CLOSING_TASKS); Tasks = new List <Task>(); TaskPair = new KeywordPair( CffKeywords.OPENING_TASK, CffKeywords.CLOSING_TASK); CffTaskExtraction = new CffTask(); }
public CffProcessors() { ProcessorsSection = new PairSection( CffKeywords.OPENING_PROCESSORS, CffKeywords.CLOSING_PROCESSORS); Processors = new List <Processor>(); ProcessorPair = new KeywordPair( CffKeywords.OPENING_PROCESSOR, CffKeywords.CLOSING_PROCESSOR); CffProcessorkExtraction = new CffProcessor(); }
public CffProcessorTypes() { ProcessorTypesSection = new PairSection( CffKeywords.OPENING_PROCESSOR_TYPES, CffKeywords.CLOSING_PROCESSOR_TYPES); ProcessorTypes = new List <ProcessorType>(); ProcessorTypePair = new KeywordPair( CffKeywords.OPENING_PROCESSOR_TYPE, CffKeywords.CLOSING_PROCESSOR_TYPE); CffProcessorTypeExtraction = new CffProcessorType(); }
// override object.Equals public override bool Equals(object obj) { if (obj == null || GetType() != obj.GetType()) { return(false); } KeywordPair other = obj as KeywordPair; if (other.Word != this.Word) { return(false); } return(other.Pos == this.Pos); }
public bool ValidateFile(string taffFilename, Validations validations) { if (taffFilename == null) { return(false); } int beforeNumOfError, afterNumOfError; beforeNumOfError = validations.ErrorValidationManager.Errors.Count; TaffFilename = taffFilename; // Extract and validate the configuration data section GetCffFilename(taffFilename, validations); // Validate the rest of the taff file KeywordPair allocationPair = new KeywordPair( TaffKeywords.OPENING_ALLOCATION, TaffKeywords.CLOSING_ALLOCATION); PairSection openClosingAllocations = new PairSection( TaffKeywords.OPENING_ALLOCATIONS, TaffKeywords.CLOSING_ALLOCATIONS); StreamReader streamReader = new StreamReader(taffFilename); TaffAllocations taffAllocations = new TaffAllocations(); int lineNumber = 1; string line; validations.Filename = taffFilename; while (!streamReader.EndOfStream) { line = streamReader.ReadLine(); line = line.Trim(); validations.LineNumber = lineNumber.ToString(); // Check if keyword is valid or not validations.CheckValidKeyword(line, TaffKeywords.KEYWORD_DICT); // Count Allocation Section allocationPair.CheckValidKeyword(line); // Check whether the line starts Opening/Closing Allocations section // If yes, mark it exist openClosingAllocations.MarkSection(line, lineNumber); // Validate and extract data in the Allocations section if (openClosingAllocations.ValidSectionPair[0] && !openClosingAllocations.ValidSectionPair[1]) { // Check whether Allocations section exists and // whether line strt with the expected keyword, "COUNT", "TASKS" // and "PROCESSORS" Count = taffAllocations.ExtractCount(Count, line, validations); NumberOfTasks = taffAllocations.ExtractNumOfTasks(NumberOfTasks, line, validations); NumberOfProcessors = taffAllocations.ExtractNumOfProcessors(NumberOfProcessors, line, validations); // Check whether the reader goes within the Allocation section taffAllocations.MarkInsideAllocation(line, lineNumber, validations); // Extract new allocation Allocation newAllocation = taffAllocations.ExtractAllocation(line, NumberOfProcessors, NumberOfTasks, validations); if (newAllocation != null) { Allocations.Add(newAllocation); } } lineNumber++; } streamReader.Close(); // Checking whether the Allocations section exists openClosingAllocations.CheckValidPair(validations, taffFilename); // Validate Allocation taffAllocations.ScanErrors( Count, NumberOfTasks, NumberOfProcessors, allocationPair, taffFilename, validations); AllocationInFileCount = allocationPair.CalculateNumOfPair(); afterNumOfError = validations.ErrorValidationManager.Errors.Count; // Console.WriteLine($"{Count} | {NumberOfTasks} | {NumberOfProcessors}"); // Console.WriteLine($"{Allocations.Count} | {allocationPair.CalculateNumOfPair()}"); return(beforeNumOfError == afterNumOfError); }
static void HashCharsMatrixes() { Random rand = new Random(); var index = new List <string>(); //Load document using (var sr = new StreamReader("C:\\Users\\brett\\Documents\\MATLAB\\wikitext-2\\wiki.train.tokens")) { using (var sw = new StreamWriter("C:\\Users\\brett\\Documents\\MATLAB\\wikitext-2\\wiki.train.txt")) { //Read to end of the stream. while (!sr.EndOfStream) { var masterList = new List <KeywordPair>(); // Get the current line var sline = sr.ReadLine(); // Make sure the line actually has words if (sline != "" && sline != " ") { // Get rid of the equal signs sline = sline.Replace('=', ' '); // Create an array of words by splitting up the line by spaces. var splity = sline.Split(' '); // Make sure its not an empty spot and iterate through the array. if (splity.Length > 1) { for (int i = 0; i < splity.Length - 1; i++) { //Strip the words of non-alphabetical characters and add the current word and the next word to the list. masterList.Add(new KeywordPair(KeywordPair.GetOnlyChars(splity[i]), KeywordPair.GetOnlyChars(splity[i + 1]))); } } } foreach (var s in masterList) { // Make sure that none of the words are empty or "unk" (I think it means unknown) if (s.First != "" && s.Second != "" && s.First != "unk" && s.Second != "unk") { // Initialize arrays for the word var mats1 = new int[18]; var mats2 = new int[18]; // Iterate through the characters in the word for (int i = 0; i < 18; i++) { // Make sure the word is long enough if (s.First.Length > i) { // Convert the char to its ASCII index integer mats1[i] = KeywordPair.GetCharBin(s.First[i], rand); } else { // Add some int value that is not an alphabetical ASCII int. mats1[i] = KeywordPair.GetCharBin(' ', rand); } // Do the same thing for the target if (s.Second.Length > i) { mats2[i] = KeywordPair.GetCharBin(s.Second[i], rand); } else { // Put the value on the lower end of the the ASCII index for the target. Hopefully it does something kool. mats2[i] = KeywordPair.GetCharBin(' ', rand); } } sw.WriteLine(KeywordPair.ConvertMatToString(mats1) + " " + KeywordPair.ConvertMatToString(mats2)); Console.WriteLine(KeywordPair.ConvertMatToString(mats1) + " " + KeywordPair.ConvertMatToString(mats2)); } } } } } }