Skip to content

Commit

Permalink
Merge pull request #13772 from JohnSnowLabs/fix_tapas_max_col_rank_issue
Browse files Browse the repository at this point in the history
Fix Tapas bug due to exceeding the maximum rank value
  • Loading branch information
maziyarpanahi authored May 10, 2023
2 parents 4732d05 + 6130185 commit 7b2674e
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ class TapasEncoder(
protected val MAX_YEAR = 2120

protected val MIN_NUMBER_OF_ROWS_WITH_VALUES_PROPORTION = 0.5f
protected val MAX_COLUMN_RANK = 255

protected val ORDINAL_SUFFIXES: Array[String] = Array("st", "nd", "rd", "th")
protected val NUMBER_WORDS: Array[String] = Array(
Expand Down Expand Up @@ -525,9 +526,10 @@ class TapasEncoder(
columnIds = setMaxSentenceLimit(emptyTokenTypes ++ columnIds ++ padding),
rowIds = setMaxSentenceLimit(emptyTokenTypes ++ rowIds ++ padding),
prevLabels = setMaxSentenceLimit(emptyTokenTypes ++ prevLabels ++ padding),
columnRanks = setMaxSentenceLimit(emptyTokenTypes ++ columnRanks ++ padding),
invertedColumnRanks =
setMaxSentenceLimit(emptyTokenTypes ++ invertedColumnRanks ++ padding),
columnRanks = setMaxSentenceLimit(
emptyTokenTypes ++ columnRanks.map(x => scala.math.min(x, MAX_COLUMN_RANK)) ++ padding),
invertedColumnRanks = setMaxSentenceLimit(emptyTokenTypes ++ invertedColumnRanks.map(x =>
scala.math.min(x, MAX_COLUMN_RANK)) ++ padding),
numericRelations = setMaxSentenceLimit(emptyTokenTypes ++ numericRelations ++ padding))
}

Expand Down

0 comments on commit 7b2674e

Please sign in to comment.