15.4.17. crate_anon.nlp_manager.parse_gate


Copyright (C) 2015-2018 Rudolf Cardinal (rudolf@pobox.com).

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 <http://www.gnu.org/licenses/>.


The pipe encoding (Python -> Java stdin, Java stdout -> Python) is fixed at UTF-8 here and in the Java code.

class crate_anon.nlp_manager.parse_gate.Gate(nlpdef: crate_anon.nlp_manager.nlp_definition.NlpDefinition, cfgsection: str, commit: bool = False)[source]

Class controlling an external process, typically our Java interface to GATE programs, CrateGatePipeline.java (but it could be any external program).

We send text to it, it parses the text, and it sends us back results, which we return as dictionaries. The specific text sought depends on the configuration file and the specific GATE program used.

dest_tables_columns() → Dict[str, List[sqlalchemy.sql.schema.Column]][source]

Returns a dictionary of {tablename: destination_columns}.

parse(text: str) → Generator[[Tuple[str, Dict[str, Any]], NoneType], NoneType][source]
  • Send text to the external process, and receive the result.
  • Note that associated data is not passed into this function, and is kept in the Python environment, so we can’t run into any problems with the transfer to/from the Java program garbling important data. All we send to the subprocess is the text (and an input_terminator). Then, we may receive MULTIPLE sets of data back (“your text contains the following 7 people/drug references/whatever”), followed eventually by the output_terminator, at which point this set is complete.
test(verbose: bool = False) → None[source]

Test the send function.