Skip to content

Commit

Permalink
Formatted code
Browse files Browse the repository at this point in the history
  • Loading branch information
vishnukaushik committed Oct 25, 2023
1 parent 7afb9f7 commit 70b9448
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 31 deletions.
65 changes: 35 additions & 30 deletions src/lenses/RougeScoreLens.tsx
Original file line number Diff line number Diff line change
@@ -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 (<div tw="text-sm truncate px-1 py-0.5 flex items-center h-full">Rouge score: {formatNumber(result)}</div>)
}
const RougeScoreLens: Lens = ({ values }) => {
const result = calculateRougeScore(values);
return (
<div tw="text-sm truncate px-1 py-0.5 flex items-center h-full">
Rouge score: {formatNumber(result)}
</div>
);
};

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;
1 change: 0 additions & 1 deletion src/rouge.d.ts

This file was deleted.

1 change: 1 addition & 0 deletions src/rougeScore.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
declare module 'rouge';

0 comments on commit 70b9448

Please sign in to comment.