Treebank display engine for React
npm install treebank-reactReact library for displaying treebanks.
It displays treebanks visually using the Dagre library
as well as displaying XML and other formats.
https://perseids-tools.github.io/treebank-react/
yarn add treebank-react
Note that this package has the following peer dependencies:
``json`
{
"react": "^16.0.0 || ^17.0.0"
}
(See project on npm.)
See the demo App.js.
`jsx
import {
Treebank,
Sentence,
Text,
Graph,
Information,
Xml,
Collapse,
} from 'treebank-react';
import 'treebank-react/build/index.css';
const xml = '
+ '
+ '
+ '
+ '
+ '
+ '
const App = () => (
);
export default App;
`
#### Treebank
The component accepts treebank XML as a treebank prop.
The other components should be children (or grandchildren, etc.) of the component.
#### Sentence
The component accepts a string id which represents the id of the
sentence to display.
It also accepts an optional highlight prop. This is an array of id strings to be
emphasized by the child components.
#### Graph
The component must be within a component.
It uses Dagre-d3 to display the treebank.
The height and width of the graph are determined by the parent element.
This is subject to change, but currently it expects a parent with display: flex.
`jsx`
#### Information
The component shows the deconstructed POSTag and the lemma for the active word.
The headers are taken from the treebank configuration.
See alpheios-project/arethusa-configs for more information about treebank configuration.
#### Xml
The component displays the XML of the sentence.
#### Collapse
The component is provided for convenience.
It is a button that displays or hides its children whenever it is clicked.
``
git clone git@github.com:perseids-tools/treebank-react.git
then install development dependencies
``
yarn install
#### Unit tests
yarn test
#### Visual regression tests
yarn visual-test
yarn start
yarn deploy
yarn build
``
yarn build
npm publish
(Make sure to update the version in package.json before publishing a new release.)
This library is build on top of DimiMikadze/create-react-library.
To upgrade to the latest version of create-react-library:
* In package.json, everything above devDependencies should not be updated,create-react-library
but everything below it should be replaced by the new versions in ../scripts
* Add back the dependencies for the project
* All of the files in should be replaced with new versions in create-react-library../config
* All of the files in should be replaced with new versions in create-react-library`.
* Test to make sure that building and deploying demo application still work