Changeset 190 for trunk/Forms
- Timestamp:
- Jul 13, 2018, 5:16:39 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Forms/UFormCheck.pas
r186 r190 55 55 function IsUppercaseAlpha(Text: string): Boolean; 56 56 function IsAlpha(Text: string): Boolean; 57 function IsAcronym(Text: string): Boolean; 57 58 procedure ReportDifferencies; 58 59 function WordContainsLetters(Text, Letters: string): Boolean; … … 77 78 SAcronymCountContent = 'Content acronym count:'; 78 79 SAcronymCountSummary = 'Summary acronym count:'; 79 SDuplicateAcronymContent = ' Duplicate acronym %s with "%s" in document content.';80 SDuplicateAcronymSummary = ' Duplicate acronym %s with "%s" in acronym summary.';81 SMissingAcronymContent = ' Content acronym %s with meaning "%s" missing from summary acronyms.';82 SMissingAcronymSummary = ' Summary acronym %s with meaning "%s" missing from content acronyms.';83 80 SDuplicateAcronymContent = 'Warning: Duplicate acronym %s with "%s" in document body.'; 81 SDuplicateAcronymSummary = 'Warning: Duplicate acronym %s with "%s" in acronym summary.'; 82 SMissingAcronymContent = 'Warning: Document body acronym %s with meaning "%s" missing from acronym summary.'; 83 SMissingAcronymSummary = 'Warning: Summary acronym %s with meaning "%s" missing from document body.'; 84 SPluralAcronym = 'Note: Acronym %s is defined as plural in document body.'; 84 85 85 86 { TFormCheck } … … 218 219 HasMeaning1: Boolean; 219 220 HasMeaning2: Boolean; 221 Plural: Boolean; 220 222 begin 221 223 AcronymDbContent.Acronyms.Clear; … … 232 234 if EndIndex <> 0 then begin 233 235 Acronym := Trim(Copy(Text, StartIndex + 1, EndIndex - StartIndex - 1)); 234 if (Length(Acronym) > 1) and IsUppercaseAlpha(Acronym) then begin 236 // Allow plural acronyms with ending 's' character 237 if (Length(Acronym) >= 1) and (Acronym[Length(Acronym)] = 's') then begin 238 Acronym := Copy(Acronym, 1, Length(Acronym) - 1); 239 Plural := True; 240 end else Plural := False; 241 if IsAcronym(Acronym) then begin 235 242 HasMeaning1 := ParseMeaning(Acronym, Text, StartIndex - 1, Meaning1); 236 243 if HasMeaning1 then Meaning := Meaning1; … … 242 249 end; 243 250 if HasMeaning1 or HasMeaning2 then begin 251 // If plural acronym then try to remove ending 's' character from the meaning 252 if Plural then MemoReport.Lines.Add(Format(SPluralAcronym, [Acronym])); 253 if Plural and (Length(Meaning) >= 1) and (Meaning[Length(Meaning)] = 's') then begin 254 Meaning := Copy(Meaning, 1, Length(Meaning) - 1); 255 end; 244 256 if Assigned(AcronymDbContent.SearchAcronym(Acronym, Meaning)) then 245 257 MemoReport.Lines.Add(Format(SDuplicateAcronymContent, [Acronym, Meaning])) … … 360 372 end; 361 373 374 function TFormCheck.IsAcronym(Text: string): Boolean; 375 const 376 MinAcronymLength = 2; 377 begin 378 Result := (Length(Text) >= MinAcronymLength) and IsUppercaseAlpha(Text); 379 end; 380 362 381 procedure TFormCheck.ReportDifferencies; 363 382 var
Note:
See TracChangeset
for help on using the changeset viewer.