Debian Codegraph @

components/chsdet/src/nsEscCharsetProber.pas

raw
1 // +----------------------------------------------------------------------+
2 // | chsdet - Charset Detector Library |
3 // +----------------------------------------------------------------------+
4 // | Copyright (C) 2006, Nick Yakowlew http://chsdet.sourceforge.net |
5 // +----------------------------------------------------------------------+
6 // | Based on Mozilla sources http://www.mozilla.org/projects/intl/ |
7 // +----------------------------------------------------------------------+
8 // | This library is free software; you can redistribute it and/or modify |
9 // | it under the terms of the GNU General Public License as published by |
10 // | the Free Software Foundation; either version 2 of the License, or |
11 // | (at your option) any later version. |
12 // | This library is distributed in the hope that it will be useful |
13 // | but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
15 // | See the GNU Lesser General Public License for more details. |
16 // | http://www.opensource.org/licenses/lgpl-license.php |
17 // +----------------------------------------------------------------------+
18 //
19 // $Id: nsEscCharsetProber.pas,v 1.4 2013/04/23 19:47:10 ya_nick Exp $
20
21 unit nsEscCharsetProber;
22
23 interface
24
25 uses
26 nsCore,
27 MultiModelProber;
28
29 type
30 TnsEscCharSetProber = class (TMultiModelProber)
31 public
32 constructor Create; override;
33 function GetConfidence: float; override;
34 end;
35
36
37 implementation
38 uses
39 nsCodingStateMachine,
40 CustomDetector;
41
42 {$I '.\mbclass\ISO2022KRLangModel.inc'}
43 {$I '.\mbclass\ISO2022JPLangModel.inc'}
44 {$I '.\mbclass\ISO2022CNLangModel.inc'}
45 {$I '.\mbclass\HZLangModel.inc'}
46
47 { TnsEscCharSetProber }
48 const
49 NUM_OF_ESC_CHARSETS = 4;
50
51 constructor TnsEscCharSetProber.Create;
52 begin
53 inherited;
54 AddCharsetModel(HZSMModel);
55 AddCharsetModel(ISO2022CNSMModel);
56 AddCharsetModel(ISO2022JPSMModel);
57 AddCharsetModel(ISO2022KRSMModel);
58 Reset;
59 end;
60
61 function TnsEscCharSetProber.GetConfidence: float;
62 begin
63 case mState of
64 psFoundIt: Result := SURE_YES;
65 psNotMe: Result := SURE_NO;
66 psDetecting: Result := (SURE_YES + SURE_NO) / 2;
67 else
68 Result := 1.1 * SURE_NO;
69 end;
70 end;
71
72 end.
73
74