package Ġcom . github . dar der ion . m und ane assignment pol ice . checker . rule . word Ċ Ċ import Ġcom . github . dar der ion . m und ane assignment pol ice . checker . Rule Violation Ċ import Ġcom . github . dar der ion . m und ane assignment pol ice . checker . Rule Violation Type Ċ import Ġcom . github . dar der ion . m und ane assignment pol ice . checker . rule . Rule Ċ import Ġcom . github . dar der ion . m und ane assignment pol ice . pdf document . PDF Document Ċ import Ġcom . github . dar der ion . m und ane assignment pol ice . pdf document . PDF Region Ċ import Ġcom . github . dar der ion . m und ane assignment pol ice . pdf document . inside Ċ Ċ abstract Ġclass ĠWord Rule ( Ċ ĉ val Ġword : ĠString , Ċ ĉ open Ġval Ġrule Body : Ġ( neighbors : ĠList < String >, Ġrequired Neighbors : ĠMutable List < Regex >, Ġdis allowed Neighbors : ĠMutable List < Regex >) Ġ-> ĠBoolean , Ċ ĉ type : ĠRule Violation Type , Ċ ĉ area : ĠPDF Region , Ċ ĉ name : ĠString Ċ ): ĠRule ( area , Ġname , Ġtype ) Ġ{ ĊĊĊ ĉ abstract Ġfun Ġis Vi olated ( document : ĠPDF Document , Ġline : ĠInt , Ġindex : ĠInt , Ġlambda Ġ:( neighbors : List < String >, required Neighbors : ĠMutable List < Regex >, dis allowed Neighbors : ĠMutable List < Regex >) Ġ-> ĠBoolean ): ĠBoolean ĊĊ ĉ override Ġfun Ġprocess ( document : ĠPDF Document ): ĠList < Rule Violation > Ġ{ Ċĉ ĉ val Ġrules Vi olations : ĠMutable List < Rule Violation > Ġ= Ġmutable ListOf () ĊĊĉ ĉ document . text . filter Ġ{ Ġit . area !! Ġinside Ġarea Ġ}. forEach Indexed Ġ{ Ġline Index , Ġline Ġ-> Ċĉĉ ĉ split To Words And P unct u ations ( line . content ) Ċĉĉĉ ĉ . map Indexed Ġ{ Ġword Index , Ġword Text Ġ-> Ġif Ġ( word Text Ġ== Ġthis . word ) Ġword Index Ġelse Ġ- 1 Ġ} Ċĉĉĉ ĉ . filter Ġ{ Ġit Ġ!= Ġ- 1 Ġ}. forEach Ġ{ Ċĉĉĉĉ ĉ if Ġ( is Vi olated ( document , Ġline Index , Ġit Ġ, Ġrule Body )) Ġ{ Ċĉĉĉĉĉ ĉ rules Vi olations . add ( Rule Violation ( listOf ( line ), Ġname , Ġtype )) Ċĉĉĉĉ ĉ } Ċĉĉĉ ĉ } Ċĉ ĉ } Ċĉ ĉ return Ġrules Vi olations Ċ ĉ } Ċ }