当前位置: 首页>>代码示例>>Python>>正文


Python Utilities.tuple_str方法代码示例

本文整理汇总了Python中utilities.Utilities.tuple_str方法的典型用法代码示例。如果您正苦于以下问题:Python Utilities.tuple_str方法的具体用法?Python Utilities.tuple_str怎么用?Python Utilities.tuple_str使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在utilities.Utilities的用法示例。


在下文中一共展示了Utilities.tuple_str方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: do_form

# 需要导入模块: from utilities import Utilities [as 别名]
# 或者: from utilities.Utilities import tuple_str [as 别名]
	def do_form(self, lemma, categories, words = ()):
		"""
		Generate the specified inflected form for the lemma, preserving the given words.
		When a word form is provided, it is returned; when not, it is generated applying the appropriate inflection form.

		@param lemma: The lemma to inflect.
		@type lemma: Lemma
		@param categories: The categories of the word to generate.
		@type categories: tuple of str/CategoryFilter
		@param words: The inflected forms (usually a list of irregular forms).
		@type words: sequence of Word
		@return: The inflected word form for the lemma.
		@rtype: Word
		@raise InflectionError: If the inflection form can not accept the lemma respecting mandatory steps.
		@raise TransformSyntaxError: If the substitution pattern in some step can not be compiled.
		"""
		word = None
		#Find is there is a default form
		for w in words:
			if CategoryFilter.test(categories, w.categories):
				word = w
				break
		if word is None:
			#Get the form == dict of transforms
			form = self.__forms[categories]
			s = None
			#Iterate over transforms
			for transform in form:
				s = transform(lemma, words)
				if s is not None:
					break
			if s is None:
				raise InflectionError("Inflection can not generate %s for lemma '%s'" % (Utilities.tuple_str(categories), `lemma`))
			word = Word(s, lemma, categories)
		return word
开发者ID:BackupTheBerlios,项目名称:pylilac-svn,代码行数:37,代码来源:inflection.py

示例2: __repr__

# 需要导入模块: from utilities import Utilities [as 别名]
# 或者: from utilities.Utilities import tuple_str [as 别名]
    def __repr__(self):
        """
		Return a verbose string representation.
		@rtype: str
		"""
        p_o_s, lemma_categories, categories = self._content[3:6]
        r = []
        r.append("{")
        if p_o_s:
            r.append(p_o_s)
        else:
            r.append("*")
        if lemma_categories:
            r.append(Utilities.tuple_str(lemma_categories))
        elif categories:
            r.append("()")
        if categories:
            r.append(Utilities.tuple_str(categories))
        r.append("}")
        return "".join(r)
开发者ID:BackupTheBerlios,项目名称:pylilac-svn,代码行数:22,代码来源:lexicon.py

示例3: __str__

# 需要导入模块: from utilities import Utilities [as 别名]
# 或者: from utilities.Utilities import tuple_str [as 别名]
	def __str__(self):
		"""
		Return a short string representation.

		@rtype: str
		"""
		s = [self.p_o_s]
		if self.condition:
			s.append(self.condition)
		if self.lemma_categories:
			s.append(Utilities.tuple_str(self.lemma_categories))
		return " ".join(s)
开发者ID:BackupTheBerlios,项目名称:pylilac-svn,代码行数:14,代码来源:inflection.py


注:本文中的utilities.Utilities.tuple_str方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。