Skip to content

Commit

Permalink
docs: use mvn site for documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
sarmbruster committed Apr 30, 2024
1 parent 63a409b commit 5718b20
Show file tree
Hide file tree
Showing 13 changed files with 266 additions and 212 deletions.
212 changes: 0 additions & 212 deletions README.adoc
Original file line number Diff line number Diff line change
@@ -1,215 +1,3 @@
# neo4j-atag

A collections of https://neo4j.com[neo4j] stored procedures to support the https://git.thm.de/aksz15/atag[applied text as graph] (ATAG) concept.


## available procedures / functions

### atag.chains.characterChain

.Parameters thm.characterChain
|===
| name | type | description | default value

| text | String | string to be used for building a chain of nodes |
| applyIndexes | boolean | if true, `startIndex/endIndex` properties are added | `false`
| | | |
| return value | Path | a path holding the created chain |
|===

#### example

[source,cypher]
----
CALL atag.chains.characterChain('what a nice text') YIELD path RETURN path;
match (t:Text)
where t.text is not null
with t
CALL atag.chains.characterChain(t.text) yield path return path;
----

### atag.chains.tokenChain

Uses regex `((?<=\W)|(?=\W))` for identifying tokens.

.Parameters thm.tokenChain
|===
| name | type | description | default value

| text | String | string to be used for building a chain of nodes |
| applyIndexes | boolean | if true, `startIndex/endIndex` properties are added | `true`
| | | |
| return value | Path | a path holding the created chain |
|===

#### examples

[source,cypher]
----
CALL atag.chains.tokenChain('what a nice text') YIELD path RETURN path;
----

[source,cypher]
----
match (t:Text)
where t.text is not null
with t
CALL atag.chains.tokenChain(t.text) yield path return path;
----

### atag.chains.fullChain

The most complete procedure, creates both token and character chain.
Delegates internally to `thm.tokenChain` and `thm.characterChain`.
Interconnects the two chains appropriately.

.Parameters thm.fullChain
|===
| name | type | description | default value

| start | Node | start node holding the text in a property |
| propertyKey | string | property key |
| applyIndexes | boolean | if true, `startIndex/endIndex` properties are added to character nodes | `false`
| | | |
| return value | void ||
|===

#### example

[source,cypher]
----
CREATE (s:Text{text:'What a nice text'})
WITH s
CALL atag.chains.fullChain(s, 'text')
RETURN s
----

### atag.chains.chain

A very generic procedure to build a chain of nodes.

.Parameters thm.chain
|===
| name | type | description | default value

| text | string | string to be used for building a chain of nodes |
| regex | string | separator regex pattern |
| label | string | label for new nodes |
| relType | string | relationship type used for the chain |
| applyIndexProperties | boolean | whether to add startIndex/endIndex properties |
| | | |
| return value | Path | a path holding the created chain |
|===

NOTE: the regex parameter uses lookahead/lookbehind notation, see https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/regex/Pattern.html

#### example

[source,cypher]
----
CALL atag.chains.chain('what a nice text', '((?<=\\s)|(?=\\s))', 'Character', 'NEXT_CHARACTER', false) YIELD path RETURN path
----

#### create example

[source,cypher]
----
match (n) detach delete n;
create (t1:Text {text:'Müde macht uns die Arbeit, die wir liegen lassen, nicht die, die wir tun.', textEn:'It is the work we leave undone that makes us tired, not the work we do.', url:'https://klebeheld.de/wandtattoos/zitate/arbeit/wandtattoo-muede-macht-uns-die-arbeit-die-wir-liegen-lassen-nicht-die-die-wir-tun.-no.1-ebner-e/542'})
create (t2:Text {text:'Müde macht uns nicht die Arbeit die wir tun sondern die, die wir liegen lassen.', textEn:'It is not the work we do that makes us tired, but the work we leave undone.', url:'https://www.mak-uk.de/wir-ueber-uns-pd.html'});
// Create uuids für Character-Nodes
:auto MATCH (r:Character)
WHERE r.uuid is null
CALL {
WITH r
SET r.uuid = apoc.create.uuid()
} IN TRANSACTIONS OF 1000 ROWS
RETURN count(*);
// Create uuids für Token-Nodes
:auto MATCH (r:Token)
WHERE r.uuid is null
CALL {
WITH r
SET r.uuid = apoc.create.uuid()
} IN TRANSACTIONS OF 1000 ROWS
RETURN count(*);
----

### atag.text.load

A function that loads the contents of a given URI into a string. This runs a HTTP get command.

.Parameters atag.text.load
|===
| name | type | description | default value

| uri | String | URI to be loaded |
| | | |
| return value | String | contents of that file |
|===

#### example

[source,cypher]
----
RETURN atag.text.load('http://www.regesta-imperii.de/id/1316-05-14_1_0_8_0_0_1_a')
----

### atag.text.import.html

Generate annotation nodes out of HTML tags.

.Parameters atag.text.import.html
|===
| name | type | description | default value

| startNode | node | start node containing html text |
| propertyKey | string | property name for html property | text
| label | string | label for new annotation nodes | Annotation
| plainTextProperty | string | property name for plain text | plainText
| relationshipType | string | relationship type between for annotation nodes | HAS_ANNOTATION

| | | |
| return value | node | new annotation nodes |
|===

#### example

[source,cypher]
----
CREATE (r:Text {identifier:'[RI XIII] H. 15 n. 101', summary:'Kg. F. teilt Kammerer und Rat der Stadt Regensburg mit, daß er als Vormund des Königs (von Böhmen und Ungarn) Ladislaus (Postumus) einerseits sowie die Brüder Hans und Heinrich, Hzz. zu Lüben (<em>Löbin</em>)<sup>1</sup>, andererseits glauben, Ansprüche auf die Länder und Städte Liegnitz und Goldberg<sup>2</sup> zu haben. Deshalb habe er auf den <em>nechsten montag nach sant Veits schierstkunftigen</em> (Juni 21) einen Tag nach Breslau angesetzt und an mehrere Fürsten, Herren und Mannen geschrieben, diesen Tag zu besuchen<sup>3</sup>. <em>Als richter</em> in dieser Angelegenheit habe er den Bf. Peter (Nowag) von Breslau <em>geordnet</em><sup>4</sup>; er bittet sie, ebenfalls eine Botschaft zu schicken, um Reinprecht von Ebersdorf und anderen, die er dorthin senden werde, <em>rat und beystand ze tun</em>. Er (Kg. F.) habe auch den Breslauern befohlen, ihnen hierzu Sicherheit und Geleit zu erteilen<sup>5</sup>.'});
MATCH (t:Text {identifier:'[RI XIII] H. 15 n. 101'})
CALL atag.text.import.html(t, 'summary', 'Annotation', 'text', 'HAS_ANNOTATION') YIELD node
RETURN node;
----

### atag.text.import.xml

Generate annotations from a property containing a (TEI) XML document.

.Parameters atag.text.import.xml
|===
| name | type | description | default value

| startNode | node | start node containing html text |
| propertyKey | string | property name for html property | text
| xpath expression | string | xpath used as a filter | /TEI/text/body//node()
| label | string | label for new annotation nodes | Annotation
| plainTextProperty | string | property name for plain text | plainText
| relationshipType | string | relationship type between for annotation nodes | HAS_ANNOTATION

| | | |
| return value | node | new annotation nodes |
|===

#### example

[source,cypher]
----
CREATE (t:Text{id:1, text: atag.text.load("https://git.thm.de/aksz15/teixml2spo/-/raw/master/patzig.xml")})
WITH t
CALL atag.text.import.xml(t, 'text', '/TEI/text/body//node()', 'Annotation', 'plainText') YIELD node
RETURN node
----
9 changes: 9 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,15 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
<version>${maven-site-plugin.version}</version>
<!--
<dependencies>
<dependency>
<groupId>io.github.devacfr.maven.skins</groupId>
<artifactId>reflow-velocity-tools</artifactId>
<version>2.3.4</version>
</dependency>
</dependencies>
-->
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
Expand Down
24 changes: 24 additions & 0 deletions src/site/markdown/atag.chains.chain.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# `atag.chains.chain`

## Description
A generic procedure to build a chain of nodes offering lots of flexibility.

## Parameters

| name | type | description | default value |
|----------------------|---------|-------------------------------------------------|---------------|
| text | string | string to be used for building a chain of nodes | |
| regex | string | separator regex pattern | |
| label | string | label for new nodes | |
| relType | string | relationship type used for the chain | |
| applyIndexProperties | boolean | whether to add startIndex/endIndex properties | |
| | | | |
| return value | Path | a path holding the created chain | |

NOTE: the regex parameter uses lookahead/lookbehind notation, see https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/regex/Pattern.html

## Examples

```cypher
CALL atag.chains.chain('what a nice text', '((?<=\\s)|(?=\\s))', 'Character', 'NEXT_CHARACTER', false) YIELD path RETURN path
```
30 changes: 30 additions & 0 deletions src/site/markdown/atag.chains.characterChain.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# `atag.chains.characterChain`

## Description

This procedure creates a chain of nodes, each representing a character of the input string.
Optionally the chain can be enriched with `startIndex` and `endIndex` properties indicating the position of the character in the input string.

## Parameters

| name | type | description | default value |
|--------------|---------|-----------------------------------------------------|---------------|
| text | String | string to be used for building a chain of nodes | |
| applyIndexes | boolean | if true, `startIndex/endIndex` properties are added | `false` |
| | | | |
| return value | Path | a path holding the created chain | |

## Examples

```cypher
CALL atag.chains.characterChain('what a nice text') YIELD path RETURN path;
```

The text can be taken from a node property:

```cypher
match (t:Text)
where t.text is not null
with t
CALL atag.chains.characterChain(t.text) yield path return path;
```
25 changes: 25 additions & 0 deletions src/site/markdown/atag.chains.fullChain.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# `atag.chains.fullChain`

## Description
The most complete procedure, creates both token and character chain.
Delegates internally to [atag.chains.tokenChain](atag.chains.tokenChain.html) and [atag.chain.characterChain](atag.chains.characterChain.html).
Interconnects the two chains appropriately.

## Parameters

| name | type | description | default value |
|--------------|---------|------------------------------------------------------------------------|---------------|
| start | Node | start node holding the text in a property | |
| propertyKey | string | property key | |
| applyIndexes | boolean | if true, `startIndex/endIndex` properties are added to character nodes | `false` |
| | | | |
| return value | void | | |

## Example

```cypher
CREATE (s:Text{text:'What a nice text'})
WITH s
CALL atag.chains.fullChain(s, 'text')
RETURN s
```
27 changes: 27 additions & 0 deletions src/site/markdown/atag.chains.tokenChain.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# `atag.chains.tokenChain`

## Description
Tokenizes a string and creates a chain of nodes, one for each token.
Uses regex `((?<=\W)|(?=\W))` for identifying tokens.

## Parameters

| name | type | description | default value |
|--------------|---------|-----------------------------------------------------|---------------|
| text | String | string to be used for building a chain of nodes | |
| applyIndexes | boolean | if true, `startIndex/endIndex` properties are added | `true` |
| | | | |
| return value | Path | a path holding the created chain | |

## Examples

```cypher
CALL atag.chains.tokenChain('what a nice text') YIELD path RETURN path;
```

```cypher
match (t:Text)
where t.text is not null
with t
CALL atag.chains.tokenChain(t.text) yield path return path;
```
25 changes: 25 additions & 0 deletions src/site/markdown/atag.text.import.html.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# `atag.text.import.html`

## Description

Generate annotation nodes out of HTML tags. The function takes a node containing html text and a property key for the html property. It returns new annotation nodes.
For HTML parsing the function uses the [jsoup](https://jsoup.org/) library.

| name | type | description | default value |
|-------------------|--------|------------------------------------------------|----------------|
| startNode | node | start node containing html text | |
| propertyKey | string | property name for html property | text |
| label | string | label for new annotation nodes | Annotation |
| plainTextProperty | string | property name for plain text | plainText |
| relationshipType | string | relationship type between for annotation nodes | HAS_ANNOTATION |
| | | | |
| return value | node | new annotation nodes | |

## Example

```cypher
CREATE (r:Text {identifier:'[RI XIII] H. 15 n. 101', summary:'Kg. F. teilt Kammerer und Rat der Stadt Regensburg mit, daß er als Vormund des Königs (von Böhmen und Ungarn) Ladislaus (Postumus) einerseits sowie die Brüder Hans und Heinrich, Hzz. zu Lüben (<em>Löbin</em>)<sup>1</sup>, andererseits glauben, Ansprüche auf die Länder und Städte Liegnitz und Goldberg<sup>2</sup> zu haben. Deshalb habe er auf den <em>nechsten montag nach sant Veits schierstkunftigen</em> (Juni 21) einen Tag nach Breslau angesetzt und an mehrere Fürsten, Herren und Mannen geschrieben, diesen Tag zu besuchen<sup>3</sup>. <em>Als richter</em> in dieser Angelegenheit habe er den Bf. Peter (Nowag) von Breslau <em>geordnet</em><sup>4</sup>; er bittet sie, ebenfalls eine Botschaft zu schicken, um Reinprecht von Ebersdorf und anderen, die er dorthin senden werde, <em>rat und beystand ze tun</em>. Er (Kg. F.) habe auch den Breslauern befohlen, ihnen hierzu Sicherheit und Geleit zu erteilen<sup>5</sup>.'});
MATCH (t:Text {identifier:'[RI XIII] H. 15 n. 101'})
CALL atag.text.import.html(t, 'summary', 'Annotation', 'text', 'HAS_ANNOTATION') YIELD node
RETURN node;
```
Loading

0 comments on commit 5718b20

Please sign in to comment.