Skip to content

Commit

Permalink
Merge pull request #156 from informagi/hello_world
Browse files Browse the repository at this point in the history
Add hello world example to readme
  • Loading branch information
hasibi authored Sep 4, 2023
2 parents a61bfc0 + bee2fe6 commit 0de828d
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
36 changes: 36 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,42 @@ ed_result = requests.post(API_URL, json={
}).json()
```

## Using REL as a Python package

You can also use REL as a Python package. See the *hello world* example below for how to get started. For more examples, have a look at the [documentation](https://rel.readthedocs.io/en/latest/tutorials/).

```pycon
from REL.mention_detection import MentionDetection
from REL.utils import process_results
from REL.entity_disambiguation import EntityDisambiguation
from REL.ner import Cmns, load_flair_ner

wiki_version = "wiki_2014"
base_url = "C:/path/to/rel_data"

input_text = {
"my_doc": ("Hello, world!", []),
}

mention_detection = MentionDetection(base_url, wiki_version)
tagger_ner = load_flair_ner("ner-fast")

tagger_ngram = Cmns(base_url, wiki_version, n=5)
mentions, n_mentions = mention_detection.find_mentions(input_text, tagger_ngram)

config = {
"mode": "eval",
"model_path": "ed-wiki-2014",
}
model = EntityDisambiguation(base_url, wiki_version, config)

predictions, timing = model.predict(mentions)
result = process_results(mentions, predictions, input_text)
print(result)
# {'my_doc': [(0, 13, 'Hello, world!', 'Hello_world_program', 0.6534378618767961, 182, '#NGRAM#')]}
```


## Installation

This section describes how to deploy REL on a local machine and setup the API. If you want to do anything more than simply running our API locally, you can skip the Docker steps and continue with installation from source.
Expand Down
2 changes: 1 addition & 1 deletion docs/tutorials/e2e_entity_linking.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ from REL.entity_disambiguation import EntityDisambiguation
from REL.ner import Cmns, load_flair_ner

wiki_version = "wiki_2014"
```
```

The code below serves as an example as to how users should format their dataset. This should obviously be replaced
and should not be used in production, although the outcome is the `input_text` variable that will be used throughout this
Expand Down

0 comments on commit 0de828d

Please sign in to comment.