File tree Expand file tree Collapse file tree 5 files changed +12
-12
lines changed
LanguageIdentification.TestConsole
LanguageIdentification.Test Expand file tree Collapse file tree 5 files changed +12
-12
lines changed Original file line number Diff line number Diff line change @@ -24,7 +24,7 @@ Install-Package LanguageIdentification
2424``` C#
2525var langIdClassifier = new LanguageIdentificationClassifier ();
2626langIdClassifier .Append (" Hello" );
27- var result = langIdClassifier .Classify ();
27+ using var result = langIdClassifier .Classify ();
2828Console .WriteLine (result );
2929```
3030
@@ -35,7 +35,7 @@ Console.WriteLine(result);
3535
36362 . 通过静态方法使用
3737``` C#
38- var result = LanguageIdentificationClassifier .Classify (" Hello" );
38+ using var result = LanguageIdentificationClassifier .Classify (" Hello" );
3939Console .WriteLine (result );
4040```
4141
@@ -50,7 +50,7 @@ Console.WriteLine(result);
5050``` C#
5151var classifier = new LanguageIdentificationClassifier (" zh" , " en" );
5252langIdClassifier .Append (" Hello" );
53- var result = langIdClassifier .Classify ();
53+ using var result = langIdClassifier .Classify ();
5454Console .WriteLine (result );
5555```
5656 - 速度会更快;
Original file line number Diff line number Diff line change @@ -22,14 +22,14 @@ public void ShouldDetectionFailWithOutLanguageLoaded()
2222 defaultClassifier . Reset ( ) ;
2323
2424 defaultClassifier . Append ( item . Text ) ;
25- var defaultClassifierResult = defaultClassifier . Classify ( ) ;
25+ using var defaultClassifierResult = defaultClassifier . Classify ( ) ;
2626
2727 Assert . AreEqual ( item . LanguageCode , defaultClassifierResult . LanguageCode ) ;
2828
2929 var portionClassifier = new LanguageIdentificationClassifier ( allSupportedLanguages . Where ( m => m != defaultClassifierResult . LanguageCode ) ) ;
3030
3131 portionClassifier . Append ( item . Text ) ;
32- var portionClassifierResult = portionClassifier . Classify ( ) ;
32+ using var portionClassifierResult = portionClassifier . Classify ( ) ;
3333
3434 Assert . AreNotEqual ( defaultClassifierResult . LanguageCode , portionClassifierResult . LanguageCode ) ;
3535
@@ -46,7 +46,7 @@ public void ShouldOnlyLoadedLanguageReturn()
4646 {
4747 classifier . Reset ( ) ;
4848 classifier . Append ( item . Text ) ;
49- var result = classifier . Classify ( ) ;
49+ using var result = classifier . Classify ( ) ;
5050
5151 Assert . IsTrue ( result . LanguageCode == "zh" || result . LanguageCode == "en" ) ;
5252
Original file line number Diff line number Diff line change @@ -15,7 +15,7 @@ public void ShouldBeSuccess()
1515 {
1616 foreach ( var item in TestData . Items )
1717 {
18- var result = LanguageIdentificationClassifier . Classify ( item . Text ) ;
18+ using var result = LanguageIdentificationClassifier . Classify ( item . Text ) ;
1919 Assert . AreEqual ( item . LanguageCode , result . LanguageCode ) ;
2020
2121 Console . WriteLine ( result ) ;
Original file line number Diff line number Diff line change @@ -96,8 +96,8 @@ public void ShouldCreateRankSuccess()
9696 langIdClassifier . Append ( item . Text ) ;
9797 using var result = langIdClassifier . Classify ( ) ;
9898
99- var rank = langIdClassifier . CreateRank ( ) . ToArray ( ) ;
100- Assert . AreEqual ( supportedLanguageCount , rank . Length ) ;
99+ using var rank = langIdClassifier . CreateRank ( ) ;
100+ Assert . AreEqual ( supportedLanguageCount , rank . Count ) ;
101101
102102 langIdClassifier . Reset ( ) ;
103103 }
@@ -138,7 +138,7 @@ public void UnableAccessResultAfterDisposed()
138138 foreach ( var item in TestData . Items )
139139 {
140140 langIdClassifier . Append ( item . Text ) ;
141- var result = langIdClassifier . Classify ( ) ;
141+ using var result = langIdClassifier . Classify ( ) ;
142142
143143 result . Dispose ( ) ;
144144
Original file line number Diff line number Diff line change @@ -31,11 +31,11 @@ static void Main(string[] args)
3131 Console . WriteLine ( $ "Load Time: { stopwatch . ElapsedMilliseconds } ") ;
3232
3333 langIdClassifier . Append ( Text_ES ) ;
34- var result = langIdClassifier . Classify ( ) ;
34+ using var result = langIdClassifier . Classify ( ) ;
3535
3636 Console . WriteLine ( result ) ;
3737 Console . WriteLine ( "---- Rank ----" ) ;
38- var detectedLanguages = langIdClassifier . CreateRank ( ) ;
38+ using var detectedLanguages = langIdClassifier . CreateRank ( ) ;
3939 foreach ( var item in detectedLanguages )
4040 {
4141 Console . WriteLine ( item ) ;
You can’t perform that action at this time.
0 commit comments