@@ -21,7 +21,7 @@ public sealed class OneOcr : IOcrModule, IDisposable
2121{
2222 const string apiKey = "kj)TGtrK>f]b[Piow.gU+nC@s\" \" \" \" \" \" 4" ;
2323 const int maxLineCount = 1000 ;
24- private readonly FastTextDetector ? fastText ;
24+ private readonly FastTextDetector fastText ;
2525 private readonly ILogger < OneOcr > logger ;
2626 private readonly string source ;
2727 private readonly HashSet < string > targets ;
@@ -58,15 +58,8 @@ private static nint Context_ResolvingUnmanagedDll(Assembly assembly, string arg2
5858 public OneOcr ( ILogger < OneOcr > logger , IOptionsSnapshot < LanguageOptions > langOptions , IOptionsSnapshot < BasicOcrParam > ocrParam )
5959 {
6060 this . logger = logger ;
61- try
62- {
63- this . fastText = new FastTextDetector ( ) ;
64- this . fastText . LoadDefaultModel ( ) ;
65- }
66- catch ( DllNotFoundException )
67- {
68- this . logger . LogError ( "FastTextのDLLが見つからないため、言語判定処理は利用出来ません" ) ;
69- }
61+ this . fastText = new FastTextDetector ( ) ;
62+ this . fastText . LoadDefaultModel ( ) ;
7063 this . source = langOptions . Value . Source ;
7164 this . targets = [ langOptions . Value . Target [ ..2 ] ] ;
7265 if ( this . targets . Overlaps ( [ "ja" , "zh" ] ) && this . source [ ..2 ] is not "ja" and not "zh" )
@@ -126,7 +119,7 @@ public OneOcr(ILogger<OneOcr> logger, IOptionsSnapshot<LanguageOptions> langOpti
126119
127120 public void Dispose ( )
128121 {
129- this . fastText ? . Dispose ( ) ;
122+ this . fastText . Dispose ( ) ;
130123 }
131124
132125 public async ValueTask < IEnumerable < TextRect > > RecognizeAsync ( SoftwareBitmap bitmap )
@@ -160,7 +153,7 @@ public async ValueTask<IEnumerable<TextRect>> RecognizeAsync(SoftwareBitmap bitm
160153 }
161154
162155 private bool IsTargetLangText ( string text )
163- => this . fastText ? . Predict ( text , 3 , 0.7f ) . Any ( p => this . targets . Contains ( p . Label [ ( p . Label . LastIndexOf ( '_' ) + 1 ) ..] ) ) ?? false ;
156+ => this . fastText . Predict ( text , 3 , 0.7f ) . Any ( p => this . targets . Contains ( p . Label [ ( p . Label . LastIndexOf ( '_' ) + 1 ) ..] ) ) ;
164157
165158 private unsafe IEnumerable < TextRect > Recognize ( SoftwareBitmap bitmap )
166159 {
0 commit comments