@@ -13,47 +13,104 @@ static async Task Main(string[] args)
1313 var source = Language . English ;
1414 var target = Language . Russian ;
1515
16- var path = $ "C: \\ Users \\ Максим \\ Desktop \\ { source } .mp3" ;
16+ await PrintTranslationsAsync ( text , source , target ) ;
1717
18- await DownloadSpeakingAsync ( text , source , path ) ;
19- await PrintConjugationAsync ( text , source ) ;
20- await PrintTranslationAsync ( text , source , target ) ;
21- await PrintContextAsync ( text , source , target ) ;
18+ await PrintContextsAsync ( text , source , target ) ;
19+
20+ await PrintSynonimsAsync ( text , source ) ;
21+
22+ await PrintConjugationsAsync ( text , source ) ;
23+
24+ await PrintSpellingsAsync ( text , source ) ;
25+
26+ await DownloadPronunciationAsync ( text , source , Directory . GetCurrentDirectory ( ) ) ;
27+ }
28+
29+ private static async Task PrintSpellingsAsync ( string text , Language language )
30+ {
31+ var spellingsData = await _reversoClient . Spelling . GetAsync ( text , language ) ;
32+
33+ if ( spellingsData is null )
34+ {
35+ Console . WriteLine ( "Failed to get spellings" ) ;
36+ return ;
37+ }
38+
39+ Console . WriteLine ( $ "Input: { spellingsData . Text } | Language: { spellingsData . Language } ") ;
40+ Console . WriteLine ( ) ;
41+
42+ foreach ( var selection in spellingsData . Correction . Select ( ( s , i ) => new { Index = i , Spelling = s } ) )
43+ {
44+ Console . WriteLine ( $ "Number { selection . Index } ") ;
45+
46+ Console . WriteLine ( "Before:" ) ;
47+ Console . WriteLine ( selection . Spelling . MistakeText ) ;
48+ Console . WriteLine ( ) ;
49+ Console . WriteLine ( "After:" ) ;
50+ Console . WriteLine ( selection . Spelling . CorrectedText ) ;
51+ Console . WriteLine ( ) ;
52+ Console . WriteLine ( "Short description: " + selection . Spelling . ShortDescription ) ;
53+ Console . WriteLine ( "Long description: " + selection . Spelling . LongDescription ) ;
54+ Console . WriteLine ( "Other:" ) ;
55+ Console . WriteLine ( $ "Start index: { selection . Spelling . StartIndex } End index: { selection . Spelling . EndIndex } ") ;
56+ Console . WriteLine ( $ "Suggestions: { string . Join ( "; " , selection . Spelling . Suggestions ) } ") ;
57+ }
58+ }
59+
60+ private static async Task PrintSynonimsAsync ( string text , Language language )
61+ {
62+ var synonimsData = await _reversoClient . Synonyms . GetAsync ( text , language ) ;
63+
64+ if ( synonimsData is null )
65+ {
66+ Console . WriteLine ( "Failed to get synonims" ) ;
67+ return ;
68+ }
69+
70+ Console . WriteLine ( $ "Input: { synonimsData . Text } | Language: { synonimsData . Language } ") ;
71+ Console . WriteLine ( ) ;
72+
73+ foreach ( var selection in synonimsData . Synonyms . Select ( ( s , i ) => new { Index = i , Synonim = s } ) )
74+ {
75+ Console . WriteLine ( $ "{ selection . Index } . { selection . Synonim . Value } ({ selection . Synonim . PartOfSpeech } )") ;
76+ }
77+
78+ Console . WriteLine ( ) ;
2279 }
2380
24- private static async Task DownloadSpeakingAsync ( string text , Language language , string path )
81+ private static async Task DownloadPronunciationAsync ( string text , Language language , string path )
2582 {
26- var pronunciation = await _reversoClient . Pronunciation . GetAsync ( text , language ) ;
83+ var pronunciationStream = await _reversoClient . Pronunciation . GetAsync ( text , language ) ;
2784
28- if ( pronunciation is null )
85+ if ( pronunciationStream is null )
2986 {
3087 Console . WriteLine ( "Failed to get pronunciation" ) ;
3188 return ;
3289 }
3390
3491 using ( var fileStream = File . Create ( path ) )
3592 {
36- pronunciation ! . CopyTo ( fileStream ) ;
93+ pronunciationStream ! . CopyTo ( fileStream ) ;
3794 }
3895 }
3996
40- private static async Task PrintConjugationAsync ( string text , Language language )
97+ private static async Task PrintConjugationsAsync ( string text , Language language )
4198 {
42- var conjugation = await _reversoClient . Conjugation . GetAsync ( text , language ) ;
99+ var conjugationsData = await _reversoClient . Conjugation . GetAsync ( text , language ) ;
43100
44- if ( conjugation is null )
101+ if ( conjugationsData is null )
45102 {
46- Console . WriteLine ( "Failed to get conjugation " ) ;
103+ Console . WriteLine ( "Failed to get conjugations " ) ;
47104 return ;
48105 }
49106
50- Console . WriteLine ( $ "Input: { conjugation . Text } | Language: { conjugation . Language } ") ;
107+ Console . WriteLine ( $ "Input: { conjugationsData . Text } | Language: { conjugationsData . Language } ") ;
51108 Console . WriteLine ( ) ;
52109
53- foreach ( var group in conjugation . Conjugations . Keys )
110+ foreach ( var group in conjugationsData . Conjugations . Keys )
54111 {
55112 Console . WriteLine ( $ "Group: { group } ") ;
56- if ( ! conjugation . Conjugations . TryGetValue ( group , out var conjugations ) )
113+ if ( ! conjugationsData . Conjugations . TryGetValue ( group , out var conjugations ) )
57114 continue ;
58115
59116 foreach ( var selection in conjugations . Select ( ( c , i ) => new { Index = i , Conjugation = c } ) )
@@ -65,20 +122,20 @@ private static async Task PrintConjugationAsync(string text, Language language)
65122 }
66123 }
67124
68- private static async Task PrintTranslationAsync ( string text , Language source , Language target )
125+ private static async Task PrintTranslationsAsync ( string text , Language source , Language target )
69126 {
70- var translation = await _reversoClient . Translation . GetAsync ( text , source , target ) ;
127+ var translationsData = await _reversoClient . Translation . GetAsync ( text , source , target ) ;
71128
72- if ( translation is null )
129+ if ( translationsData is null )
73130 {
74131 Console . WriteLine ( "Failed to get translation" ) ;
75132 return ;
76133 }
77134
78- Console . WriteLine ( $ "Input: { translation . Text } | Source language: { translation . Source } | Target language: { translation . Target } ") ;
135+ Console . WriteLine ( $ "Input: { translationsData . Text } | Source language: { translationsData . Source } | Target language: { translationsData . Target } ") ;
79136 Console . WriteLine ( ) ;
80137
81- foreach ( var selection in translation . Translations . Select ( ( t , i ) => new { Index = i , Translation = t } ) )
138+ foreach ( var selection in translationsData . Translations . Select ( ( t , i ) => new { Index = i , Translation = t } ) )
82139 {
83140 Console . WriteLine ( $ "Number { selection . Index } ") ;
84141
@@ -101,20 +158,20 @@ private static async Task PrintTranslationAsync(string text, Language source, La
101158 }
102159 }
103160
104- private static async Task PrintContextAsync ( string text , Language source , Language target )
161+ private static async Task PrintContextsAsync ( string text , Language source , Language target )
105162 {
106- var context = await _reversoClient . Context . GetAsync ( text , source , target ) ;
163+ var contextsData = await _reversoClient . Context . GetAsync ( text , source , target ) ;
107164
108- if ( context is null )
165+ if ( contextsData is null )
109166 {
110167 Console . WriteLine ( "Failed to get context" ) ;
111168 return ;
112169 }
113170
114- Console . WriteLine ( $ "Input: { context . Text } | Source language: { context . Source } | Target language: { context . Target } ") ;
171+ Console . WriteLine ( $ "Input: { contextsData . Text } | Source language: { contextsData . Source } | Target language: { contextsData . Target } ") ;
115172 Console . WriteLine ( ) ;
116173
117- foreach ( var selection in context . Examples . Select ( ( e , i ) => new { Index = i , Example = e } ) )
174+ foreach ( var selection in contextsData . Examples . Select ( ( e , i ) => new { Index = i , Example = e } ) )
118175 {
119176 Console . WriteLine ( $ "Number { selection . Index } ") ;
120177
0 commit comments