Skip to content

Commit

Permalink
Deploying to gh-pages from @ bd3d6d3 🚀
Browse files Browse the repository at this point in the history
  • Loading branch information
Aethor committed Jul 18, 2024
1 parent ae52284 commit 1ffe19c
Show file tree
Hide file tree
Showing 10 changed files with 413 additions and 146 deletions.
7 changes: 6 additions & 1 deletion _sources/contributing.rst.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,9 @@ the ``tests`` directory. We use ``pytest`` to test code, and also use
``hypothesis`` when applicable. If you open a patch, make sure that
all tests are passing. In particular, do not rely on the CI, as it
does not run time costly tests! Check for yourself locally, using
``RENARD_TEST_ALL=1 python -m pytest tests``
``RENARD_TEST_ALL=1 python -m pytest tests``. Note that there are
specific tests and environment variable for optional dependencies such
as *stanza* (``RENARD_TEST_STANZA_OPTDEP``). These must be explicitely
set to ``1`` if you want to test optional dependencies, as
``RENARD_TEST_ALL=1`` does not enable test on these optional
dependencies.
6 changes: 4 additions & 2 deletions _sources/extending.rst.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@ Creating new steps

Usually, steps must implement at least four functions :

- :meth:`.PipelineStep.__init__`: is used to pass options at step init time
- :meth:`.PipelineStep.__call__`: is called at pipeline run time
- :meth:`.PipelineStep.__init__`: is used to pass options at step init
time. Options passed at step init time should be valid for a
collection of texts, and not be text specific.
- :meth:`.PipelineStep.__call__`: is called at pipeline run time.
- :meth:`.PipelineStep.needs`: declares the set of informations needed
from the pipeline state by this step. Each returned string should be
an attribute of :class:`.PipelineState`.
Expand Down
47 changes: 46 additions & 1 deletion _sources/pipeline.rst.txt
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ In that case, the ``tokens`` requirements is fulfilled at run time. If
you don't pass the parameter, Renard will throw the following
exception:

>>> ValueError: ["step 1 (NLTKNamedEntityRecognizer) has unsatisfied needs (needs : {'tokens'}, available : {'text'})"]
>>> ValueError: ["step 1 (NLTKNamedEntityRecognizer) has unsatisfied needs. needs: {'tokens'}. available: {'text'}). missing: {'tokens'}."]


For simplicity, one can use one of the preconfigured pipelines:
Expand Down Expand Up @@ -252,6 +252,51 @@ graph to a directory. Meanwhile,
dynamic graph to the Gephi format.


Custom Segmentation
-------------------

The ``dynamic_window`` parameter of
:class:`.CoOccurencesGraphExtractor` determines the segmentation of
the dynamic networks, in number of interactions. In the example above,
a new graph will be created for each 20 interactions.

While one can rely on the arguments of the graph extractor of the
pipeline to determine the dynamic window, Renard allows to specify a
custom segmentation of a text with the ``dynamic_blocks``
argument. When running a pipeline, you can cut your text however you
want and pass this argument instead of the usual text:


.. code-block:: python
from renard.pipeline import Pipeline
from renard.pipeline.tokenization import NLTKTokenizer
from renard.pipeline.ner import NLTKNamedEntityRecognizer
from renard.pipeline.character_unification import GraphRulesCharacterUnifier
from renard.pipeline.graph_extraction import CoOccurrencesGraphExtractor
from renard.utils import block_bounds
with open("./my_doc.txt") as f:
text = f.read()
# let's suppose the 'cut_into_chapters' function cut the text into chapters.
chapters = cut_into_chapters(text)
pipeline = Pipeline(
[
NLTKTokenizer(),
NLTKNamedEntityRecognizer(),
GraphRulesCharacterUnifier(),
CoOccurrencesGraphExtractor(co_occurrences_dist=25, dynamic=True)
]
)
# the 'block_bounds' function automatically extracts the boundaries of your
# block of text.
out = pipeline(text, dynamic_blocks=block_bounds(chapters))
Multilingual Support
====================

Expand Down
7 changes: 6 additions & 1 deletion contributing.html
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,12 @@ <h2>Code Quality Guidelines<a class="headerlink" href="#code-quality-guidelines"
<code class="docutils literal notranslate"><span class="pre">hypothesis</span></code> when applicable. If you open a patch, make sure that
all tests are passing. In particular, do not rely on the CI, as it
does not run time costly tests! Check for yourself locally, using
<code class="docutils literal notranslate"><span class="pre">RENARD_TEST_ALL=1</span> <span class="pre">python</span> <span class="pre">-m</span> <span class="pre">pytest</span> <span class="pre">tests</span></code></p>
<code class="docutils literal notranslate"><span class="pre">RENARD_TEST_ALL=1</span> <span class="pre">python</span> <span class="pre">-m</span> <span class="pre">pytest</span> <span class="pre">tests</span></code>. Note that there are
specific tests and environment variable for optional dependencies such
as <em>stanza</em> (<code class="docutils literal notranslate"><span class="pre">RENARD_TEST_STANZA_OPTDEP</span></code>). These must be explicitely
set to <code class="docutils literal notranslate"><span class="pre">1</span></code> if you want to test optional dependencies, as
<code class="docutils literal notranslate"><span class="pre">RENARD_TEST_ALL=1</span></code> does not enable test on these optional
dependencies.</p>
</section>
</section>

Expand Down
6 changes: 4 additions & 2 deletions extending.html
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,10 @@ <h1>Extending Renard<a class="headerlink" href="#extending-renard" title="Permal
<h2>Creating new steps<a class="headerlink" href="#creating-new-steps" title="Permalink to this headline"></a></h2>
<p>Usually, steps must implement at least four functions :</p>
<ul class="simple">
<li><p><a class="reference internal" href="reference.html#renard.pipeline.core.PipelineStep.__init__" title="renard.pipeline.core.PipelineStep.__init__"><code class="xref py py-meth docutils literal notranslate"><span class="pre">PipelineStep.__init__()</span></code></a>: is used to pass options at step init time</p></li>
<li><p><a class="reference internal" href="reference.html#renard.pipeline.core.PipelineStep.__call__" title="renard.pipeline.core.PipelineStep.__call__"><code class="xref py py-meth docutils literal notranslate"><span class="pre">PipelineStep.__call__()</span></code></a>: is called at pipeline run time</p></li>
<li><p><a class="reference internal" href="reference.html#renard.pipeline.core.PipelineStep.__init__" title="renard.pipeline.core.PipelineStep.__init__"><code class="xref py py-meth docutils literal notranslate"><span class="pre">PipelineStep.__init__()</span></code></a>: is used to pass options at step init
time. Options passed at step init time should be valid for a
collection of texts, and not be text specific.</p></li>
<li><p><a class="reference internal" href="reference.html#renard.pipeline.core.PipelineStep.__call__" title="renard.pipeline.core.PipelineStep.__call__"><code class="xref py py-meth docutils literal notranslate"><span class="pre">PipelineStep.__call__()</span></code></a>: is called at pipeline run time.</p></li>
<li><p><a class="reference internal" href="reference.html#renard.pipeline.core.PipelineStep.needs" title="renard.pipeline.core.PipelineStep.needs"><code class="xref py py-meth docutils literal notranslate"><span class="pre">PipelineStep.needs()</span></code></a>: declares the set of informations needed
from the pipeline state by this step. Each returned string should be
an attribute of <a class="reference internal" href="reference.html#renard.pipeline.core.PipelineState" title="renard.pipeline.core.PipelineState"><code class="xref py py-class docutils literal notranslate"><span class="pre">PipelineState</span></code></a>.</p></li>
Expand Down
30 changes: 20 additions & 10 deletions genindex.html
Original file line number Diff line number Diff line change
Expand Up @@ -222,19 +222,19 @@ <h2 id="_">_</h2>
</li>
<li><a href="reference.html#renard.pipeline.corefs.SpacyCorefereeCoreferenceResolver._coreferee_get_mention_tokens">_coreferee_get_mention_tokens() (renard.pipeline.corefs.SpacyCorefereeCoreferenceResolver static method)</a>
</li>
<li><a href="reference.html#renard.pipeline.graph_extraction.CoOccurrencesGraphExtractor._extract_dynamic_graph">_extract_dynamic_graph() (renard.pipeline.graph_extraction.CoOccurrencesGraphExtractor method)</a>
<li><a href="reference.html#renard.pipeline.graph_extraction.CoOccurrencesGraphExtractor._create_co_occurrences_blocks">_create_co_occurrences_blocks() (renard.pipeline.graph_extraction.CoOccurrencesGraphExtractor method)</a>
</li>
<li><a href="reference.html#renard.pipeline.graph_extraction.CoOccurrencesGraphExtractor._extract_gephi_dynamic_graph">_extract_gephi_dynamic_graph() (renard.pipeline.graph_extraction.CoOccurrencesGraphExtractor method)</a>
<li><a href="reference.html#renard.pipeline.graph_extraction.CoOccurrencesGraphExtractor._extract_dynamic_graph">_extract_dynamic_graph() (renard.pipeline.graph_extraction.CoOccurrencesGraphExtractor method)</a>
</li>
<li><a href="reference.html#renard.pipeline.graph_extraction.CoOccurrencesGraphExtractor._extract_graph">_extract_graph() (renard.pipeline.graph_extraction.CoOccurrencesGraphExtractor method)</a>
</li>
<li><a href="reference.html#renard.pipeline.graph_extraction.CoOccurrencesGraphExtractor._mentions_interact">_mentions_interact() (renard.pipeline.graph_extraction.CoOccurrencesGraphExtractor method)</a>
</li>
<li><a href="reference.html#renard.pipeline.core.Pipeline._non_ignored_steps">_non_ignored_steps() (renard.pipeline.core.Pipeline method)</a>
</li>
<li><a href="reference.html#renard.pipeline.character_unification.GraphRulesCharacterUnifier._pipeline_init_">_pipeline_init_() (renard.pipeline.character_unification.GraphRulesCharacterUnifier method)</a>

<ul>
<li><a href="reference.html#renard.pipeline.character_unification.NaiveCharacterUnifier._pipeline_init_">(renard.pipeline.character_unification.NaiveCharacterUnifier method)</a>
</li>
<li><a href="reference.html#renard.pipeline.core.PipelineStep._pipeline_init_">(renard.pipeline.core.PipelineStep method)</a>
</li>
<li><a href="reference.html#renard.pipeline.corefs.BertCoreferenceResolver._pipeline_init_">(renard.pipeline.corefs.BertCoreferenceResolver method)</a>
Expand All @@ -244,9 +244,11 @@ <h2 id="_">_</h2>
<li><a href="reference.html#renard.pipeline.ner.BertNamedEntityRecognizer._pipeline_init_">(renard.pipeline.ner.BertNamedEntityRecognizer method)</a>
</li>
<li><a href="reference.html#renard.pipeline.speaker_attribution.BertSpeakerDetector._pipeline_init_">(renard.pipeline.speaker_attribution.BertSpeakerDetector method)</a>
</li>
<li><a href="reference.html#renard.pipeline.tokenization.NLTKTokenizer._pipeline_init_">(renard.pipeline.tokenization.NLTKTokenizer method)</a>
</li>
</ul></li>
<li><a href="reference.html#renard.pipeline.core.Pipeline._pipeline_init_steps">_pipeline_init_steps() (renard.pipeline.core.Pipeline method)</a>
<li><a href="reference.html#renard.pipeline.core.Pipeline._pipeline_init_steps_">_pipeline_init_steps_() (renard.pipeline.core.Pipeline method)</a>
</li>
<li><a href="reference.html#renard.pipeline.corefs.SpacyCorefereeCoreferenceResolver._spacy_try_infer_spaces">_spacy_try_infer_spaces() (renard.pipeline.corefs.SpacyCorefereeCoreferenceResolver static method)</a>
</li>
Expand All @@ -270,29 +272,33 @@ <h2 id="B">B</h2>
</li>
<li><a href="reference.html#renard.pipeline.ner.BertNamedEntityRecognizer.batch_labels">batch_labels() (renard.pipeline.ner.BertNamedEntityRecognizer method)</a>
</li>
</ul></td>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="reference.html#renard.pipeline.corefs.BertCoreferenceResolver">BertCoreferenceResolver (class in renard.pipeline.corefs)</a>
</li>
</ul></td>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="reference.html#renard.pipeline.ner.BertNamedEntityRecognizer">BertNamedEntityRecognizer (class in renard.pipeline.ner)</a>
</li>
<li><a href="reference.html#renard.pipeline.speaker_attribution.BertSpeakerDetector">BertSpeakerDetector (class in renard.pipeline.speaker_attribution)</a>
</li>
<li><a href="reference.html#renard.utils.block_bounds">block_bounds() (in module renard.utils)</a>
</li>
<li><a href="reference.html#renard.utils.BlockBounds">BlockBounds (in module renard.utils)</a>
</li>
</ul></td>
</tr></table>

<h2 id="C">C</h2>
<table style="width: 100%" class="indextable genindextable"><tr>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="reference.html#renard.pipeline.core.PipelineState.chapter_tokens">chapter_tokens (renard.pipeline.core.PipelineState attribute)</a>
</li>
<li><a href="reference.html#renard.pipeline.core.PipelineState.chapters">chapters (renard.pipeline.core.PipelineState attribute)</a>
<li><a href="reference.html#renard.pipeline.core.PipelineState.char2token">char2token (renard.pipeline.core.PipelineState attribute)</a>
</li>
<li><a href="reference.html#renard.pipeline.character_unification.Character">Character (class in renard.pipeline.character_unification)</a>
</li>
<li><a href="reference.html#renard.pipeline.core.PipelineState.character_network">character_network (renard.pipeline.core.PipelineState attribute)</a>
</li>
<li><a href="reference.html#renard.pipeline.core.PipelineState.characters">characters (renard.pipeline.core.PipelineState attribute)</a>
</li>
<li><a href="reference.html#renard.utils.charbb2tokenbb">charbb2tokenbb() (in module renard.utils)</a>
</li>
<li><a href="reference.html#renard.pipeline.core.Pipeline.check_valid">check_valid() (renard.pipeline.core.Pipeline method)</a>
</li>
Expand Down Expand Up @@ -320,6 +326,8 @@ <h2 id="D">D</h2>
</li>
</ul></td>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="reference.html#renard.pipeline.core.PipelineState.dynamic_blocks">dynamic_blocks (renard.pipeline.core.PipelineState attribute)</a>
</li>
<li><a href="reference.html#renard.graph_utils.dynamic_graph_to_gephi_graph">dynamic_graph_to_gephi_graph() (in module renard.graph_utils)</a>
</li>
</ul></td>
Expand Down Expand Up @@ -492,6 +500,8 @@ <h2 id="P">P</h2>
<table style="width: 100%" class="indextable genindextable"><tr>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="reference.html#renard.pipeline.core.Pipeline">Pipeline (class in renard.pipeline.core)</a>
</li>
<li><a href="reference.html#renard.pipeline.core.Pipeline.PipelineParameter">PipelineParameter (renard.pipeline.core.Pipeline attribute)</a>
</li>
<li><a href="reference.html#renard.pipeline.core.PipelineState">PipelineState (class in renard.pipeline.core)</a>
</li>
Expand Down
Binary file modified objects.inv
Binary file not shown.
Loading

0 comments on commit 1ffe19c

Please sign in to comment.