-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #301 from vishnukaushik/main
Add Rouge score lens
- Loading branch information
Showing
5 changed files
with
61 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { Lens } from '../types'; | ||
import 'twin.macro'; | ||
import rouge from 'rouge'; | ||
import { formatNumber } from '../dataformat'; | ||
|
||
const RougeScoreLens: Lens = ({ values }) => { | ||
const rouge1 = rouge.n(values[0], values[1], 1); | ||
const rouge2 = rouge.n(values[0], values[1], 2); | ||
return ( | ||
<div> | ||
<div tw="text-sm truncate px-1 py-0.5 flex items-center h-full"> | ||
Rouge 1: {formatNumber(rouge1)} | ||
</div> | ||
<div tw="text-sm truncate px-1 py-0.5 flex items-center h-full"> | ||
Rouge 2: {formatNumber(rouge2)} | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
RougeScoreLens.key = 'RougeScoreView'; | ||
RougeScoreLens.dataTypes = ['str']; | ||
RougeScoreLens.defaultHeight = 50; | ||
RougeScoreLens.minHeight = 50; | ||
RougeScoreLens.maxHeight = 100; | ||
RougeScoreLens.multi = true; | ||
RougeScoreLens.displayName = 'ROUGE Score'; | ||
RougeScoreLens.filterAllowedColumns = (allColumns, selectedColumns) => { | ||
if (selectedColumns.length === 2) return []; | ||
const selectedKeys = selectedColumns.map((selectedCol) => selectedCol.key); | ||
return allColumns.filter(({ type, key }) => { | ||
return type.kind === 'str' && !selectedKeys.includes(key); | ||
}); | ||
}; | ||
RougeScoreLens.isSatisfied = (columns) => { | ||
if (columns.length === 2) return true; | ||
return false; | ||
}; | ||
export default RougeScoreLens; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
declare module 'rouge'; |