コード例 #1
0
        public TranslationEngine(string baseUrl, string projectId, IHttpClient httpClient = null)
        {
            ProjectId = projectId;
            var wordTokenizer = new LatinWordTokenizer();

            SourceWordTokenizer  = wordTokenizer;
            TargetWordTokenizer  = wordTokenizer;
            RestClient           = new TranslationRestClient(baseUrl, httpClient ?? new AjaxHttpClient());
            ErrorCorrectionModel = new ErrorCorrectionModel();
            _cts = new CancellationTokenSource();
        }
コード例 #2
0
        public ErrorCorrectionWordGraphProcessor(ErrorCorrectionModel ecm, IReadOnlyList <string> sourceSegment,
                                                 WordGraph wordGraph, double ecmWeight = 1, double wordGraphWeight = 1)
        {
            _ecm            = ecm;
            _sourceSegment  = sourceSegment;
            _wordGraph      = wordGraph;
            EcmWeight       = ecmWeight;
            WordGraphWeight = wordGraphWeight;

            _restScores           = _wordGraph.ComputeRestScores().ToArray();
            _stateEcmScoreInfos   = new List <EcmScoreInfo>();
            _arcEcmScoreInfos     = new List <List <EcmScoreInfo> >();
            _stateBestScores      = new List <List <double> >();
            _stateWordGraphScores = new List <double>();
            _stateBestPrevArcs    = new List <List <int> >();
            _statesInvolvedInArcs = new HashSet <int>();
            _prevPrefix           = new string[0];

            InitStates();
            InitArcs();
        }