14.5.24. crate_anon.nlp_manager.parse_cognitive

crate_anon/nlp_manager/parse_cognitive.py


Copyright (C) 2015, University of Cambridge, Department of Psychiatry. Created by Rudolf Cardinal (rnc1001@cam.ac.uk).

This file is part of CRATE.

CRATE is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

CRATE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with CRATE. If not, see <https://www.gnu.org/licenses/>.


Python regex-based NLP processors for cognitive tests.

All inherit from crate_anon.nlp_manager.regex_parser.NumeratorOutOfDenominatorParser and are constructed with these arguments:

nlpdef:

a crate_anon.nlp_manager.nlp_definition.NlpDefinition

cfgsection:

the name of a CRATE NLP config file section (from which we may choose to get extra config information)

commit:

force a COMMIT whenever we insert data? You should specify this in multiprocess mode, or you may get database deadlocks.

class crate_anon.nlp_manager.parse_cognitive.Ace(nlpdef: Optional[crate_anon.nlp_manager.nlp_definition.NlpDefinition], cfg_processor_name: Optional[str], commit: bool = False)[source]

COGNITIVE.

Addenbrooke’s Cognitive Examination (ACE, ACE-R, ACE-III) total score.

The default denominator is 100 but it supports other values if given explicitly.

__init__(nlpdef: Optional[crate_anon.nlp_manager.nlp_definition.NlpDefinition], cfg_processor_name: Optional[str], commit: bool = False) None[source]
This class operates with compiled regexes having this group format:
  • quantity_regex_str: e.g. to find “MMSE”

Parameters
  • nlpdef – a crate_anon.nlp_manager.nlp_definition.NlpDefinition

  • cfg_processor_name – the suffix (name) of a CRATE NLP config file processor section (from which we may choose to get extra config information)

  • variable_name – becomes the content of the variable_name output column

  • variable_regex_str – regex for the text that states the variable

  • expected_denominator – the integer value that’s expected as the “out of Y” part. For example, an MMSE is out of 30; an ACE-III total is out of 100. If the text just says “MMSE 17”, we will infer “17 out of 30”; so, for the MMSE, expected_denominator should be 30.

  • numerator_text_fieldname – field (column) name in which to store the text retrieved as the numerator

  • numerator_fieldname – field (column) name in which to store the numerical value retrieved as the numerator

  • denominator_text_fieldname – field (column) name in which to store the text retrieved as the denominator

  • denominator_fieldname – field (column) name in which to store the numerical value retrieved as the denominator

  • correct_numerator_fieldname – field (column) name in which we store the principal validated numerator. For example, if an MMSE processor sees “17” or “17/30”, this field will end up containing 17; but if it sees “17/100”, it will remain NULL.

  • take_absolute – Convert negative values to positive ones? As for SimpleNumericalResultParser.

  • commit – force a COMMIT whenever we insert data? You should specify this in multiprocess mode, or you may get database deadlocks.

  • debug – print the regex?

test(verbose: bool = False) None[source]

Performs a self-test on the NLP processor.

Parameters

verbose – Be verbose?

This is an abstract method that is subclassed.

class crate_anon.nlp_manager.parse_cognitive.AceValidator(nlpdef: Optional[crate_anon.nlp_manager.nlp_definition.NlpDefinition], cfg_processor_name: Optional[str], commit: bool = False)[source]

Validator for Ace (see help for explanation).

test(verbose: bool = False) None[source]

Performs a self-test on the NLP processor.

Parameters

verbose – Be verbose?

This is an abstract method that is subclassed.

class crate_anon.nlp_manager.parse_cognitive.MiniAce(nlpdef: Optional[crate_anon.nlp_manager.nlp_definition.NlpDefinition], cfg_processor_name: Optional[str], commit: bool = False)[source]

COGNITIVE.

Mini-Addenbrooke’s Cognitive Examination (M-ACE).

The default denominator is 30, but it supports other values if given explicitly.

__init__(nlpdef: Optional[crate_anon.nlp_manager.nlp_definition.NlpDefinition], cfg_processor_name: Optional[str], commit: bool = False) None[source]
This class operates with compiled regexes having this group format:
  • quantity_regex_str: e.g. to find “MMSE”

Parameters
  • nlpdef – a crate_anon.nlp_manager.nlp_definition.NlpDefinition

  • cfg_processor_name – the suffix (name) of a CRATE NLP config file processor section (from which we may choose to get extra config information)

  • variable_name – becomes the content of the variable_name output column

  • variable_regex_str – regex for the text that states the variable

  • expected_denominator – the integer value that’s expected as the “out of Y” part. For example, an MMSE is out of 30; an ACE-III total is out of 100. If the text just says “MMSE 17”, we will infer “17 out of 30”; so, for the MMSE, expected_denominator should be 30.

  • numerator_text_fieldname – field (column) name in which to store the text retrieved as the numerator

  • numerator_fieldname – field (column) name in which to store the numerical value retrieved as the numerator

  • denominator_text_fieldname – field (column) name in which to store the text retrieved as the denominator

  • denominator_fieldname – field (column) name in which to store the numerical value retrieved as the denominator

  • correct_numerator_fieldname – field (column) name in which we store the principal validated numerator. For example, if an MMSE processor sees “17” or “17/30”, this field will end up containing 17; but if it sees “17/100”, it will remain NULL.

  • take_absolute – Convert negative values to positive ones? As for SimpleNumericalResultParser.

  • commit – force a COMMIT whenever we insert data? You should specify this in multiprocess mode, or you may get database deadlocks.

  • debug – print the regex?

test(verbose: bool = False) None[source]

Performs a self-test on the NLP processor.

Parameters

verbose – Be verbose?

This is an abstract method that is subclassed.

class crate_anon.nlp_manager.parse_cognitive.MiniAceValidator(nlpdef: Optional[crate_anon.nlp_manager.nlp_definition.NlpDefinition], cfg_processor_name: Optional[str], commit: bool = False)[source]

Validator for MiniAce (see help for explanation).

class crate_anon.nlp_manager.parse_cognitive.Mmse(nlpdef: Optional[crate_anon.nlp_manager.nlp_definition.NlpDefinition], cfg_processor_name: Optional[str], commit: bool = False)[source]

COGNITIVE.

Mini-mental state examination (MMSE).

The default denominator is 30, but it supports other values if given explicitly.

__init__(nlpdef: Optional[crate_anon.nlp_manager.nlp_definition.NlpDefinition], cfg_processor_name: Optional[str], commit: bool = False) None[source]
This class operates with compiled regexes having this group format:
  • quantity_regex_str: e.g. to find “MMSE”

Parameters
  • nlpdef – a crate_anon.nlp_manager.nlp_definition.NlpDefinition

  • cfg_processor_name – the suffix (name) of a CRATE NLP config file processor section (from which we may choose to get extra config information)

  • variable_name – becomes the content of the variable_name output column

  • variable_regex_str – regex for the text that states the variable

  • expected_denominator – the integer value that’s expected as the “out of Y” part. For example, an MMSE is out of 30; an ACE-III total is out of 100. If the text just says “MMSE 17”, we will infer “17 out of 30”; so, for the MMSE, expected_denominator should be 30.

  • numerator_text_fieldname – field (column) name in which to store the text retrieved as the numerator

  • numerator_fieldname – field (column) name in which to store the numerical value retrieved as the numerator

  • denominator_text_fieldname – field (column) name in which to store the text retrieved as the denominator

  • denominator_fieldname – field (column) name in which to store the numerical value retrieved as the denominator

  • correct_numerator_fieldname – field (column) name in which we store the principal validated numerator. For example, if an MMSE processor sees “17” or “17/30”, this field will end up containing 17; but if it sees “17/100”, it will remain NULL.

  • take_absolute – Convert negative values to positive ones? As for SimpleNumericalResultParser.

  • commit – force a COMMIT whenever we insert data? You should specify this in multiprocess mode, or you may get database deadlocks.

  • debug – print the regex?

test(verbose: bool = False) None[source]

Performs a self-test on the NLP processor.

Parameters

verbose – Be verbose?

This is an abstract method that is subclassed.

class crate_anon.nlp_manager.parse_cognitive.MmseValidator(nlpdef: Optional[crate_anon.nlp_manager.nlp_definition.NlpDefinition], cfg_processor_name: Optional[str], commit: bool = False)[source]

Validator for Mmse (see help for explanation).

class crate_anon.nlp_manager.parse_cognitive.Moca(nlpdef: Optional[crate_anon.nlp_manager.nlp_definition.NlpDefinition], cfg_processor_name: Optional[str], commit: bool = False)[source]

COGNITIVE.

Montreal Cognitive Assessment (MOCA).

The default denominator is 30, but it supports other values if given explicitly.

__init__(nlpdef: Optional[crate_anon.nlp_manager.nlp_definition.NlpDefinition], cfg_processor_name: Optional[str], commit: bool = False) None[source]
This class operates with compiled regexes having this group format:
  • quantity_regex_str: e.g. to find “MMSE”

Parameters
  • nlpdef – a crate_anon.nlp_manager.nlp_definition.NlpDefinition

  • cfg_processor_name – the suffix (name) of a CRATE NLP config file processor section (from which we may choose to get extra config information)

  • variable_name – becomes the content of the variable_name output column

  • variable_regex_str – regex for the text that states the variable

  • expected_denominator – the integer value that’s expected as the “out of Y” part. For example, an MMSE is out of 30; an ACE-III total is out of 100. If the text just says “MMSE 17”, we will infer “17 out of 30”; so, for the MMSE, expected_denominator should be 30.

  • numerator_text_fieldname – field (column) name in which to store the text retrieved as the numerator

  • numerator_fieldname – field (column) name in which to store the numerical value retrieved as the numerator

  • denominator_text_fieldname – field (column) name in which to store the text retrieved as the denominator

  • denominator_fieldname – field (column) name in which to store the numerical value retrieved as the denominator

  • correct_numerator_fieldname – field (column) name in which we store the principal validated numerator. For example, if an MMSE processor sees “17” or “17/30”, this field will end up containing 17; but if it sees “17/100”, it will remain NULL.

  • take_absolute – Convert negative values to positive ones? As for SimpleNumericalResultParser.

  • commit – force a COMMIT whenever we insert data? You should specify this in multiprocess mode, or you may get database deadlocks.

  • debug – print the regex?

test(verbose: bool = False) None[source]

Performs a self-test on the NLP processor.

Parameters

verbose – Be verbose?

This is an abstract method that is subclassed.

class crate_anon.nlp_manager.parse_cognitive.MocaValidator(nlpdef: Optional[crate_anon.nlp_manager.nlp_definition.NlpDefinition], cfg_processor_name: Optional[str], commit: bool = False)[source]

Validator for Moca (see help for explanation).