1
- # coding=utf-8
1
+ # coding=utf-8 pylint: disable=too-many-lines
2
2
# ------------------------------------
3
3
# Copyright (c) Microsoft Corporation.
4
4
# Licensed under the MIT License.
@@ -616,6 +616,11 @@ class LinkedEntity(DictMixin):
616
616
:ivar data_source: Data source used to extract entity linking,
617
617
such as Wiki/Bing etc.
618
618
:vartype data_source: str
619
+ :ivar str bing_id: Bing unique identifier of the recognized entity. Use in conjunction
620
+ with the Bing Entity Search SDK to fetch additional relevant information. Only
621
+ available for API version v3.1-preview.2 and up.
622
+ .. versionadded:: v3.1-preview.2
623
+ The *bing_id* property.
619
624
"""
620
625
621
626
def __init__ (self , ** kwargs ):
@@ -625,22 +630,32 @@ def __init__(self, **kwargs):
625
630
self .data_source_entity_id = kwargs .get ("data_source_entity_id" , None )
626
631
self .url = kwargs .get ("url" , None )
627
632
self .data_source = kwargs .get ("data_source" , None )
633
+ self .bing_id = kwargs .get ("bing_id" , None )
628
634
629
635
@classmethod
630
636
def _from_generated (cls , entity ):
637
+ bing_id = entity .bing_id if hasattr (entity , "bing_id" ) else None
631
638
return cls (
632
639
name = entity .name ,
633
640
matches = [LinkedEntityMatch ._from_generated (e ) for e in entity .matches ], # pylint: disable=protected-access
634
641
language = entity .language ,
635
642
data_source_entity_id = entity .id ,
636
643
url = entity .url ,
637
644
data_source = entity .data_source ,
645
+ bing_id = bing_id ,
638
646
)
639
647
640
648
def __repr__ (self ):
641
649
return "LinkedEntity(name={}, matches={}, language={}, data_source_entity_id={}, url={}, " \
642
- "data_source={})" .format (self .name , repr (self .matches ), self .language , self .data_source_entity_id ,
643
- self .url , self .data_source )[:1024 ]
650
+ "data_source={}, bing_id={})" .format (
651
+ self .name ,
652
+ repr (self .matches ),
653
+ self .language ,
654
+ self .data_source_entity_id ,
655
+ self .url ,
656
+ self .data_source ,
657
+ self .bing_id ,
658
+ )[:1024 ]
644
659
645
660
646
661
class LinkedEntityMatch (DictMixin ):
0 commit comments