setMaxNgrams( intval( $options['t'] ) ); } if ( !empty( $options['f'] ) ) { $cat->setMinFreq( intval( $options['f'] ) ); } $input = isset( $options['l'] ) ? $options['l'] : file_get_contents( "php://stdin" ); if ( !empty( $options['c'] ) ) { $result = $cat->classify( $input, explode( ",", $options['c'] ) ); } else { $result = $cat->classify( $input ); } if ( empty( $result ) ) { echo "No match found.\n"; exit( 1 ); } if ( !empty( $options['u'] ) ) { $max = reset( $result ) * $options['u']; } else { $max = reset( $result ) * 1.05; } if ( !empty( $options['a'] ) ) { $top = $options['a']; } else { $top = 10; } $result = array_filter( $result, function ( $res ) use( $max ) { return $res < $max; } ); if ( $result && count( $result ) <= $top ) { echo join( " OR ", array_keys( $result ) ) . "\n"; exit( 0 ); } else { echo "Cannot determine language.\n"; exit( 1 ); }