pychronicles 0.1.6__tar.gz → 0.2.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. {pychronicles-0.1.6/pychronicles.egg-info → pychronicles-0.2.0}/PKG-INFO +82 -78
  2. pychronicles-0.2.0/README.md +362 -0
  3. {pychronicles-0.1.6 → pychronicles-0.2.0}/pychronicles/__init__.py +3 -2
  4. {pychronicles-0.1.6 → pychronicles-0.2.0}/pychronicles/abstraction.py +59 -30
  5. pychronicles-0.2.0/pychronicles/chronicle.py +1268 -0
  6. pychronicles-0.2.0/pychronicles/fchronicle.py +504 -0
  7. {pychronicles-0.1.6 → pychronicles-0.2.0}/pychronicles/mtlformula.py +48 -7
  8. {pychronicles-0.1.6 → pychronicles-0.2.0}/pychronicles/pandas_tpatterns.py +149 -87
  9. {pychronicles-0.1.6 → pychronicles-0.2.0}/pychronicles/timedsequence.py +61 -22
  10. {pychronicles-0.1.6 → pychronicles-0.2.0}/pychronicles/utils.py +38 -24
  11. {pychronicles-0.1.6 → pychronicles-0.2.0/pychronicles.egg-info}/PKG-INFO +82 -78
  12. {pychronicles-0.1.6 → pychronicles-0.2.0}/pychronicles.egg-info/SOURCES.txt +6 -2
  13. {pychronicles-0.1.6 → pychronicles-0.2.0}/pychronicles.egg-info/requires.txt +1 -0
  14. {pychronicles-0.1.6 → pychronicles-0.2.0}/pyproject.toml +14 -3
  15. {pychronicles-0.1.6 → pychronicles-0.2.0}/setup.py +1 -1
  16. pychronicles-0.2.0/tests/test_abstraction.py +138 -0
  17. pychronicles-0.2.0/tests/test_chronicle.py +1012 -0
  18. pychronicles-0.2.0/tests/test_fchronicle.py +312 -0
  19. pychronicles-0.2.0/tests/test_mtlformula.py +52 -0
  20. pychronicles-0.2.0/tests/test_pandas_tpatterns.py +226 -0
  21. pychronicles-0.2.0/tests/test_projection.py +60 -0
  22. pychronicles-0.2.0/tests/test_timedsequences.py +154 -0
  23. pychronicles-0.2.0/tests/test_utils_crs.py +95 -0
  24. pychronicles-0.1.6/README.md +0 -360
  25. pychronicles-0.1.6/pychronicles/chronicle.py +0 -1135
  26. pychronicles-0.1.6/pychronicles/fchronicle.py +0 -357
  27. pychronicles-0.1.6/tests/test_abstraction.py +0 -50
  28. pychronicles-0.1.6/tests/test_pandas.py +0 -58
  29. pychronicles-0.1.6/tests/test_projection.py +0 -60
  30. pychronicles-0.1.6/tests/test_timedsequences.py +0 -147
  31. {pychronicles-0.1.6 → pychronicles-0.2.0}/LICENCE.txt +0 -0
  32. {pychronicles-0.1.6 → pychronicles-0.2.0}/MANIFEST.in +0 -0
  33. {pychronicles-0.1.6 → pychronicles-0.2.0}/pychronicles.egg-info/dependency_links.txt +0 -0
  34. {pychronicles-0.1.6 → pychronicles-0.2.0}/pychronicles.egg-info/top_level.txt +0 -0
  35. {pychronicles-0.1.6 → pychronicles-0.2.0}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.4
2
2
  Name: pychronicles
3
- Version: 0.1.6
3
+ Version: 0.2.0
4
4
  Summary: A package for chronicle recognition.
5
5
  Author-email: Thomas Guyet <thomas.guyet@inria.fr>
6
6
  Maintainer-email: Thomas Guyet <thomas.guyet@inria.fr>
@@ -202,6 +202,8 @@ Requires-Dist: build; extra == "build"
202
202
  Requires-Dist: twine; extra == "build"
203
203
  Provides-Extra: dev
204
204
  Requires-Dist: pytest; extra == "dev"
205
+ Requires-Dist: pytest-cov; extra == "dev"
206
+ Dynamic: license-file
205
207
 
206
208
  ---
207
209
  title: README
@@ -211,18 +213,19 @@ author: Thomas Guyet
211
213
  [![PyPI version](https://badge.fury.io/py/pychronicles.svg)](https://badge.fury.io/py/pychronicles)
212
214
  [![Downloads](https://static.pepy.tech/badge/pychronicles)](https://pepy.tech/project/pychronicles)
213
215
  [![GitHub license](https://img.shields.io/static/v1?label=Licence&message=LGPL-3&color=green)](https://www.gnu.org/licenses/lgpl-3.0.txt)
214
-
216
+ [![coverage report](https://gitlab.inria.fr/tguyet/pychronicles/badges/master/coverage.svg)](https://gitlab.inria.fr/tguyet/pychronicles/-/commits/master)
217
+ [![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/git/https%3A%2F%2Fgitlab.inria.fr%2Ftguyet%2Fpychronicles/HEAD?labpath=examples%2Fcarepathway_example.ipynb)
215
218
 
216
219
  # PyChronicles package
217
220
 
218
- A chronicle is a specification of the complex temporal behaviors as a graph of temporal constraints. More specifically, a chronicle is a multiset of events and a set of temporal constraints specifying that occurrences of pairs of events must occurs within a given temporal interval.
219
- It can be used to recognize complex behaviors in sequence the temporal events.
220
- PyChronicle is now compatible with Pandas and makes chronicle features [available on dataframes](#dataframe-accessor) representing timed sequences.
221
+ A chronicle is a specification of complex temporal behaviors as a graph of temporal constraints. More specifically, a chronicle is a multiset of events and a set of temporal constraints specifying that the occurrences of pairs of events must occur within given temporal intervals.
222
+ It can be used to recognize complex behaviors in sequences of temporal events.
223
+ PyChronicles is now compatible with Pandas and makes chronicle features [available on dataframes](#dataframe-accessor) representing timed sequences.
221
224
 
222
- This library proposes a Python class to define a timed sequence, a chronicle, to read/save them in a standard CRS format. The main useful functionnality for chronicle is their efficient matching in a timed sequence, or pandas dataframes (including an accessor).
223
- The Abstracter class enables to create a chronicle from a collection of sequences.
225
+ This library provides Python classes to define timed sequences and chronicles, and to read/save chronicles in the standard CRS format. The main functionality for chronicles is their efficient matching in timed sequences, or in pandas dataframes (through an accessor).
226
+ The `Abstracter` class makes it possible to create a chronicle from a collection of sequences.
224
227
 
225
- For more details about the usage of this package, have a look at the [documentation](https://tguyet.gitlabpages.inria.fr/pychronicles/). And for more (formal) information about the temporal model of chronicle, see our [book](https://link.springer.com/book/10.1007/978-3-031-33693-5) and :
228
+ For more details about the usage of this package, have a look at the [documentation](https://tguyet.gitlabpages.inria.fr/pychronicles/). For more (formal) information about the temporal model of chronicles, see our [book](https://link.springer.com/book/10.1007/978-3-031-33693-5):
226
229
  ~~~bibtex
227
230
  @book{chroniclesbook,
228
231
  title = {Chronicles: Formalization of a Temporal Model},
@@ -235,7 +238,7 @@ For more details about the usage of this package, have a look at the [documentat
235
238
 
236
239
  ## Package installation
237
240
 
238
- The [PyChronicles package](https://pypi.org/project/hydronaut) is available in [Python Package Index](https://pypi.org/) and can be installed using any standard Python package manager.
241
+ The [PyChronicles package](https://pypi.org/project/pychronicles) is available in the [Python Package Index](https://pypi.org/) and can be installed using any standard Python package manager.
239
242
  ~~~sh
240
243
  pip install pychronicles
241
244
  ~~~
@@ -249,14 +252,14 @@ pip install -r requirements.txt
249
252
  pip install --upgrade .
250
253
  ~~~
251
254
 
252
- You can also use pip to install the repo from sources. For instance, run the following commands:
255
+ Alternatively, you can install the repository from sources with pip only:
253
256
  ~~~sh
254
257
  git clone --recursive https://gitlab.inria.fr/tguyet/pychronicles
255
258
  cd pychronicles
256
259
  pip install .
257
260
  ~~~
258
261
 
259
- In case you want to visualize chronicles, you will need to install manually the `networkx` and `matplotlib`. By default, they are not installed and the plotting functions is disabled.
262
+ In case you want to visualize chronicles, you need to install `networkx` and `matplotlib` manually. By default, they are not installed and the plotting function is disabled.
260
263
  ~~~sh
261
264
  pip install networkx matplotlib
262
265
  ~~~
@@ -264,20 +267,21 @@ pip install networkx matplotlib
264
267
  ## Basic Usage Example
265
268
 
266
269
  ```python
267
- import pychonicles
270
+ import numpy as np
271
+ from pychronicles import TimedSequence, Chronicle
268
272
 
269
273
  # create a timed sequence
270
274
  seq = [('a',1),('c',2),('b',3),('a',8)]
271
- ts = TimedSequence(np.array([e[2] for e in seq], dtype='float'), [e[0] for e in seq])
275
+ ts = TimedSequence(np.array([e[1] for e in seq], dtype='float'), np.array([e[0] for e in seq]))
272
276
 
273
- #create a chronicle
277
+ # create a chronicle
274
278
  c=Chronicle()
275
279
  c.add_event(0,'a')
276
280
  c.add_event(1,'b')
277
281
  c.add_constraint(0,1, (0.4,2.3))
278
282
 
279
283
  reco=c.match(ts)
280
- print(f"Does the chronicle matches the sequence? [{reco}]")
284
+ print(f"Does the chronicle match the sequence? [{reco}]")
281
285
 
282
286
  reco=c.recognize(ts)
283
287
  print(f"What are the occurrences of the chronicle in the sequence? [{reco}]")
@@ -286,46 +290,46 @@ print(f"What are the occurrences of the chronicle in the sequence? [{reco}]")
286
290
 
287
291
  ## Efficient chronicle recognition
288
292
 
289
- The chronicle recognition package is a pure python package implemented using numpy features. To make it more efficient, it is possible to compile a cythonized version.
293
+ The chronicle recognition package is a pure Python package implemented using numpy features.
290
294
 
291
295
  ### Timed Sequences
292
296
 
293
- A timed sequence is be created from different manners:
294
- * a pair of lists containing the events and the dates.
295
- * a simple list of items (`str`, `int` or `None`) with implicit timestamps : `['a', 'b', ..., None, 'c', None, 'd']`. In this case, `None` means that there is no event at the corresponding time instant.
296
- * a list of explicitly timestamped items (`str` or `int`) : `[ (1,'a'), (23,'b'), (30,'c'), (45, 'd')]`
297
+ A timed sequence is created from a pair of arrays: a numpy array containing the dates, and an array containing the events (with the same length).
297
298
 
298
- The dates can be represented with dates (only with `np.datetime64` type) or floats. In case the dates are coded as `int`, they will be converted in `float`.
299
+ The dates can be represented with dates (only with the `np.datetime64` type) or with floats. Integer dates must be converted into floats (the pandas accessor does it automatically).
299
300
 
300
- The type of events must be `str` or `int`.
301
+ The type of the events must be `str` or `int`.
301
302
 
302
303
  _Usage Example_:
303
304
  ```python
304
305
  >>> seq = [('a',1),('c',2),('b',3),('a',8),('a',10),('b',12),('a',15),('c',17), ('b',20),('c',23),('c',25),('b',26),('c',28),('b',30)]
305
306
  >>> dates = np.array([np.datetime64('1970-01-01') + np.timedelta64(e[1],'D') for e in seq], dtype='datetime64')
306
307
  >>> data = np.array([e[0] for e in seq])
307
- >>> ts = TimedSequence(dates, data)
308
+ >>> ts = TimedSequence(dates, data)
308
309
  ```
309
310
 
310
311
  ### Chronicles
311
312
 
312
- The core of the this package is the chronicle class that represents a chronicle temporal model which also offers efficient matching functionalities.
313
+ The core of this package is the `Chronicle` class, which represents the chronicle temporal model and offers efficient matching functionalities.
313
314
 
314
315
 
315
- The chronicles handles two models of time (that must be consistent with the model of time in timed sequences):
316
- * discrete timestamps using floats
317
- * continuous timestamps using `datetime64` format. In this case the temporal constraints of a chronicle must be defined using `np.timedelta64` values.
316
+ Chronicles handle two models of time (which must be consistent with the model of time of the timed sequences):
317
+ * numerical timestamps using floats,
318
+ * dates using the `datetime64` format. In this case, the temporal constraints of a chronicle must be defined using `np.timedelta64` values.
318
319
 
319
- A chronicle can not combine constraints of the two different kinds. The first defined constraint defines the model of time of the chronicle.
320
+ A chronicle cannot combine constraints of the two different kinds. The first defined constraint defines the model of time of the chronicle.
320
321
 
321
322
  <br>
322
323
 
323
- The package implements efficient algorithms to recognize it. It benefits from numpy functionalities to increase their efficiency. There are three different ways to _recognize_ a chronicle in a sequence of a events:
324
+ The package implements efficient algorithms to recognize chronicles. There are three different ways to _recognize_ a chronicle in a sequence of events:
325
+
326
+ * the absence/presence recognition (`c.match(seq)`): its result is a boolean stating whether the chronicle occurs at least once in the sequence. This is the most efficient algorithm, as it stops as soon as an occurrence is found.
327
+ * the occurrence enumeration (`c.recognize(seq)`): its result is the list of the occurrences of the chronicle in the sequence. Contrary to the first function, it looks for all the possible combinations of events. Thus, it is less efficient, but more informative.
328
+ * the lazy occurrence enumeration (`c.iter_recognize(seq)`): it returns an iterator over the same occurrences, which are computed on demand. This is useful to process the occurrences one at a time, or to stop the enumeration early.
324
329
 
325
- * the absence/presence recognition (`c.match(seq)`): its result is a boolean stating whether the chronicle occur at least once in the sequence, this is the most efficient algorithm
326
- * the occurrence enumeration (`c.recognize(seq)`): its result is a list of occurrences of the chronicle in a sequence. Contrary to the first function, it looks for all possible combination of events. Thus it is less efficient, but more informative.
330
+ In an occurrence, two identical events of a chronicle cannot match the same event of the sequence.
327
331
 
328
- Note that a chronicle is somehow similar to a simple temporal network and the set of constraints may be inconsistent or redundant. It is possible to _minimize_ the temporal constraints of a chronicle using the corresponding function.
332
+ Note that a chronicle is somehow similar to a simple temporal network, and the set of constraints may be inconsistent or redundant. It is possible to _minimize_ the temporal constraints of a chronicle using the corresponding function.
329
333
 
330
334
  ```python
331
335
  >>> c=Chronicle()
@@ -358,16 +362,16 @@ You can also depict a chronicle as a matplotlib graph:
358
362
 
359
363
  ### Fuzzy chronicles
360
364
 
361
- The `FuzzyChronicle` class represents a class for approximated recognition of a chronicle. The chronicle is defined in the same way of a chronicle.
362
- The temporal model is enriched with the modeling of a fuzzyness of temporal constraints (`lbda` parameter)
365
+ The `FuzzyChronicle` class enables the approximate recognition of a chronicle. A fuzzy chronicle is defined in the same way as a chronicle.
366
+ The temporal model is enriched with the modeling of the fuzziness of the temporal constraints (`lbda` parameter).
363
367
 
364
- In addition to the matching function presented above, it proposes a `cmp` function that finds occurrences of a chronicle with a degree of matching (parameter `threshold`).
368
+ In addition to the matching functions presented above, it provides a `cmp` function that finds all the occurrences of a chronicle whose degree of matching is above a threshold (parameter `threshold`), together with their similarity. The `iter_cmp` function is its lazy version.
365
369
 
366
- More details about fuzzy chroniclesis available in the [article](https://hal.archives-ouvertes.fr/hal-03698361) (in French):
370
+ More details about fuzzy chronicles are available in the [article](https://inria.hal.science/hal-02422796v1) (in French):
367
371
  ```bibtex
368
372
  @inproceedings{fchronicles,
369
373
  title = {{\'E}num{\'e}ration des occurrences d'une chronique},
370
- author = {Guyet, Thomas and Besnard, Philippe and Ben Salha, Nasreddine and Samet, Ahmed and Lachiche, Nicolas},
374
+ author = {Guyet, Thomas and Besnard, Philippe and Samet, Ahmed and Ben Salha, Nasreddine and Lachiche, Nicolas},
371
375
  booktitle = {Actes de la conférence Extraction et Gestion des Connaissances},
372
376
  publisher = {{\'E}ditions RNTI},
373
377
  pages = {253--260},
@@ -377,29 +381,29 @@ More details about fuzzy chroniclesis available in the [article](https://hal.arc
377
381
 
378
382
  # Dataframe accessor
379
383
 
380
- The `pychronicles` package include an new accessor for pandas dataframe.
381
- This accessor enables, denoted `tpattern` to use chronicle functionnalities directly with the pandas packages. In this case, you do not even need to manage your timed sequences by hand ... everything can be done directly with pandas.
384
+ The `pychronicles` package includes a new accessor for pandas dataframes.
385
+ This accessor, denoted `tpattern`, makes it possible to use chronicle functionalities directly with pandas. In this case, you do not even need to manage your timed sequences by hand: everything can be done directly with pandas.
382
386
 
383
387
  The pandas accessor enables:
384
388
 
385
389
  * to match or enumerate occurrences of a chronicle
386
- * to match an Metric Temporal Logic (MTL) formula
390
+ * to match a Metric Temporal Logic (MTL) formula
387
391
  * to abstract a collection of sequences
388
392
  * to extract the delays of matching occurrences of a chronicle
389
393
 
390
394
 
391
395
  ## Spirit of the accessor
392
396
 
393
- The spirit of our accessor is to use a pandas dataframe to encode a sequence or a collection of sequence. The index of the dataframe models the time ... it can be integer, float or date index.
397
+ The spirit of our accessor is to use a pandas dataframe to encode a sequence or a collection of sequences. The index of the dataframe models the time: it can be an integer, float or date index.
394
398
 
395
- A column of the dataframe acn be defined to specify the identifier of the sequence. In the following example, the column name `id` denotes this identifier. Intuitivelly, it can be used to make `groupby` operations, to process a collection of timed sequences.
399
+ A column of the dataframe can be defined to specify the identifier of the sequences. In the following example, the column named `id` denotes this identifier. Intuitively, it can be used to make `groupby` operations, to process a collection of timed sequences.
396
400
 
397
- The important feature of our package is that any other column can be added to the dataframe. The idea behind this modeling is that the dataframe gather all the information about the events. The columns describes each event (an can contain `None`).
401
+ The important feature of our package is that any other column can be added to the dataframe. The idea behind this modeling is that the dataframe gathers all the information about the events. The columns describe each event (and can contain `None`).
398
402
 
399
403
 
400
- The example below illustrates the representation of a collection of sequences with a Pandas dataframe.
401
- The basic sequence is repeated three times to create a collection of three timed sequences. The index of the dataframe is defined with dates in this case.
402
- The event names of the basic sequence feed the column `label`, and we added two columns:
404
+ The example below illustrates the representation of a collection of sequences with a Pandas dataframe.
405
+ The basic sequence is repeated three times to create a collection of three timed sequences. In this case, the index of the dataframe is defined with dates.
406
+ The event names of the basic sequence feed the column `label`, and we added three columns:
403
407
 
404
408
 
405
409
  * a column `str_val` with the string values (twice the label)
@@ -407,7 +411,7 @@ The event names of the basic sequence feed the column `label`, and we added two
407
411
  * a column `id` that represents the identifier of a sequence.
408
412
 
409
413
  ```python
410
- #create a basic sequence
414
+ # create a basic sequence
411
415
  seq = [('a',1),('c',2),('b',3),('a',8),('a',10),('b',12),('a',15),('c',17)]
412
416
  df = pd.DataFrame({
413
417
  "label": [e[0] for e in seq]*3,
@@ -421,19 +425,19 @@ df = pd.DataFrame({
421
425
 
422
426
  <br>
423
427
 
424
- Then, the definition of the event of a chronicle are no more the name of an event, but the description of a event of interest throught its description features.
425
- When used with pandas dataframe, the events of a chronicle are queries on the dataframe.
428
+ Then, the events of a chronicle are no longer event names, but descriptions of the events of interest through their features.
429
+ When used with pandas dataframes, the events of a chronicle are queries on the dataframe.
426
430
  In the example above, an event could be defined by "`label=='a' & num_val>3`".
427
431
 
428
- At the time, our framework handles string and number attributes. The specification of an event uses the classical operators defined in the [Pandas documentation](https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.query.html).
432
+ For the time being, our framework handles string and number attributes. The specification of an event uses the classical operators defined in the [Pandas documentation](https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.query.html).
429
433
 
430
- ## Matching / enumerate occurrences of a chronicle
434
+ ## Matching / enumerating the occurrences of a chronicle
431
435
 
432
- Let us now use a dataframe defined as explained in the previous section with chronicle.
436
+ Let us now use a dataframe defined as explained in the previous section with a chronicle.
433
437
 
434
- For that, we first need to define a chronicle. It works exactly as before but, the definition of chronicle's events are queries.
438
+ For that, we first need to define a chronicle. It works exactly as before, but the chronicle's events are defined by queries.
435
439
 
436
- For instance, the following example illustrates the definition a simple chronicle that uses queries as event:
440
+ For instance, the following example illustrates the definition of a simple chronicle that uses queries as events:
437
441
  ```python
438
442
  c=Chronicle()
439
443
  c.add_event(0,'label=="a"')
@@ -443,24 +447,24 @@ c.add_constraint(0,1, (np.timedelta64(4,'D'),np.timedelta64(10,'D')))
443
447
 
444
448
  For more details about the syntax of queries, please refer to the [Pandas documentation](https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.query.html).
445
449
 
446
- This chronicle is semantically sound for being used in with the dataframe defined in the example of the previous section.
450
+ This chronicle is semantically sound to be used with the dataframe defined in the example of the previous section.
447
451
 
448
452
  ### Dataframe representing a sequence
449
453
 
450
454
  In this section, we consider that the dataframe represents a unique sequence (for instance, we selected the first sequence of the previous dataframe with `df[df.id==1]`).
451
455
 
452
- The recognition functionalities are now accessible throught the Pandas dataframe:
456
+ The recognition functionalities are now accessible through the Pandas dataframe:
453
457
 
454
- * `df.tpattern.match(c)` will return a boolean indicating whether the chronicle occurs in the sequence or not
455
- * `df.tpattern.recognize(c)` will return the list of occurrences of `c` in the sequence
456
- * `df.tpattern.project(c)` will return the list of delays for the temporal constraints of the chronicle `c`
458
+ * `df.tpattern.match(c)` returns a boolean indicating whether the chronicle occurs in the sequence or not
459
+ * `df.tpattern.recognize(c)` returns the list of the occurrences of `c` in the sequence (`df.tpattern.iter_recognize(c)` is its lazy version)
460
+ * `df.tpattern.project(c)` returns a dataframe with the delays of the temporal constraints of the chronicle `c` in each of its occurrences
457
461
 
458
462
  Note that the `tpattern` keyword gives access to the features of our package.
459
463
 
460
464
  <br>
461
465
 
462
- Using chronicles becomes very easy with Pandas dataframe and it also gains in expressivity thanks to the use of queries as event.
463
- We keep good computational efficiency of the recognition algorithms thanks to the use of the rewritting principle developed with semantic chronicles (see reference below).
466
+ Using chronicles becomes very easy with Pandas dataframes, and they also gain in expressivity thanks to the use of queries as events.
467
+ We keep a good computational efficiency of the recognition algorithms thanks to the rewriting principle developed with semantic chronicles (see the reference below).
464
468
 
465
469
  ```bibtex
466
470
  @inproceedings{semantic_chronicles,
@@ -474,20 +478,20 @@ We keep good computational efficiency of the recognition algorithms thanks to th
474
478
 
475
479
  ### Dataframe representing a collection of sequences
476
480
 
477
- To proceed with a dataframe containing several sequences, you can use the following idioms based on `apply`:
481
+ To process a dataframe containing several sequences, you can use the following idiom based on `apply`:
478
482
 
479
483
  ```python
480
484
  reco=df.groupby('id').apply(lambda d: d.tpattern.match(c))
481
485
  ```
482
486
 
483
487
  In this case, the attribute `id` is used to select the events for each sequence, and then the `match` algorithm is applied to this selection.
484
- The result is a dataframe containing a boolean value for each sequence id.
488
+ The result is a pandas series containing a boolean value for each sequence id.
485
489
 
486
- The same applies with `recognition` function.
490
+ The same applies to the `recognize` function.
487
491
 
488
- ## Use of MTL formula
492
+ ## Use of MTL formulas
489
493
 
490
- For situation recognitinon, there are strong connection between chronicles and metric temporal logics such as MTL or TPTL. See the [article](https://hal.archives-ouvertes.fr/hal-03777471):
494
+ For situation recognition, there are strong connections between chronicles and metric temporal logics such as MTL or TPTL. See the [article](https://hal.archives-ouvertes.fr/hal-03777471):
491
495
  ~~~bibtex
492
496
  @inproceedings{chronicle_templogics,
493
497
  title = {Logical forms of chronicles},
@@ -498,12 +502,12 @@ For situation recognitinon, there are strong connection between chronicles and m
498
502
  }
499
503
  ~~~
500
504
 
501
- To illustrate that the principle of semantic chronicles can be broader, we extended it to the case of MTL formulae. This means that our framework enables to express a MTL formulae using query as events.
505
+ To illustrate that the principle of semantic chronicles can be broader, we extended it to the case of MTL formulas. This means that our framework makes it possible to express MTL formulas using queries as events.
502
506
 
503
507
 
504
- The `tpattern` accessor provides a function `match_mtl` that is dedicated to the recognition of a MTL formulae in the timed sequence. This function returns a boolean value. There is not equivalent to the enumeration of occurrences of a chronicle.
508
+ The `tpattern` accessor provides a function `match_mtl` that is dedicated to the recognition of an MTL formula in the timed sequence (only for dataframes indexed by floats or integers). This function returns a boolean value. There is no equivalent to the enumeration of the occurrences of a chronicle.
505
509
 
506
- The syntax of an MTL formula is based on the two operators `F` (eventually) and `G` (globally). These operators can be specified with temporal constraints (in brackets). They combines events defined in the same way as for chronicle events.
510
+ The syntax of an MTL formula is based on the two operators `F` (eventually) and `G` (globally). These operators can be specified with temporal constraints (in brackets). They combine events defined in the same way as chronicle events.
507
511
 
508
512
  ```python
509
513
  query = ' F(label=="a" & F[2.9,5]( label=="b" & num_val>5 ))'
@@ -514,13 +518,13 @@ This feature is based on the [Python implementation of MTL](https://github.com/m
514
518
 
515
519
  ## Abstraction of a sequence
516
520
 
517
- Finally, we also provide a function that enables to abstract a collection of sequences into a chronicle.
521
+ Finally, we also provide a function that abstracts a collection of sequences into a chronicle.
518
522
 
519
- Contrary to the recognition functions that can handle several columns, the abstraction requires to define a column that correspond to the event name. In addition, it requires to define the attribute name that correspond to the identifier of the sequences.
520
- Then, the function, named `abstract` takes two arguments and outputs a single chronicle that occurs in all the sequences.
523
+ Contrary to the recognition functions that can handle several columns, the abstraction requires a column that corresponds to the event names. In addition, it requires the name of the attribute that corresponds to the identifier of the sequences.
524
+ Then, the function, named `abstract`, takes these two arguments and outputs a single chronicle that occurs in all the sequences.
521
525
 
522
526
 
523
- The following example extracts a chronicle from the dataframe introduced above. It focuses event on the label attribute.
527
+ The following example extracts a chronicle from the dataframe introduced above. Its events are based on the `label` attribute.
524
528
  ```python
525
529
  chro = df.tpattern.abstract('label', 'id')
526
530
  ```
@@ -529,7 +533,7 @@ chro = df.tpattern.abstract('label', 'id')
529
533
 
530
534
  ## Export / import of chronicles
531
535
 
532
- It is possible to specify chronicles using the CRS format. The following code illustrate the syntax for specifying a chronicle in this format.
536
+ It is possible to specify chronicles using the CRS format (see the functions `load` and `to_crs` of the `pychronicles.utils` module). The following code illustrates the syntax for specifying a chronicle in this format.
533
537
 
534
538
  ```
535
539
  chronicle C27_sub_0[]()
@@ -550,16 +554,16 @@ chronicle C27_sub_0[]()
550
554
 
551
555
  * implementation of chronicle mining algorithms
552
556
  * graphical chronicle editor
553
- * better cythonize the recognition
557
+ * compile the recognition (e.g. with Cython)
554
558
  * optimized matching of several chronicles at the same time
555
559
 
556
560
 
557
- If you think that this package can be improved ... do not hesitate to contact the author to request additional features. He will do his best to maintain the code and improve it continuously.
561
+ If you think that this package can be improved, do not hesitate to contact the author to request additional features. He will do his best to maintain the code and improve it continuously.
558
562
 
559
563
 
560
564
  # Authorship
561
565
 
562
566
  * **Author:** Thomas Guyet
563
567
  * **Institution:** Inria/AIstroSight
564
- * **date:** 08/2024
568
+ * **date:** 10/2026
565
569