本文整理汇总了Python中nltk.sem.logic.is_indvar函数的典型用法代码示例。如果您正苦于以下问题:Python is_indvar函数的具体用法?Python is_indvar怎么用?Python is_indvar使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了is_indvar函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self, domain, assign=None):
dict.__init__(self)
self.domain = domain
if assign:
for (var, val) in assign:
assert val in self.domain,\
"'%s' is not in the domain: %s" % (val, self.domain)
assert is_indvar(var),\
"Wrong format for an Individual Variable: '%s'" % var
self[var] = val
self._addvariant()
开发者ID:0day1day,项目名称:golismero,代码行数:11,代码来源:evaluate.py
示例2: clausify
def clausify(expression):
"""
Skolemize, clausify, and standardize the variables apart.
"""
clause_list = []
for clause in _clausify(skolemize(expression)):
for free in clause.free():
if is_indvar(free.name):
newvar = VariableExpression(unique_variable())
clause = clause.replace(free, newvar)
clause_list.append(clause)
return clause_list
开发者ID:2ricecrackerfolder,项目名称:twittermood,代码行数:12,代码来源:resolution.py
示例3: add
def add(self, var, val):
"""
Add a new variable-value pair to the assignment, and update
``self.variant``.
"""
assert val in self.domain,\
"%s is not in the domain %s" % (val, self.domain)
assert is_indvar(var),\
"Wrong format for an Individual Variable: '%s'" % var
self[var] = val
self._addvariant()
return self
开发者ID:SamuraiT,项目名称:nltk3-alpha,代码行数:13,代码来源:evaluate.py
示例4: DrtVariableExpression
def DrtVariableExpression(variable):
"""
This is a factory method that instantiates and returns a subtype of
``DrtAbstractVariableExpression`` appropriate for the given variable.
"""
if is_indvar(variable.name):
return DrtIndividualVariableExpression(variable)
elif is_funcvar(variable.name):
return DrtFunctionVariableExpression(variable)
elif is_eventvar(variable.name):
return DrtEventVariableExpression(variable)
else:
return DrtConstantExpression(variable)
开发者ID:BohanHsu,项目名称:developer,代码行数:13,代码来源:drt.py
示例5: _convert2val
def _convert2val(self, valuation_str):
"""
Transform the output file into an NLTK-style Valuation.
:return: A model if one is generated; None otherwise.
:rtype: sem.Valuation
"""
valuation_standard_format = self._transform_output(valuation_str, 'standard')
val = []
for line in valuation_standard_format.splitlines(False):
l = line.strip()
if l.startswith('interpretation'):
# find the number of entities in the model
num_entities = int(l[l.index('(') + 1 : l.index(',')].strip())
elif l.startswith('function') and l.find('_') == -1:
# replace the integer identifier with a corresponding alphabetic character
name = l[l.index('(') + 1 : l.index(',')].strip()
if is_indvar(name):
name = name.upper()
value = int(l[l.index('[') + 1 : l.index(']')].strip())
val.append((name, MaceCommand._make_model_var(value)))
elif l.startswith('relation'):
l = l[l.index('(') + 1 :]
if '(' in l:
# relation is not nullary
name = l[: l.index('(')].strip()
values = [
int(v.strip())
for v in l[l.index('[') + 1 : l.index(']')].split(',')
]
val.append(
(name, MaceCommand._make_relation_set(num_entities, values))
)
else:
# relation is nullary
name = l[: l.index(',')].strip()
value = int(l[l.index('[') + 1 : l.index(']')].strip())
val.append((name, value == 1))
return Valuation(val)
开发者ID:prz3m,项目名称:kind2anki,代码行数:44,代码来源:mace.py
示例6: _order_ref_strings
def _order_ref_strings(self, refs):
strings = ["%s" % ref for ref in refs]
ind_vars = []
func_vars = []
event_vars = []
other_vars = []
for s in strings:
if is_indvar(s):
ind_vars.append(s)
elif is_funcvar(s):
func_vars.append(s)
elif is_eventvar(s):
event_vars.append(s)
else:
other_vars.append(s)
return sorted(other_vars) + \
sorted(event_vars, key=lambda v: int([v[2:],-1][len(v[2:]) == 0])) + \
sorted(func_vars, key=lambda v: (v[0], int([v[1:],-1][len(v[1:])==0]))) + \
sorted(ind_vars, key=lambda v: (v[0], int([v[1:],-1][len(v[1:])==0])))
开发者ID:BohanHsu,项目名称:developer,代码行数:19,代码来源:drt.py
注:本文中的nltk.sem.logic.is_indvar函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论