1818using FullSerializer ;
1919using System . Text ;
2020using System . Collections . Generic ;
21+ using IBM . Watson . DeveloperCloud . Services . XRAY . v1 ;
2122
2223namespace IBM . Watson . DeveloperCloud . Services . AlchemyAPI . v1
2324{
@@ -57,6 +58,41 @@ public bool HasGeographicInformation
5758 }
5859 }
5960
61+ private PositionOnMap _GeoLocation = null ;
62+ public PositionOnMap GeoLocation
63+ {
64+ get
65+ {
66+ if ( _GeoLocation == null )
67+ {
68+ string geoString = null ;
69+ for ( int i = 0 ; entities != null && i < entities . Length ; i ++ )
70+ {
71+ if ( entities [ i ] . disambiguated != null )
72+ {
73+ geoString = entities [ i ] . disambiguated . geo ;
74+ if ( ! string . IsNullOrEmpty ( geoString ) )
75+ {
76+ string [ ] geoValues = geoString . Split ( ' ' ) ;
77+ if ( geoValues != null && geoValues . Length == 2 )
78+ {
79+ double latitute = 0 ;
80+ double longitutde = 0 ;
81+
82+ if ( double . TryParse ( geoValues [ 0 ] , out latitute ) && double . TryParse ( geoValues [ 1 ] , out longitutde ) )
83+ {
84+ _GeoLocation = new PositionOnMap ( latitute , longitutde , entities [ i ] . disambiguated . name ) ;
85+ break ;
86+ }
87+ }
88+ }
89+ }
90+ }
91+ }
92+ return _GeoLocation ;
93+ }
94+ }
95+
6096 public override string ToString ( )
6197 {
6298 StringBuilder stringBuilder = new StringBuilder ( ) ;
@@ -615,6 +651,37 @@ public bool HasGeographicInformation
615651 return ! string . IsNullOrEmpty ( geoString ) ;
616652 }
617653 }
654+
655+ private PositionOnMap _GeoLocation = null ;
656+ public PositionOnMap GeoLocation
657+ {
658+ get
659+ {
660+ if ( _GeoLocation == null )
661+ {
662+ string geoString = null ;
663+ if ( disambiguated != null )
664+ {
665+ geoString = disambiguated . geo ;
666+ if ( ! string . IsNullOrEmpty ( geoString ) )
667+ {
668+ string [ ] geoValues = geoString . Split ( ' ' ) ;
669+ if ( geoValues != null && geoValues . Length == 2 )
670+ {
671+ double latitute = 0 ;
672+ double longitutde = 0 ;
673+
674+ if ( double . TryParse ( geoValues [ 0 ] , out latitute ) && double . TryParse ( geoValues [ 1 ] , out longitutde ) )
675+ {
676+ _GeoLocation = new PositionOnMap ( latitute , longitutde , disambiguated . name ) ;
677+ }
678+ }
679+ }
680+ }
681+ }
682+ return _GeoLocation ;
683+ }
684+ }
618685 } ;
619686
620687 [ fsObject ]
@@ -749,12 +816,6 @@ public string ToLongString()
749816 return stringBuilder . ToString ( ) ;
750817 }
751818
752- public override string ToString ( )
753- {
754- return string . Format ( "[CombinedCallData: status={0}, totalTransactions={1}, language={2}, text={3}, keywords={4}, entities={5}, docSentiment={6}, concepts={7}, " +
755- "relations={8}, taxonomy={9}, docEmotions={10}, dates={11}, HasData={12}, " +
756- "EntityCombined={13}, EntityCombinedCommaSeperated={14}]" , status , totalTransactions , language , text , keywords , entities , docSentiment , concepts , relations , taxonomy , docEmotions , dates , HasData , EntityCombined , EntityCombinedCommaSeperated ) ;
757- }
758819 } ;
759820
760821
@@ -768,32 +829,6 @@ public class Keyword
768829
769830 } ;
770831
771- [ fsObject ]
772- public class DateData
773- {
774- public string text { get ; set ; }
775- public string date { get ; set ; }
776-
777- private System . DateTime m_dateValue = default ( System . DateTime ) ;
778- public System . DateTime DateValue
779- {
780- get
781- {
782- if ( m_dateValue == default ( System . DateTime ) && ! string . IsNullOrEmpty ( date ) && date . Length > 8 )
783- {
784- //19840101T000000
785- System . DateTime . TryParseExact ( date . Remove ( 8 ) ,
786- "yyyyddMM" ,
787- System . Globalization . CultureInfo . InvariantCulture ,
788- System . Globalization . DateTimeStyles . None ,
789- out m_dateValue ) ;
790-
791- }
792- return m_dateValue ;
793- }
794- }
795- } ;
796-
797832 [ fsObject ]
798833 public class Concept
799834 {
@@ -873,5 +908,30 @@ public class DocEmotions
873908 public string sadness { get ; set ; }
874909 } ;
875910
911+ [ fsObject ]
912+ public class DateData
913+ {
914+ public string text { get ; set ; }
915+ public string date { get ; set ; }
916+
917+ private System . DateTime m_dateValue = default ( System . DateTime ) ;
918+ public System . DateTime DateValue
919+ {
920+ get
921+ {
922+ if ( m_dateValue == default ( System . DateTime ) && ! string . IsNullOrEmpty ( date ) && date . Length > 8 )
923+ {
924+ //19840101T000000
925+ System . DateTime . TryParseExact ( date . Remove ( 8 ) ,
926+ "yyyyddMM" ,
927+ System . Globalization . CultureInfo . InvariantCulture ,
928+ System . Globalization . DateTimeStyles . None ,
929+ out m_dateValue ) ;
930+
931+ }
932+ return m_dateValue ;
933+ }
934+ }
935+ } ;
876936
877937}
0 commit comments