diff --git a/src/lenses/RougeScoreLens.tsx b/src/lenses/RougeScoreLens.tsx index cdeafb38..5932bcf4 100644 --- a/src/lenses/RougeScoreLens.tsx +++ b/src/lenses/RougeScoreLens.tsx @@ -1,37 +1,42 @@ -import { Lens } from "../types"; +import { Lens } from '../types'; import 'twin.macro'; import rouge from 'rouge'; -import { formatNumber } from "../dataformat"; +import { formatNumber } from '../dataformat'; -const calculateRougeScore=(values: unknown[])=>{ - return rouge.n(values[0], values[1]) -} +const calculateRougeScore = (values: unknown[]) => { + return rouge.n(values[0], values[1]); +}; -const RougeScoreLens: Lens = ({values})=>{ - const result = calculateRougeScore(values) - return (
Rouge score: {formatNumber(result)}
) -} +const RougeScoreLens: Lens = ({ values }) => { + const result = calculateRougeScore(values); + return ( +
+ Rouge score: {formatNumber(result)} +
+ ); +}; -RougeScoreLens.key="RougeScoreView" -RougeScoreLens.dataTypes=["str"] -RougeScoreLens.defaultHeight = 22 -RougeScoreLens.minHeight=22 -RougeScoreLens.maxHeight=64 -RougeScoreLens.multi=true -RougeScoreLens.displayName="ROUGE Score" -RougeScoreLens.filterAllowedColumns=(allColumns, selectedColumns) => { - if(selectedColumns.length===2) - return [] - else return allColumns.filter(({type, key}) => { - const isNotSelected = (key)=>{ - return selectedColumns.filter((selectedCol)=>{selectedCol.key!==key}) - } - return type.kind === 'str' && isNotSelected(key); - }) +RougeScoreLens.key = 'RougeScoreView'; +RougeScoreLens.dataTypes = ['str']; +RougeScoreLens.defaultHeight = 22; +RougeScoreLens.minHeight = 22; +RougeScoreLens.maxHeight = 64; +RougeScoreLens.multi = true; +RougeScoreLens.displayName = 'ROUGE Score'; +RougeScoreLens.filterAllowedColumns = (allColumns, selectedColumns) => { + if (selectedColumns.length === 2) return []; + else + return allColumns.filter(({ type, key }) => { + const isNotSelected = (key: string) => { + return selectedColumns.filter((selectedCol) => { + selectedCol.key !== key; + }); + }; + return type.kind === 'str' && isNotSelected(key); + }); }; -RougeScoreLens.isSatisfied = (columns)=>{ - if(columns.length===2) - return true; +RougeScoreLens.isSatisfied = (columns) => { + if (columns.length === 2) return true; return false; -} -export default RougeScoreLens +}; +export default RougeScoreLens; diff --git a/src/rouge.d.ts b/src/rouge.d.ts deleted file mode 100644 index 670ae045..00000000 --- a/src/rouge.d.ts +++ /dev/null @@ -1 +0,0 @@ -declare module "rouge" diff --git a/src/rougeScore.d.ts b/src/rougeScore.d.ts new file mode 100644 index 00000000..a294f4d3 --- /dev/null +++ b/src/rougeScore.d.ts @@ -0,0 +1 @@ +declare module 'rouge';