-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
06aed0c
commit 4239b44
Showing
6 changed files
with
107 additions
and
1 deletion.
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
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,5 @@ | ||
import { ChapterId } from 'transliteration/domain/chapter-id' | ||
|
||
export type NgramScore = ChapterId & { | ||
overlap: number | ||
} |
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,79 @@ | ||
import React, { ReactNode } from 'react' | ||
import AppContent from 'common/AppContent' | ||
import { SectionCrumb, TextCrumb } from 'common/Breadcrumbs' | ||
import FragmentCrumb from 'fragmentarium/ui/FragmentCrumb' | ||
import SessionContext from 'auth/SessionContext' | ||
import { Session } from 'auth/Session' | ||
import withData from 'http/withData' | ||
import { HeadTags } from 'router/head' | ||
import FragmentService from 'fragmentarium/application/FragmentService' | ||
import { NgramScore } from 'fragmentarium/domain/ngramMatching' | ||
import { Col, Container, Row } from 'react-bootstrap' | ||
import { GenreInfoRow } from 'corpus/ui/search/CorpusSearchResult' | ||
import _ from 'lodash' | ||
|
||
function NgramMatchingHeadTags({ number }: { number: string }): JSX.Element { | ||
return ( | ||
<HeadTags | ||
title={`Fragment ${number} N-gram Matching: eBL`} | ||
description={`Fragment ${number} n-gram matching in the electronic Babylonian Library (eBL) Fragmentarium.`} | ||
/> | ||
) | ||
} | ||
|
||
function NgramMatching({ | ||
number, | ||
ngramScores, | ||
}: { | ||
number: string | ||
ngramScores: readonly NgramScore[] | ||
}): JSX.Element { | ||
return ( | ||
<AppContent | ||
crumbs={[ | ||
new SectionCrumb('Fragmentarium'), | ||
new FragmentCrumb(number), | ||
new TextCrumb('N-Gram Matching'), | ||
]} | ||
title={`N-Gram Matching for ${number}`} | ||
> | ||
<SessionContext.Consumer> | ||
{(session: Session): ReactNode => | ||
session.isAllowedToReadFragments() ? ( | ||
<> | ||
<NgramMatchingHeadTags number={number} /> | ||
<Container> | ||
{ngramScores.map((score, index) => ( | ||
<Row key={index}> | ||
<Col> | ||
{ | ||
<GenreInfoRow | ||
chapterId={_.omit(score, 'overlap')} | ||
textName={''} | ||
/> | ||
} | ||
</Col> | ||
<Col>{score.overlap.toFixed(4)}</Col> | ||
</Row> | ||
))} | ||
</Container> | ||
</> | ||
) : ( | ||
'Please log in to search for matching chapters' | ||
) | ||
} | ||
</SessionContext.Consumer> | ||
</AppContent> | ||
) | ||
} | ||
|
||
export default withData< | ||
{ fragmentService: FragmentService; number: string }, | ||
{ number: string }, | ||
readonly NgramScore[] | ||
>( | ||
({ data, ...props }) => ( | ||
<NgramMatching ngramScores={data} number={props.number} /> | ||
), | ||
(props) => props.fragmentService.ngramScores(props.number) | ||
) |
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