Skip to content

Commit

Permalink
WIP adding in docs
Browse files Browse the repository at this point in the history
  • Loading branch information
chanind committed Dec 29, 2023
1 parent d4d0e00 commit 9f6b52c
Show file tree
Hide file tree
Showing 36 changed files with 192 additions and 860 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ src/**.js
coverage
*.log
package-lock.json
yarn.lock
yarn.lock
.DS_Store
1 change: 1 addition & 0 deletions docs/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
# Generated files
.docusaurus
.cache-loader
generated

# Misc
.DS_Store
Expand Down
12 changes: 0 additions & 12 deletions docs/blog/2019-05-28-first-blog-post.md

This file was deleted.

44 changes: 0 additions & 44 deletions docs/blog/2019-05-29-long-blog-post.md

This file was deleted.

20 changes: 0 additions & 20 deletions docs/blog/2021-08-01-mdx-blog-post.mdx

This file was deleted.

Binary file not shown.
25 changes: 0 additions & 25 deletions docs/blog/2021-08-26-welcome/index.md

This file was deleted.

17 changes: 0 additions & 17 deletions docs/blog/authors.yml

This file was deleted.

66 changes: 66 additions & 0 deletions docs/docs/api.penman.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import Tree from '../generated/classes/lib_tree.Tree.mdx';
import Graph from '../generated/classes/lib_graph.Graph.mdx';
import Triple from '../generated/types/lib_graph.Triple.mdx';
import PENMANCodec from '../generated/classes/lib_codec.PENMANCodec.mdx';

# penman-js

The main `penman-js` module contains most exports that you'll need for basic usage. For more advanced usage, see the other submodules in the API Reference.

Users wanting to interact with graphs might find the `decode` and
`encode` functions a good place to start::

```js
import { encode, decode } from 'penman-js';
const g = penman.decode('(w / want-01 :ARG0 (b / boy) :ARG1 (g / go :ARG0 b))');
console.log(g.top);
// 'w'
console.log(g.triples.length);
// 6
console.log(g.instances().map((instance) => instance[2]));
// ['want-01', 'boy', 'go']

// JS doesn't support keyword parameters, so `undefined` must be passed for optional params
console.log(encode(g, undefined, undefined, 'b'));
// (b / boy
// :ARG0-of (w / want-01
// :ARG1 (g / go
// :ARG0 b)))
```

The `decode` and `encode` functions work with one PENMAN
graph. The `load` and `dump` functions work with
collections of graphs.

Users who want to work with trees would use `parse` and
`format` instead

```js
import { parse, format } from 'penman-js';

const t = penman.parse('(w / want-01 :ARG0 (b / boy) :ARG1 (g / go :ARG0 b))');
const [variable, branches] = t.node;
console.log(variable); // ouput: 'w'
console.log(branches.length); // output: 3
const [role, target] = branches[2];
console.log(role); // output: ':ARG1'
console.log(format(target));
// (g / go
// :ARG0 b)
```

---

<Tree />

---

<Triple />

---

<Graph />

---

<PENMANCodec />
50 changes: 15 additions & 35 deletions docs/docs/intro.md
Original file line number Diff line number Diff line change
@@ -1,47 +1,27 @@
---
sidebar_position: 1
slug: /
---

# Tutorial Intro
# Penman JS

Let's discover **Docusaurus in less than 5 minutes**.
[![ci](https://img.shields.io/github/actions/workflow/status/chanind/penman-js/ci.yaml?branch=main)](https://github.com/chanind/penman-js)
[![Npm](https://img.shields.io/npm/v/penman-js)](https://www.npmjs.com/package/penman-js)

## Getting Started
PENMAN notation (e.g. AMR) parser and generator for JavaScript

Get started by **creating a new site**.
## About

Or **try Docusaurus immediately** with **[docusaurus.new](https://docusaurus.new)**.
This library is a manual port of the Penman Python library, with identical method names and import structure. However, as Python and Javascript do have some differences, this port has the following changes:

### What you'll need
- all snake-case function names from the Python library are renamed using camel-case to fit Javascript naming conventions. For example, the function `get_pushed_variable` from Python is renamed to `getPushedVariable` in Javascript.
- Python tuples are replaced with Javascript arrays
- Python dictionaries are replaced with Javascript `Map`
- functions only support positional arguments, since Javascript doesn't support keyword arguments like Python
- All imports use `penman-js` as the base instead of `penman`. For instance, `from penman.graph import Graph` in Python is replaced with `import { Graph } from "penman-js/graph";` in Javascript.

- [Node.js](https://nodejs.org/en/download/) version 18.0 or above:
- When installing Node.js, you are recommended to check all checkboxes related to dependencies.
Otherwise, refer to the [Penman Python library docs](https://penman.readthedocs.io/en/latest/index.html) for full documentation.

## Generate a new site
## Disclaimer

Generate a new Docusaurus site using the **classic template**.

The classic template will automatically be added to your project after you run the command:

```bash
npm init docusaurus@latest my-website classic
```

You can type this command into Command Prompt, Powershell, Terminal, or any other integrated terminal of your code editor.

The command also installs all necessary dependencies you need to run Docusaurus.

## Start your site

Run the development server:

```bash
cd my-website
npm run start
```

The `cd` command changes the directory you're working with. In order to work with your newly created Docusaurus site, you'll need to navigate the terminal there.

The `npm run start` command builds your website locally and serves it through a development server, ready for you to view at http://localhost:3000/.

Open `docs/intro.md` (this page) and edit some lines: the site **reloads automatically** and displays your changes.
This project is not officially affiliated with [AMR](http://amr.isi.edu/) or the [Penman Python library](https://github.com/goodmami/penman).
32 changes: 32 additions & 0 deletions docs/docs/quick-start.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
---
sidebar_position: 2
---

# Quick start

## Installation

Install the library from NPM

```
npm install penman-js
```

## Basic usage

The `decode` function make it easy to parse AMR text in Penman notation into a graph. The `encode` function can likewise turn it back into a string.

```js
import { encode, decode } from 'penman-js';

g = decode('(b / bark-01 :ARG0 (d / dog))');
g.triples;
// [('b', ':instance', 'bark-01'), ('b', ':ARG0', 'd'), ('d', ':instance', 'dog')]
g.edges();
// [Edge(source='b', role=':ARG0', target='d')]

// JS doesn't support keyword parameters, so `undefined` must be passed for optional params
console.log(encode(g, undefined, undefined, 3));
// (b / bark-01
// :ARG0 (d / dog))
```
8 changes: 0 additions & 8 deletions docs/docs/tutorial-basics/_category_.json

This file was deleted.

23 changes: 0 additions & 23 deletions docs/docs/tutorial-basics/congratulations.md

This file was deleted.

34 changes: 0 additions & 34 deletions docs/docs/tutorial-basics/create-a-blog-post.md

This file was deleted.

Loading

0 comments on commit 9f6b52c

Please sign in to comment.