Exemplo n.º 1
0
        public UnionTextSegmenter(params InitParam_v1[] ps)
        {
            if (ps == null || !ps.Any())
            {
                throw (new ArgumentNullException(nameof(ps)));
            }

            _NativeTextMMFModelsBinary = new NativeTextMMFModelBinary[ps.Length];
            _TextSegmenters            = new TextSegmenter           [ps.Length];
            _Languages = new LanguageEnum            [ps.Length];

            for (var i = 0; i < ps.Length; i++)
            {
                ref var p = ref ps[i];
                var     m = new NativeTextMMFModelBinary(p.ModelConfigs);
                _NativeTextMMFModelsBinary[i] = m;
                _TextSegmenters           [i] = new TextSegmenter(m);
                _Languages                [i] = p.Language;
            }
Exemplo n.º 2
0
        public UnionTextSegmenter(params InitParam_v1[] ps)
        {
            if ((ps == null) || !ps.Any())
            {
                throw (new ArgumentNullException(nameof(ps)));
            }

            #region comm. [.consecutively.]

            /*
             * _NativeTextMMFModelsBinary = new NativeTextMMFModelBinary[ ps.Length ];
             * _TextSegmenters            = new TextSegmenter           [ ps.Length ];
             * _Languages                 = new LanguageEnum            [ ps.Length ];
             *
             * for ( var i = 0; i < ps.Length; i++ )
             * {
             *  ref readonly var p = ref ps[ i ];
             *  var m = new NativeTextMMFModelBinary( p.ModelConfigs );
             *  _NativeTextMMFModelsBinary[ i ] = m;
             *  _TextSegmenters           [ i ] = new TextSegmenter( m );
             *  _Languages                [ i ] = p.Language;
             * }
             * //*/
            #endregion

            #region [.parallel.]
            var nativeTextMMFModelsBinary = new NativeTextMMFModelBinary[ps.Length];
            var textSegmenters            = new TextSegmenter           [ps.Length];
            var languages = new LanguageEnum            [ps.Length];

            Parallel.ForEach(ps, (p, _, i) =>
            {
                var m = new NativeTextMMFModelBinary(p.ModelConfigs);
                nativeTextMMFModelsBinary[i] = m;
                textSegmenters           [i] = new TextSegmenter(m);
                languages                [i] = p.Language;
            });

            _NativeTextMMFModelsBinary = nativeTextMMFModelsBinary;
            _TextSegmenters            = textSegmenters;
            _Languages = languages;
            #endregion
        }
Exemplo n.º 3
0
 public static SetNative GetSet(NativeTextMMFModelBinary model) => model._Set;