question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Analyzing with TreeBuilderProcess: Can't instantiate abstract class TreeBuilderProcess with abstract method run

See original GitHub issue

Description Attempting to analyze a CLTK sentence using cltk.dependency.processes.TreeBuilderProcess added to variable pipeline of class NLP, in order produce a dependency graph, produces an error output that states that the abstract class TreeBuilderProcess cannot be instantiated with the abstract method “run”.

To Reproduce

  1. Install Python version 3.10.4
  2. Install CLTK version 1.1.5 with dependencies using pip in virtualenv
  3. In a REPL, run the following code:
from cltk import NLP
from cltk.dependency.processes import TreeBuilderProcess
nlp = NLP(language="lat", suppress_banner=True)
nlp.pipeline.add_process(TreeBuilderProcess)
from cltk.languages.example_texts import get_example_text
doc = nlp.analyze(text=get_example_text("lat"))

  1. See error
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/user/.virtualenvs/textproc/lib/python3.10/site-packages/cltk/nlp.py", line 140, in analyze
    a_process = self._get_process_object(process)
  File "/home/user/.virtualenvs/textproc/lib/python3.10/site-packages/cltk/nlp.py", line 116, in _get_process_object
    a_process = process_object(self.language.iso_639_3_code)
TypeError: Can't instantiate abstract class TreeBuilderProcess with abstract method run

Expected behavior This follows the example commands as listed on the following URL: https://docs.cltk.org/en/latest/cltk.dependency.html

According to the documentation, cltk.dependency.processes.TreeBuilderProcess is a “Process that takes a doc containing sentences of CLTK words and returns a dependency tree for each sentence.”

Expected behavior is no error output, with the ability to use the “doc” object as a reference for dependency graphs (trees) of the example text in question.

Example language “got” leads to the same output.

Desktop (please complete the following information):

Pop!_OS 22.04 LTS jammy (ID_LIKE ubuntu debian)

Issue Analytics

  • State:open
  • Created a year ago
  • Reactions:2
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
clemsciencescommented, Aug 9, 2022

Hello Gideon,

I think it would be easier to discuss about it on or Discord server: https://discord.gg/ATUDJQX7cg and I’ll see how to help you more precisely and see how to implement the TreeBuilderProcess class.

1reaction
kylepjohnsoncommented, Aug 1, 2022

Thanks, Clément.

I wrote this a few years ago, but it looks like I never finished it. TreeBuilderProcess is not referenced anywhere else in the docs. If I recall correctly, my intention was that this would be a generic form of what we do with (StanzaProcess), but only for dependency information. For the run() method that @clemsciences references, you can see one here: https://github.com/cltk/cltk/blob/cd25f24d5795ae8d169f2dce778d6b1175d97633/src/cltk/dependency/processes.py#L45

@GideonK if you would explain what your goal is, we will help you as best we can.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Can't instantiate abstract class with abstract methods
The error message indicates that the SubClass class has an 'abstract method' <some method> , and its not a concrete method, hence we...
Read more >
How to Fix Python Error 'Can't Instantiate Abstract Class'
Here's the fix for can't instantiate abstract class error. ... The class must be abstract if there is any abstract method in a...
Read more >
Can We Instantiate an Abstract Class in Java? - GeeksforGeeks
Abstract class, we have heard that abstract class are classes which can have abstract methods and it can't be instantiated.
Read more >
Abstract Base Classes in Python: Fundamentals for Data ...
Abstract base classes cannot be instantiated. Instead, they are inherited and extended by the concrete subclasses.
Read more >
Abstract class instantiated PYL-E0110 - Python - DeepSource
An abstract class with abc.ABCMeta as metaclass has abstract methods and is instantiated. This will result in a TypeError as Python can't instantiate ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found