本文整理汇总了Python中arches.app.models.concept.Concept.values方法的典型用法代码示例。如果您正苦于以下问题:Python Concept.values方法的具体用法?Python Concept.values怎么用?Python Concept.values使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类arches.app.models.concept.Concept
的用法示例。
在下文中一共展示了Concept.values方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_get_label_no_exact_match
# 需要导入模块: from arches.app.models.concept import Concept [as 别名]
# 或者: from arches.app.models.concept.Concept import values [as 别名]
def test_get_label_no_exact_match(self):
"""
Given no match on language code or region, return the first prefLabel found
"""
concept = Concept()
concept.values = [
ConceptValue({
'type': 'prefLabel',
'value': 'bier',
'language': 'nl'
}),
ConceptValue({
'type': 'prefLabel',
'category': 'label',
'value': 'beer',
'language': 'es-SP'
}),
ConceptValue({
'type': 'altLabel',
'category': 'label',
'value': 'test alt label en-US',
'language': 'en-US'
})
]
pl = concept.get_preflabel('fr-BE')
self.assertEquals(pl.type,'prefLabel')
self.assertEquals(pl.value,'bier' or 'beer')
self.assertEquals(pl.language,'nl' or 'es-SP')
示例2: test_create_concept
# 需要导入模块: from arches.app.models.concept import Concept [as 别名]
# 或者: from arches.app.models.concept.Concept import values [as 别名]
def test_create_concept(self):
"""
Test of basic CRUD on a Concept model
"""
concept_in = Concept()
concept_in.nodetype = 'Concept'
concept_in.values = [ConceptValue({
#id: '',
#conceptid: '',
'type': 'prefLabel',
'category': 'label',
'value': 'test pref label',
'language': 'en-US'
})]
concept_in.save()
concept_out = Concept().get(id=concept_in.id)
self.assertEqual(concept_out.id, concept_in.id)
self.assertEqual(concept_out.values[0].value, 'test pref label')
label = concept_in.values[0]
label.value = 'updated pref label'
concept_in.values[0] = label
concept_in.save()
concept_out = Concept().get(id=concept_in.id)
self.assertEqual(concept_out.values[0].value, 'updated pref label')
concept_out.delete(delete_self=True)
with self.assertRaises(models.Concept.DoesNotExist):
deleted_concept = Concept().get(id=concept_out.id)
示例3: test_get_region_specific_preflabel_when_language_only_version_does_not_exist
# 需要导入模块: from arches.app.models.concept import Concept [as 别名]
# 或者: from arches.app.models.concept.Concept import values [as 别名]
def test_get_region_specific_preflabel_when_language_only_version_does_not_exist(self):
"""
Given a language only and the system only has values that with regions specified, then
the system should pick the first preflabel with the same language code
"""
concept = Concept()
concept.values = [
ConceptValue({
'type': 'prefLabel',
'category': 'label',
'value': 'test pref label en-US',
'language': 'en-US'
}),
ConceptValue({
'type': 'prefLabel',
'category': 'label',
'value': 'test pref label es',
'language': 'es-SP'
}),
ConceptValue({
'type': 'altLabel',
'category': 'label',
'value': 'test alt label en-US',
'language': 'en-US'
})
]
self.assertEqual(concept.get_preflabel(lang='en').value, 'test pref label en-US')
示例4: test_prefer_preflabel_with_just_lang_code_match_over_exact_match_with_altlabel
# 需要导入模块: from arches.app.models.concept import Concept [as 别名]
# 或者: from arches.app.models.concept.Concept import values [as 别名]
def test_prefer_preflabel_with_just_lang_code_match_over_exact_match_with_altlabel(self):
"""
Given a language and region, test should pick the preflabel even if that preflabel specifies a language only
and even if an altlabel exists with the exact match
"""
concept = Concept()
concept.values = [
ConceptValue({
'type': 'prefLabel',
'category': 'label',
'value': 'test pref label en',
'language': 'en'
}),
ConceptValue({
'type': 'prefLabel',
'category': 'label',
'value': 'test pref label es',
'language': 'es-SP'
}),
ConceptValue({
'type': 'altLabel',
'category': 'label',
'value': 'test alt label en-US',
'language': 'en-US'
})
]
self.assertEqual(concept.get_preflabel(lang='en-US').value, 'test pref label en')
示例5: test_get_altlabel_when_no_preflabel_exists
# 需要导入模块: from arches.app.models.concept import Concept [as 别名]
# 或者: from arches.app.models.concept.Concept import values [as 别名]
def test_get_altlabel_when_no_preflabel_exists(self):
"""
Given a language and region, test should pick the altlabel when no preflabel exists
"""
concept = Concept()
concept.values = [
ConceptValue({
'type': 'prefLabel',
'category': 'label',
'value': 'test pref label es',
'language': 'es-SP'
}),
ConceptValue({
'type': 'altLabel',
'category': 'label',
'value': 'test alt label en-US',
'language': 'en-US'
})
]
self.assertEqual(concept.get_preflabel(lang='en-US').value, 'test alt label en-US')
示例6: test_prefer_preflabel_over_altlabel
# 需要导入模块: from arches.app.models.concept import Concept [as 别名]
# 或者: from arches.app.models.concept.Concept import values [as 别名]
def test_prefer_preflabel_over_altlabel(self):
"""
Test to confirm the proper retrieval of the prefLabel based on different language requirements
"""
concept = Concept()
concept.values = [
ConceptValue({
'type': 'prefLabel',
'category': 'label',
'value': 'test pref label en-US',
'language': 'en-US'
}),
ConceptValue({
'type': 'prefLabel',
'category': 'label',
'value': 'test pref label en',
'language': 'en'
}),
ConceptValue({
'type': 'prefLabel',
'category': 'label',
'value': 'test pref label es-SP',
'language': 'es-SP'
}),
ConceptValue({
'type': 'altLabel',
'category': 'label',
'value': 'test alt label en-US',
'language': 'en-US'
})
]
self.assertEqual(concept.get_preflabel(lang='en-US').value, 'test pref label en-US')
self.assertEqual(concept.get_preflabel(lang='en').value, 'test pref label en')
self.assertEqual(concept.get_preflabel().value, 'test pref label %s' % (test_settings.LANGUAGE_CODE))
示例7: test_get_altlabel_when_no_preflabel_exists_and_altlabel_only_specifies_lang_code
# 需要导入模块: from arches.app.models.concept import Concept [as 别名]
# 或者: from arches.app.models.concept.Concept import values [as 别名]
def test_get_altlabel_when_no_preflabel_exists_and_altlabel_only_specifies_lang_code(self):
"""
Given a language and region and the system only has values that specify a language code, the
the system should pick the altlabel even if the altlabel doesn't specifiy a region
"""
concept = Concept()
concept.values = [
ConceptValue({
'type': 'prefLabel',
'category': 'label',
'value': 'test pref label es',
'language': 'es'
}),
ConceptValue({
'type': 'altLabel',
'category': 'label',
'value': 'test alt label en',
'language': 'en'
})
]
self.assertEqual(concept.get_preflabel(lang='en-US').value, 'test alt label en')
示例8: test_prefLabel
# 需要导入模块: from arches.app.models.concept import Concept [as 别名]
# 或者: from arches.app.models.concept.Concept import values [as 别名]
def test_prefLabel(self):
"""
Test to confirm the proper retrieval of the prefLabel based on different language requirements
"""
concept = Concept()
concept.nodetype = 'Concept'
concept.values = [
ConceptValue({
'type': 'prefLabel',
'category': 'label',
'value': 'test pref label en-US',
'language': 'en-US'
}),
ConceptValue({
'type': 'prefLabel',
'category': 'label',
'value': 'test pref label en',
'language': 'en'
}),
ConceptValue({
'type': 'prefLabel',
'category': 'label',
'value': 'test pref label es-SP',
'language': 'es-SP'
}),
ConceptValue({
'type': 'altLabel',
'category': 'label',
'value': 'test alt label en-US',
'language': 'en-US'
})
]
self.assertEqual(concept.get_preflabel(lang='en-US').value, 'test pref label en-US')
self.assertEqual(concept.get_preflabel(lang='en').value, 'test pref label en')
self.assertEqual(concept.get_preflabel().value, 'test pref label %s' % (test_settings.LANGUAGE_CODE))
concept.values = [
ConceptValue({
'type': 'prefLabel',
'category': 'label',
'value': 'test pref label en',
'language': 'en'
}),
ConceptValue({
'type': 'prefLabel',
'category': 'label',
'value': 'test pref label es',
'language': 'es-SP'
}),
ConceptValue({
'type': 'altLabel',
'category': 'label',
'value': 'test alt label en-US',
'language': 'en-US'
})
]
# should pick the base language if it can't find the more specific version
self.assertEqual(concept.get_preflabel(lang='en-US').value, 'test pref label en')
concept.values = [
ConceptValue({
'type': 'prefLabel',
'category': 'label',
'value': 'test pref label es',
'language': 'es-SP'
}),
ConceptValue({
'type': 'altLabel',
'category': 'label',
'value': 'test alt label en-US',
'language': 'en-US'
})
]
self.assertEqual(concept.get_preflabel(lang='en-US').value, 'test alt label en-US')
concept.values = [
ConceptValue({
'type': 'prefLabel',
'category': 'label',
'value': 'test pref label es',
'language': 'es-SP'
}),
ConceptValue({
'type': 'altLabel',
'category': 'label',
'value': 'test alt label en',
'language': 'en'
})
]
self.assertEqual(concept.get_preflabel(lang='en-US').value, 'test alt label en')
concept.values = [
ConceptValue({
'type': 'prefLabel',
#.........这里部分代码省略.........