Skip to content

Commit 6005296

Browse files
committed
Allowing having textcat data in a non-standard location #23
1 parent e6770e7 commit 6005296

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

frog_wrapper.pyx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -255,11 +255,17 @@ def installdata(targetdir=None, frogdataversion=FROGDATAVERSION, uctodataversion
255255
raise Exception("Installation of frogdata failed")
256256
print(f"Installation of frogdata {frogdataversion} complete", file=sys.stderr)
257257

258-
if os.path.isdir("/usr/share/libexttextcat"):
258+
textcatpath = os.environ.get("TEXTCATPATH","/usr/share/libexttextcat")
259+
if os.path.isdir(textcatpath):
259260
if os.system(f"cd {uctodir} && wget -O textcat.cfg https://raw.githubusercontent.com/LanguageMachines/ucto/master/config/textcat.cfg") != 0:
260261
raise Exception("Installation of textcat.cfg failed.")
262+
if textcatpath[-1] = '/': textcatpath = textcatpath[:-1]
263+
if textcatpath != "/usr/share/libexttextcat":
264+
data = open(f"{uctodir}/textcat.cfg",'r',encoding='utf-8').read()
265+
with open(f"{uctodir}/textcat.cfg",'w',encoding='utf-8').read()
266+
f.write(data.replace("/usr/share/libexttextcat", textcatpath))
261267
else:
262-
print("Language detection will not be available unless you install libexttextcat and rerun installdata()", file=sys.stderr)
268+
print("Language detection will not be available unless you install libexttextcat and rerun installdata(). Libexttextcat was not found. If it is in a non-standard location, set environment variable TEXTCATPATH (defaults to /usr/share/libexttextcat) prior to calling installdata()", file=sys.stderr)
263269

264270

265271

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757

5858
setup(
5959
name = 'python-frog',
60-
version = '0.6.5', #also ensure UCTODATAVERSION and FROGDATAVERSION are good in frog_wrapper.pyx
60+
version = '0.6.6', #also ensure UCTODATAVERSION and FROGDATAVERSION are good in frog_wrapper.pyx
6161
author = "Maarten van Gompel",
6262
author_email = "[email protected]",
6363
description = ("Python binding to Frog, an NLP suite for Dutch doing part-of-speech tagging, lemmatisation, morphological analysis, named-entity recognition, shallow parsing, and dependency parsing."),

0 commit comments

Comments
 (0)