diff --git a/build/service/Tesseract.php b/build/service/Tesseract.php index 4d08ab5..5741d0d 100755 --- a/build/service/Tesseract.php +++ b/build/service/Tesseract.php @@ -70,7 +70,7 @@ } /* (5) Manage if empty */ - if( count($lines) < 2 ) + if( count($lines) < 3 ) throw new \Exception("Nothing read"); } @@ -83,10 +83,10 @@ $title = $lines[0]; /* (2) Get last non-empty line */ - for( $i = count($lines)-1 ; $i > 0 ; $i-- ){ + for( $i = 2 ; $i < count($lines) ; $i++ ){ // Amphi ... // - if( preg_match('@^a[nm]([bp][hln])?[ir] ?(.+)$@i', $lines[$i], $m) ) // 'amphi A', 'amphi 600 droit' + if( preg_match('@^a[nm](?:[bp][hln])?[ir] ?(.+)$@i', $lines[$i], $m) ) // 'amphi A', 'amphi 600 droit' return [ $title, "Amphi ${m[1]}" ]; @@ -94,12 +94,15 @@ if( preg_match('@^[S|5] ?(\d+)@i', $lines[$i], $m) ) // 'S10', 'S22' return [ $title, "S. ${m[1]}" ]; + // If not 'Cours', 'CTD', 'TD', 'TP' // + if( preg_match('@^(co[hu][trn][s5]|t[dp|c[mn]|ct[dp])@i', $lines[$i]) ) + continue; } } - return [ $title, null ]; + return [ $title, $lines[2] ]; }