本文整理汇总了Python中nltk.internals.find_binary函数的典型用法代码示例。如果您正苦于以下问题:Python find_binary函数的具体用法?Python find_binary怎么用?Python find_binary使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了find_binary函数的19个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: config_tadm
def config_tadm(bin=None):
global _tadm_bin
_tadm_bin = find_binary(
'tadm', bin,
env_vars=['TADM'],
binary_names=['tadm'],
url='http://tadm.sf.net')
开发者ID:Weiming-Hu,项目名称:text-based-six-degree,代码行数:7,代码来源:tadm.py
示例2: _repr_png_
def _repr_png_(self):
"""Draws and outputs in PNG for ipython.
PNG is used instead of PDF, since it can be displayed in the qt
console and has wider browser support.
"""
with tempfile.NamedTemporaryFile() as f_tmp:
in_path = '{0:}.ps'.format(f_tmp.name)
out_path = '{0:}.png'.format(f_tmp.name)
# generate PostScript using the drawing utils of NLTK
self.to_ps(in_path)
# convert to PNG with ghostscript
subprocess.call(
[find_binary('gs',
binary_names=['gswin32c.exe', 'gswin64c.exe'],
env_vars=['PATH'], verbose=False)] +
'-q -dEPSCrop {2:} -dSAFER -dBATCH -dNOPAUSE -sOutputFile={0:} {1:}'
.format(out_path, in_path, _GS_PARAMS['png']).split())
# this function will return the encoded+decoded bytes of the PNG
# file
with open(out_path, 'rb') as sr:
res = sr.read()
os.remove(in_path)
os.remove(out_path)
return base64.b64encode(res).decode()
开发者ID:irit-melodi,项目名称:educe,代码行数:25,代码来源:annotation.py
示例3: config_mallet
def config_mallet(mallet_home=None):
"""
Configure NLTK's interface to the Mallet machine learning package.
:type mallet_home: str
:param mallet_home: The full path to the mallet directory. If not
specified, then NLTK will search the system for a mallet directory;
and if one is not found, it will raise a ``LookupError`` exception.
"""
global _mallet_home, _mallet_classpath
# We don't actually care about this binary -- we just use it to
# make sure we've found the right directory.
mallethon_bin = find_binary(
"mallet",
mallet_home,
env_vars=["MALLET", "MALLET_HOME"],
binary_names=["mallethon"],
url="http://mallet.cs.umass.edu",
)
# Record the location where mallet lives.
bin_dir = os.path.split(mallethon_bin)[0]
_mallet_home = os.path.split(bin_dir)[0]
# Construct a classpath for using mallet.
lib_dir = os.path.join(_mallet_home, "lib")
if not os.path.isdir(lib_dir):
raise ValueError("While configuring mallet: directory %r " "not found." % lib_dir)
_mallet_classpath = os.path.pathsep.join(
os.path.join(lib_dir, filename) for filename in sorted(os.listdir(lib_dir)) if filename.endswith(".jar")
)
开发者ID:carriercomm,项目名称:PrologMUD,代码行数:30,代码来源:mallet.py
示例4: _find_binary
def _find_binary(self, name, bin_dir, verbose=False):
return find_binary(name,
path_to_bin=bin_dir,
env_vars=['CANDC'],
url='http://svn.ask.it.usyd.edu.au/trac/candc/',
binary_names=[name, name + '.exe'],
verbose=verbose)
开发者ID:GINK03,项目名称:KindleReferencedIndexScore,代码行数:7,代码来源:boxer.py
示例5: _find_binary
def _find_binary(self, name, verbose=False):
return find_binary(name,
searchpath=Theorem.BINARY_LOCATIONS,
env_vars=['PROVER9HOME'],
url='http://www.cs.unm.edu/~mccune/prover9/',
binary_names=[name],
verbose=verbose)
开发者ID:Garnovski,项目名称:nltk-drt,代码行数:7,代码来源:inference.py
示例6: config_mallet
def config_mallet(mallet_home=None):
"""
Configure NLTK's interface to the C{mallet} machine learning
package.
:param mallet_home: The full path to the C{mallet} directory. If
not specified, then nltk will search the system for a
C{mallet} directory; and if one is not found, it will raise a
C{LookupError} exception.
:type mallet_home: str
"""
global _mallet_home, _mallet_classpath
# We don't actually care about this binary -- we just use it to
# make sure we've found the right directory.
mallethon_bin = find_binary(
'mallet', mallet_home,
env_vars=['MALLET', 'MALLET_HOME'],
binary_names=['mallethon'],
url='http://mallet.cs.umass.edu>')
# Record the location where mallet lives.
bin_dir = os.path.split(mallethon_bin)[0]
_mallet_home = os.path.split(bin_dir)[0]
# Construct a classpath for using mallet.
lib_dir = os.path.join(_mallet_home, 'lib')
if not os.path.isdir(lib_dir):
raise ValueError('While configuring mallet: directory %r '
'not found.' % lib_dir)
_mallet_classpath = ':'.join([os.path.join(lib_dir, filename)
for filename in sorted(os.listdir(lib_dir))
if filename.endswith('.jar')])
开发者ID:approximatelylinear,项目名称:nltk,代码行数:31,代码来源:mallet.py
示例7: __init__
def __init__(self, path_to_model, path_to_bin=None,
encoding=_hunpos_charset, verbose=False):
"""
Starts the hunpos-tag executable and establishes a connection with it.
:param path_to_model: The model file.
:param path_to_bin: The hunpos-tag binary.
:param encoding: The encoding used by the model. Unicode tokens
passed to the tag() and tag_sents() methods are converted to
this charset when they are sent to hunpos-tag.
The default is ISO-8859-1 (Latin-1).
This parameter is ignored for str tokens, which are sent as-is.
The caller must ensure that tokens are encoded in the right charset.
"""
self._closed = True
hunpos_paths = ['.', '/usr/bin', '/usr/local/bin', '/opt/local/bin',
'/Applications/bin', '~/bin', '~/Applications/bin']
hunpos_paths = list(map(os.path.expanduser, hunpos_paths))
self._hunpos_bin = find_binary(
'hunpos-tag', path_to_bin,
env_vars=('HUNPOS_TAGGER',),
searchpath=hunpos_paths,
url=_hunpos_url,
verbose=verbose
)
self._hunpos_model = find_file(
path_to_model, env_vars=('HUNPOS_TAGGER',), verbose=verbose)
self._encoding = encoding
self._hunpos = Popen([self._hunpos_bin, self._hunpos_model],
shell=False, stdin=PIPE, stdout=PIPE, stderr=PIPE)
self._closed = False
开发者ID:Kappie,项目名称:support_vector_machine,代码行数:34,代码来源:hunpos.py
示例8: config_malt
def config_malt(self, bin=None, verbose=False):
"""
Configure NLTK's interface to the C{malt} package. This
searches for a directory containing the malt jar
:param bin: The full path to the C{malt} binary. If not
specified, then nltk will search the system for a C{malt}
binary; and if one is not found, it will raise a
C{LookupError} exception.
:type bin: str
"""
#: A list of directories that should be searched for the malt
#: executables. This list is used by L{config_malt} when searching
#: for the malt executables.
_malt_path = ['.',
'/usr/lib/malt-1*',
'/usr/share/malt-1*',
'/usr/local/bin',
'/usr/local/malt-1*',
'/usr/local/bin/malt-1*',
'/usr/local/malt-1*',
'/usr/local/share/malt-1*']
# Expand wildcards in _malt_path:
malt_path = reduce(add, map(glob.glob, _malt_path))
# Find the malt binary.
self._malt_bin = find_binary('malt.jar', bin,
searchpath=malt_path, env_vars=['MALTPARSERHOME'],
url='http://w3.msi.vxu.se/~jha/maltparser/index.html',
verbose=verbose)
开发者ID:approximatelylinear,项目名称:nltk,代码行数:31,代码来源:malt.py
示例9: _find_binary
def _find_binary(self, name, bin_dir, verbose=False):
return find_binary(
name,
path_to_bin=bin_dir,
env_vars=["CANDCHOME"],
url="http://svn.ask.it.usyd.edu.au/trac/candc/",
binary_names=[name, name + ".exe"],
verbose=verbose,
)
开发者ID:navikohli,项目名称:nltk,代码行数:9,代码来源:boxer.py
示例10: __init__
def __init__(self, path_to_treetagger=None, language='english',
verbose=False, abbreviation_list=None):
"""
Initialize the TreeTagger.
:param language: Default language is english.
The encoding used by the model. Unicode tokens
passed to the tag() method are converted to
this charset when they are sent to TreeTagger.
The default is utf-8.
This parameter is ignored for str tokens, which are sent as-is.
The caller must ensure that tokens are encoded in the right charset.
"""
if path_to_treetagger:
self._path_to_treetagger = path_to_treetagger
else:
self._path_to_treetagger = None
treetagger_paths = ['.']
if 'TREETAGGER_HOME' in os.environ:
if _platform == "win32":
tt_path = os.path.normpath(os.path.join(os.environ['TREETAGGER_HOME'], 'bin'))
else:
tt_path = os.path.normpath(os.path.join(os.environ['TREETAGGER_HOME'], 'cmd'))
treetagger_paths.append(tt_path)
elif self._path_to_treetagger:
if _platform == "win32":
tt_path = os.path.normpath(os.path.join(self._path_to_treetagger, 'bin'))
else:
tt_path = os.path.normpath(os.path.join(self._path_to_treetagger, 'cmd'))
treetagger_paths.append(tt_path)
else:
raise LookupError('Set \'TREETAGGER_HOME\' or use path_to_treetagger!')
treetagger_paths = list(map(os.path.expanduser, treetagger_paths))
self._abbr_list = abbreviation_list
if language in self.get_installed_lang():
if _platform == "win32":
treetagger_bin_name = 'tag-' + language + '.bat'
else:
treetagger_bin_name = 'tree-tagger-' + language
else:
raise LookupError('Language not installed!')
try:
self._treetagger_bin = find_binary(
treetagger_bin_name,
searchpath=treetagger_paths,
url=_treetagger_url,
verbose=verbose)
except LookupError:
print('NLTK was unable to find the TreeTagger bin!')
开发者ID:miotto,项目名称:treetagger-python,代码行数:55,代码来源:treetagger.py
示例11: __init__
def __init__(self, path_to_home=None, language="english", encoding="latin-1", verbose=False):
"""
Initialize the TreeTagger.
:param path_to_home: The TreeTagger binary.
:param language: Default language is german.
:param encoding: The encoding used by the model. Unicode tokens
passed to the tag() and batch_tag() methods are converted to
this charset when they are sent to TreeTagger.
The default is utf8.
This parameter is ignored for str tokens, which are sent as-is.
The caller must ensure that tokens are encoded in the right charset.
"""
treetagger_paths = [
".",
"/usr/bin",
"/usr/local/bin",
"/opt/local/bin",
"/Applications/bin",
"~/bin",
"~/Applications/bin",
"~/work/TreeTagger/cmd",
]
treetagger_paths = map(os.path.expanduser, treetagger_paths)
try:
if language in _treetagger_languages[encoding]:
if encoding == u"latin-1":
"""the executable has no encoding information for latin-1"""
treetagger_bin_name = "tree-tagger-" + language
self._encoding = u"latin-1"
else:
treetagger_bin_name = "tree-tagger-" + language + u"-" + encoding
self._encoding = encoding
else:
raise LookupError("NLTK was unable to find the TreeTagger bin!")
except KeyError as e:
raise LookupError("NLTK was unable to find the TreeTagger bin!")
self._treetagger_bin = find_binary(
treetagger_bin_name,
path_to_home,
env_vars=("TREETAGGER", "TREETAGGER_HOME"),
searchpath=treetagger_paths,
url=_treetagger_url,
verbose=verbose,
)
if encoding in _treetagger_charset:
self._encoding = encoding
开发者ID:estnltk,项目名称:pfe,代码行数:52,代码来源:treetagger.py
示例12: to_pdf
def to_pdf(self, filename):
"""Image representation in PDF.
"""
# generate PostScript using the drawing utils of NLTK
root, ext = os.path.splitext(filename)
in_path = '{0:}.ps'.format(root)
self.to_ps(in_path)
# convert to PDF with ghostscript
subprocess.call(
[find_binary('gs',
binary_names=['gswin32c.exe', 'gswin64c.exe'],
env_vars=['PATH'], verbose=False)] +
'-q -dEPSCrop {2:} -dSAFER -dBATCH -dNOPAUSE -sOutputFile={0:} {1:}'
.format(filename, in_path, _GS_PARAMS['pdf']).split())
os.remove(in_path)
开发者ID:irit-melodi,项目名称:educe,代码行数:15,代码来源:annotation.py
示例13: __init__
def __init__(self, path_to_home=None, language='german',
encoding='utf8', verbose=False, abbreviation_list=None):
"""
Initialize the TreeTagger.
:param path_to_home: The TreeTagger binary.
:param language: Default language is german.
:param encoding: The encoding used by the model. Unicode tokens
passed to the tag() and batch_tag() methods are converted to
this charset when they are sent to TreeTagger.
The default is utf8.
This parameter is ignored for str tokens, which are sent as-is.
The caller must ensure that tokens are encoded in the right charset.
"""
treetagger_paths = ['.', '/usr/bin', '/usr/local/bin', '/opt/local/bin',
'/Applications/bin', '~/bin', '~/Applications/bin',
'~/work/TreeTagger/cmd', '~/tree-tagger/cmd', '/tree-tagger/bin', '/tree-tagger/cmd', '/var/opt/treetagger/bin', '/var/opt/treetagger/cmd']
treetagger_paths = map(os.path.expanduser, treetagger_paths)
self._abbr_list = abbreviation_list
try:
if language in _treetagger_languages[encoding]:
if encoding == u'latin-1':
"""the executable has no encoding information for latin-1"""
treetagger_bin_name = 'tree-tagger-' + language
self._encoding = u'latin-1'
else:
#treetagger_bin_name = 'tree-tagger-' + language + u'-' + encoding
treetagger_bin_name = 'tree-tagger-' + language
self._encoding = encoding
else:
raise LookupError('NLTK was unable to find the TreeTagger bin!')
except KeyError as e:
raise LookupError('NLTK was unable to find the TreeTagger bin!')
self._treetagger_bin = find_binary(
treetagger_bin_name, path_to_home,
env_vars=('TREETAGGER', 'TREETAGGER_HOME'),
searchpath=treetagger_paths,
url=_treetagger_url,
verbose=verbose)
print(u'### {}'.format(self._treetagger_bin))
if encoding in _treetagger_charset:
self._encoding = encoding
print(u'#### {}'.format(self._encoding))
开发者ID:rrafaelpinto,项目名称:treetagger-python,代码行数:48,代码来源:treetagger.py
示例14: config_megam
def config_megam(bin=None):
"""
Configure NLTK's interface to the ``megam`` maxent optimization
package.
:param bin: The full path to the ``megam`` binary. If not specified,
then nltk will search the system for a ``megam`` binary; and if
one is not found, it will raise a ``LookupError`` exception.
:type bin: str
"""
global _megam_bin
_megam_bin = find_binary(
'megam', bin,
env_vars=['MEGAM'],
binary_names=['megam.opt', 'megam', 'megam_686', 'megam_i686.opt'],
url='http://www.umiacs.umd.edu/~hal/megam/index.html')
开发者ID:esabelhaus,项目名称:secret-octo-dubstep,代码行数:16,代码来源:megam.py
示例15: config_megam
def config_megam(bin=None):
"""
Configure NLTK's interface to the C{megam} maxent optimization
package.
@param bin: The full path to the C{megam} binary. If not specified,
then nltk will search the system for a C{megam} binary; and if
one is not found, it will raise a C{LookupError} exception.
@type bin: C{string}
"""
global _megam_bin
_megam_bin = find_binary(
'megam', bin,
env_vars=['MEGAM', 'MEGAMHOME'],
binary_names=['megam.opt', 'megam', 'megam_686', 'megam_i686.opt'],
url='http://www.cs.utah.edu/~hal/megam/')
开发者ID:johndpope,项目名称:jazzparser,代码行数:16,代码来源:megam.py
示例16: config_megam
def config_megam(bin=None):
"""
Configure NLTK's interface to the ``megam`` maxent optimization
package.
:param bin: The full path to the ``megam`` binary. If not specified,
then nltk will search the system for a ``megam`` binary; and if
one is not found, it will raise a ``LookupError`` exception.
:type bin: str
"""
global _megam_bin
_megam_bin = find_binary(
"megam",
bin,
env_vars=["MEGAM", "MEGAMHOME"],
binary_names=["megam.opt", "megam", "megam_686", "megam_i686.opt"],
url="http://www.cs.utah.edu/~hal/megam/",
)
开发者ID:tamamshud,项目名称:nltk,代码行数:18,代码来源:megam.py
示例17: _run_ptbconv
def _run_ptbconv(num, format='D', verbose=False):
bin = find_binary('ptbconv',
env_vars=['PTBCONV'],
url='http://www.jaist.ac.jp/~h-yamada/',
verbose=False)
input_filename = reduce(os.path.join,
[_treebank_path(), 'combined', 'wsj_%04d.mrg' % num])
cmd = [bin, '-'+format]
p = subprocess.Popen(cmd,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
stdin=open(input_filename))
(stdout, stderr) = p.communicate()
if verbose:
print stderr.strip()
return stdout
开发者ID:Sandy4321,项目名称:nltk_contrib,代码行数:20,代码来源:ptbconv.py
示例18: config_tnt
def config_tnt(bin=None, verbose=False):
"""
Configure the location of TnT Executable
@param path: Path to the TnT executable
@type path: C{str}
"""
try:
if _tnt_bin:
return _tnt_bin
except UnboundLocalError:
pass
# Find the tnt binary.
tnt_bin = find_binary('tnt', bin,
searchpath=tnt_search, env_vars=['TNTHOME'],
url='http://www.coli.uni-saarland.de/~thorsten/tnt/',
verbose=verbose)
_tnt_bin = tnt_bin
return _tnt_bin
开发者ID:Sandy4321,项目名称:nltk_contrib,代码行数:22,代码来源:tnt.py
示例19: __init__
def __init__(self, path_to_home=None, language='german',
verbose=False, abbreviation_list=None):
"""
Initialize the TreeTagger.
:param path_to_home: The TreeTagger binary.
:param language: Default language is german.
The encoding used by the model. Unicode tokens
passed to the tag() and batch_tag() methods are converted to
this charset when they are sent to TreeTagger.
The default is utf-8.
This parameter is ignored for str tokens, which are sent as-is.
The caller must ensure that tokens are encoded in the right charset.
"""
treetagger_paths = ['.', '/usr/bin', '/usr/local/bin', '/opt/local/bin',
'/Applications/bin', '~/bin', '~/Applications/bin',
'~/work/tmp/treetagger/cmd', '~/tree-tagger/cmd']
treetagger_paths = list(map(os.path.expanduser, treetagger_paths))
self._abbr_list = abbreviation_list
if language in _treetagger_languages:
if _platform == "win32":
treetagger_bin_name = 'tag-' + language
else:
treetagger_bin_name = 'tree-tagger-' + language
else:
raise LookupError('Language not in language list!')
try:
self._treetagger_bin = find_binary(
treetagger_bin_name, path_to_home,
env_vars=('TREETAGGER', 'TREETAGGER_HOME'),
searchpath=treetagger_paths,
url=_treetagger_url,
verbose=verbose)
except LookupError:
print('NLTK was unable to find the TreeTagger bin!')
开发者ID:Drumbot,项目名称:treetagger-python,代码行数:39,代码来源:treetagger.py
注:本文中的nltk.internals.find_binary函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论