Skip to content

Commit e33afd2

Browse files
committed
UDPipe (and thus ufal.udpipe) doesn't need to be imported if online=1
1 parent bd89be0 commit e33afd2

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

udapi/block/udpipe/base.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
11
"""Block udpipe.Base for tagging and parsing using UDPipe."""
22
from udapi.core.block import Block
3-
from udapi.tool.udpipe import UDPipe
43
from udapi.tool.udpipeonline import UDPipeOnline
54
from udapi.core.bundle import Bundle
65

6+
# Import UDPipe only if available (requires ufal.udpipe)
7+
try:
8+
from udapi.tool.udpipe import UDPipe
9+
UDPIPE_AVAILABLE = True
10+
except ImportError:
11+
UDPIPE_AVAILABLE = False
12+
713
KNOWN_MODELS = {
814
'af': 'models/udpipe/2.4/afrikaans-afribooms-ud-2.4-190531.udpipe',
915
'af_afribooms': 'models/udpipe/2.4/afrikaans-afribooms-ud-2.4-190531.udpipe',
@@ -143,6 +149,8 @@ def tool(self):
143149
if self.online:
144150
self._tool = UDPipeOnline(model=self.model)
145151
else:
152+
if not UDPIPE_AVAILABLE:
153+
raise ImportError("UDPipe is not available. Install ufal.udpipe or use online=1")
146154
self._tool = UDPipe(model=self.model)
147155
return self._tool
148156

0 commit comments

Comments
 (0)