1515*
1616*/
1717
18+ using System ;
1819using FullSerializer ;
20+ using System . Collections . Generic ;
1921
2022namespace IBM . Watson . DeveloperCloud . Services . NaturalLanguageUnderstanding . v1
2123{
@@ -484,7 +486,7 @@ public class DeletedResponse
484486 public string deleted { get ; set ; }
485487 }
486488
487- [ fsObject ]
489+ [ fsObject ( Converter = typeof ( ParametersConverter ) ) ]
488490 public class Parameters
489491 {
490492 /// <summary>
@@ -494,12 +496,10 @@ public class Parameters
494496 /// <summary>
495497 /// The HTML file to analyze
496498 /// </summary>
497- [ fsIgnore ]
498499 public string html { get ; set ; }
499500 /// <summary>
500501 /// The web page to analyze
501502 /// </summary>
502- [ fsIgnore ]
503503 public string url { get ; set ; }
504504 /// <summary>
505505 /// Specific features to analyze the document for
@@ -508,26 +508,26 @@ public class Parameters
508508 /// <summary>
509509 /// Remove website elements, such as links, ads, etc
510510 /// </summary>
511- public bool clean { get ; set ; }
511+ public bool ? clean { get ; set ; }
512512 /// <summary>
513513 /// XPath query for targeting nodes in HTML
514514 /// </summary>
515515 public string xpath { get ; set ; }
516516 /// <summary>
517517 /// Whether to use raw HTML content if text cleaning fails
518518 /// </summary>
519- public bool fallback_to_raw { get ; set ; }
519+ public bool ? fallback_to_raw { get ; set ; }
520520 /// <summary>
521521 /// Whether or not to return the analyzed text
522522 /// </summary>
523- public bool return_analyzed_text { get ; set ; }
523+ public bool ? return_analyzed_text { get ; set ; }
524524 /// <summary>
525525 /// ISO 639-1 code indicating the language to use in the analysis
526526 /// </summary>
527527 public string language { get ; set ; }
528528 }
529529
530- [ fsObject ]
530+ [ fsObject ( Converter = typeof ( FeaturesConverter ) ) ]
531531 public class Features
532532 {
533533 /// <summary>
@@ -685,4 +685,145 @@ public class NaturalLanguageUnderstandingVersion
685685 public const string Version = "2017-02-27" ;
686686 }
687687 #endregion
688+
689+ #region Parameters Converter
690+ public class ParametersConverter : fsConverter
691+ {
692+ private static fsSerializer sm_Serializer = new fsSerializer ( ) ;
693+
694+ public override bool CanProcess ( Type type )
695+ {
696+ return type == typeof ( Parameters ) ;
697+ }
698+
699+ public override fsResult TryDeserialize ( fsData data , ref object instance , Type storageType )
700+ {
701+ throw new NotImplementedException ( ) ;
702+ }
703+
704+ public override fsResult TrySerialize ( object instance , out fsData serialized , Type storageType )
705+ {
706+ Parameters parameters = ( Parameters ) instance ;
707+ serialized = null ;
708+
709+ Dictionary < string , fsData > serialization = new Dictionary < string , fsData > ( ) ;
710+ if ( parameters . text != null )
711+ serialization . Add ( "text" , new fsData ( parameters . text ) ) ;
712+
713+ if ( parameters . url != null )
714+ serialization . Add ( "url" , new fsData ( parameters . url ) ) ;
715+
716+ if ( parameters . html != null )
717+ serialization . Add ( "html" , new fsData ( parameters . html ) ) ;
718+
719+ if ( parameters . clean != null )
720+ serialization . Add ( "clean" , new fsData ( ( bool ) parameters . clean ) ) ;
721+
722+ if ( parameters . xpath != null )
723+ serialization . Add ( "xpath" , new fsData ( parameters . xpath ) ) ;
724+
725+ if ( parameters . fallback_to_raw != null )
726+ serialization . Add ( "fallback_to_raw" , new fsData ( ( bool ) parameters . fallback_to_raw ) ) ;
727+
728+ if ( parameters . return_analyzed_text != null )
729+ serialization . Add ( "return_analyzed_text" , new fsData ( ( bool ) parameters . return_analyzed_text ) ) ;
730+
731+ if ( parameters . xpath != null )
732+ serialization . Add ( "xpath" , new fsData ( parameters . xpath ) ) ;
733+
734+ fsData tempData = null ;
735+ sm_Serializer . TrySerialize ( parameters . features , out tempData ) ;
736+ serialization . Add ( "features" , tempData ) ;
737+
738+ serialized = new fsData ( serialization ) ;
739+
740+ return fsResult . Success ;
741+ }
742+ }
743+ #endregion
744+
745+ #region Features Converter
746+ public class FeaturesConverter : fsConverter
747+ {
748+ private static fsSerializer sm_Serializer = new fsSerializer ( ) ;
749+
750+ public override bool CanProcess ( Type type )
751+ {
752+ return type == typeof ( Parameters ) ;
753+ }
754+
755+ public override fsResult TryDeserialize ( fsData data , ref object instance , Type storageType )
756+ {
757+ throw new NotImplementedException ( ) ;
758+ }
759+
760+ public override fsResult TrySerialize ( object instance , out fsData serialized , Type storageType )
761+ {
762+ Features features = ( Features ) instance ;
763+ serialized = null ;
764+
765+ Dictionary < string , fsData > serialization = new Dictionary < string , fsData > ( ) ;
766+
767+ fsData tempData = null ;
768+
769+ if ( features . concepts != null )
770+ {
771+ sm_Serializer . TrySerialize ( features . concepts , out tempData ) ;
772+ serialization . Add ( "concepts" , tempData ) ;
773+ }
774+
775+ if ( features . emotion != null )
776+ {
777+ sm_Serializer . TrySerialize ( features . emotion , out tempData ) ;
778+ serialization . Add ( "emotion" , tempData ) ;
779+ }
780+
781+ if ( features . entities != null )
782+ {
783+ sm_Serializer . TrySerialize ( features . entities , out tempData ) ;
784+ serialization . Add ( "entities" , tempData ) ;
785+ }
786+
787+ if ( features . keywords != null )
788+ {
789+ sm_Serializer . TrySerialize ( features . keywords , out tempData ) ;
790+ serialization . Add ( "keywords" , tempData ) ;
791+ }
792+
793+ if ( features . metadata != null )
794+ {
795+ sm_Serializer . TrySerialize ( features . metadata , out tempData ) ;
796+ serialization . Add ( "metadata" , tempData ) ;
797+ }
798+
799+ if ( features . relations != null )
800+ {
801+ sm_Serializer . TrySerialize ( features . relations , out tempData ) ;
802+ serialization . Add ( "relations" , tempData ) ;
803+ }
804+
805+ if ( features . semantic_roles != null )
806+ {
807+ sm_Serializer . TrySerialize ( features . semantic_roles , out tempData ) ;
808+ serialization . Add ( "semantic_roles" , tempData ) ;
809+ }
810+
811+ if ( features . sentiment != null )
812+ {
813+ sm_Serializer . TrySerialize ( features . sentiment , out tempData ) ;
814+ serialization . Add ( "sentiment" , tempData ) ;
815+ }
816+
817+ if ( features . categories != null )
818+ {
819+ sm_Serializer . TrySerialize ( features . categories , out tempData ) ;
820+ serialization . Add ( "categories" , tempData ) ;
821+ }
822+
823+ serialized = new fsData ( serialization ) ;
824+
825+ return fsResult . Success ;
826+ }
827+ }
828+ #endregion
688829}
0 commit comments