コード例 #1
0
        public void IndexText_ThenSearch_MultipleMatches_ScoresHigher()
        {
            var index = new DocumentIndex();

            index.IndexText("cat sat on mat", "cat-m");
            index.IndexText("cat sat on sofa", "cat-s");
            index.IndexText("dog sat on mat", "dog-m");
            index.IndexText("dog sat on sofa", "dog-s");
            index.IndexText("dog sat on dog", "dog-x");

            var results1 = index.Search("cat sat").ToList();

            Assert.That(results1.Count, Is.EqualTo(2));
            Assert.That(results1.Any(r => r.DocumentKey == "cat-m"));

            var results2 = index.Search("cat mat").ToList();

            Assert.That(results2.Count, Is.EqualTo(1));
            Assert.That(results2.Single().DocumentKey, Is.EqualTo("cat-m"));

            var results3 = index.Search("sat dog").ToList();

            Assert.That(results3.Count, Is.EqualTo(3));
            Assert.That(results3.First().DocumentKey, Is.EqualTo("dog-x"));
        }
コード例 #2
0
ファイル: CorpusAnalyser.cs プロジェクト: roberino/linqinfer
        public CorpusAnalyser(IEnumerable<string> samples)
        {
            _index = new DocumentIndex();
            _markovChain = new DiscreteMarkovChain<string>();

            _documentTermMatrix = Analyse(samples.Select(s => new TokenisedTextDocument(Guid.NewGuid().ToString(), _index.Tokeniser.Tokenise(s))));
        }
コード例 #3
0
ファイル: CorpusAnalyser.cs プロジェクト: roberino/linqinfer
        public CorpusAnalyser(IEnumerable<TokenisedTextDocument> samples)
        {
            _index = new DocumentIndex();
            _markovChain = new DiscreteMarkovChain<string>();

            _documentTermMatrix = Analyse(samples);
        }
コード例 #4
0
		private IDocumentIndex DoGetOrCreateDocumentFinder(AccountName accountName, DocumentIndexTypeToken documentIndexTypeToken)
		{
			ConcurrentDictionary<string, Lazy<IDocumentIndex>> storage = _documentIndexes[documentIndexTypeToken];
			return storage.GetOrAdd(accountName.Value, key => Lazy.Create(() =>
				{
					IDocumentIndex documentIndex = new DocumentIndex(documentIndexTypeToken, accountName, () =>
						{
							Lazy<IDocumentIndex> _;
							storage.TryRemove(accountName.Value, out _);
						}, _documentIndexSetup, _logger);
					return documentIndex;
				})).Value;
		}
コード例 #5
0
        public void Index_Then_Search()
        {
            var search = new DocumentIndex();

            var docs = TestData.TestCorpus().Select(t => XDocument.Parse(t)).ToList().AsQueryable();

            search.IndexDocuments(docs, d => d.Root.Attribute("id").Value);

            var matches = search.SearchInternal("love time");

            Assert.That(matches.All(m => m.Value > 0));
            Assert.That(matches.First().Key, Is.EqualTo("3"));
        }
コード例 #6
0
        public void Index_Then_Export_ReturnsExpectedXml()
        {
            var search = new DocumentIndex();

            var docs = TestData.TestCorpus().Select(t => XDocument.Parse(t)).ToList().AsQueryable();

            search.IndexDocuments(docs, d => d.Root.Attribute("id").Value);

            var xml = search.ExportAsXml();

            Assert.That(xml.Root.Name.LocalName, Is.EqualTo("index"));
            Assert.That(xml.Root.Attribute("doc-count").Value, Is.EqualTo(docs.Count().ToString()));
            Assert.That(xml.Root.Elements().All(e => e.Name.LocalName == "term"));

            xml.WriteTo(XmlWriter.Create(Console.Out, new XmlWriterSettings() { Indent = true }));
        }
コード例 #7
0
        public void Export_Then_Import_RestoresState()
        {
            var index1 = new DocumentIndex();

            var docs = TestData.TestCorpus().Select(t => XDocument.Parse(t)).ToList().AsQueryable();

            index1.IndexDocuments(docs, d => d.Root.Attribute("id").Value);

            var xml = index1.ExportAsXml();

            var index2 = new DocumentIndex(index1.Tokeniser);

            index2.ImportXml(xml);

            var xml2 = index2.ExportAsXml();

            Assert.That(xml.ToString(), Is.EqualTo(xml2.ToString()));
        }
コード例 #8
0
        public void ShouldIncludeTextScore()
        {
            // Given

            const string selectExpression1 = "textScore()";
            const string selectExpression2 = "textScore(myTextScore)";

            Action <IDocumentProjectionBuilder> expectedSelectExpression1 = p => p.IncludeTextScore();
            Action <IDocumentProjectionBuilder> expectedSelectExpression2 = p => p.IncludeTextScore("myTextScore");

            var item = new DynamicWrapper
            {
                { "prop1", "Item1" },
                { "prop2", 12345 },
                { "date", DateTime.Today }
            };

            // When
            var selectActualExpression1 = ParseSelect(selectExpression1);
            var selectActualExpression2 = ParseSelect(selectExpression2);

            // Then

            var textIndex = new DocumentIndex {
                Key = new Dictionary <string, DocumentIndexKeyType> {
                    { "prop1", DocumentIndexKeyType.Text }
                }
            };
            var documentStorage = DocumentStorageTestHelpers.GetEmptyStorage(nameof(ShouldIncludeTextScore), textIndex);

            documentStorage.InsertOne(item);

            var expectedValue1 = documentStorage.FindText("Item1").Project(expectedSelectExpression1).FirstOrDefault();
            var actualValue1   = documentStorage.FindText("Item1").Project(selectActualExpression1).FirstOrDefault();

            AreEqualDynamicWrapper(expectedValue1, actualValue1);

            var expectedValue2 = documentStorage.FindText("Item1").Project(expectedSelectExpression2).FirstOrDefault();
            var actualValue2   = documentStorage.FindText("Item1").Project(selectActualExpression2).FirstOrDefault();

            AreEqualDynamicWrapper(expectedValue2, actualValue2);
        }
コード例 #9
0
        private Document CreateLuceneDocument(DocumentIndex documentIndex)
        {
            var doc = new Document
            {
                // Always store the content item id
                new StringField("ContentItemId", documentIndex.ContentItemId.ToString(), Field.Store.YES)
            };

            foreach (var entry in documentIndex.Entries)
            {
                var store = entry.Options.HasFlag(DocumentIndexOptions.Store)
                            ? Field.Store.YES
                            : Field.Store.NO;

                switch (entry.Type)
                {
                case DocumentIndex.Types.Boolean:
                    // Store "true"/"false" for booleans
                    doc.Add(new StringField(entry.Name, Convert.ToString(entry.Value).ToLowerInvariant(), store));
                    break;

                case DocumentIndex.Types.DateTime:
                    if (entry.Value != null)
                    {
                        if (entry.Value is DateTimeOffset)
                        {
                            doc.Add(new StringField(entry.Name, DateTools.DateToString(((DateTimeOffset)entry.Value).UtcDateTime, DateResolution.SECOND), store));
                        }
                        else
                        {
                            doc.Add(new StringField(entry.Name, DateTools.DateToString(((DateTime)entry.Value).ToUniversalTime(), DateResolution.SECOND), store));
                        }
                    }
                    else
                    {
                        doc.Add(new StringField(entry.Name, "NULL", store));
                    }
                    break;

                case DocumentIndex.Types.Integer:
                    if (entry.Value != null && Int64.TryParse(entry.Value.ToString(), out var value))
                    {
                        doc.Add(new Int64Field(entry.Name, value, store));
                    }
                    else
                    {
                        doc.Add(new StringField(entry.Name, "NULL", store));
                    }

                    break;

                case DocumentIndex.Types.Number:
                    if (entry.Value != null)
                    {
                        doc.Add(new DoubleField(entry.Name, Convert.ToDouble(entry.Value), store));
                    }
                    else
                    {
                        doc.Add(new StringField(entry.Name, "NULL", store));
                    }
                    break;

                case DocumentIndex.Types.Text:
                    if (entry.Value != null && !String.IsNullOrEmpty(Convert.ToString(entry.Value)))
                    {
                        if (entry.Options.HasFlag(DocumentIndexOptions.Analyze))
                        {
                            doc.Add(new TextField(entry.Name, Convert.ToString(entry.Value), store));
                        }
                        else
                        {
                            doc.Add(new StringField(entry.Name, Convert.ToString(entry.Value), store));
                        }
                    }
                    else
                    {
                        if (entry.Options.HasFlag(DocumentIndexOptions.Analyze))
                        {
                            doc.Add(new TextField(entry.Name, "NULL", store));
                        }
                        else
                        {
                            doc.Add(new StringField(entry.Name, "NULL", store));
                        }
                    }
                    break;

                case DocumentIndex.Types.GeoPoint:
                    var strategy = new RecursivePrefixTreeStrategy(_grid, entry.Name);
                    if (entry.Value != null && entry.Value is DocumentIndex.GeoPoint point)
                    {
                        var geoPoint = _ctx.MakePoint((double)point.Longitude, (double)point.Latitude);
                        foreach (var field in strategy.CreateIndexableFields(geoPoint))
                        {
                            doc.Add(field);
                        }

                        if (entry.Options.HasFlag(DocumentIndexOptions.Store))
                        {
                            doc.Add(new StoredField(strategy.FieldName, $"{point.Latitude},{point.Longitude}"));
                        }
                    }
                    else
                    {
                        doc.Add(new StringField(strategy.FieldName, "NULL", store));
                    }
                    break;
                }
            }

            return(doc);
        }
コード例 #10
0
        private void PopulateAlgoliaDocumentEntries(DocumentIndex documentIndex)
        {
            SetContentItemId(documentIndex.ContentItemId);
            foreach (var entry in documentIndex.Entries)
            {
                var store = entry.Options.HasFlag(DocumentIndexOptions.Store)
                            ? true
                            : false;

                if (entry.Value == null)
                {
                    continue;
                }

                switch (entry.Type)
                {
                case DocumentIndex.Types.Boolean:
                    // store "true"/"false" for booleans
                    //   doc.Add(new StringField(entry.Name, Convert.ToString(entry.Value).ToLowerInvariant(), store));
                    Document[entry.Name] = Convert.ToString(entry.Value).ToLowerInvariant();
                    break;

                case DocumentIndex.Types.DateTime:
                    if (entry.Value is DateTimeOffset)
                    {
                        // doc.Add(new StringField(entry.Name, DateTools.DateToString(((DateTimeOffset)entry.Value).UtcDateTime, DateTools.Resolution.SECOND), store));
                        Document[entry.Name] = DateTimeHelper.DateTimeToUnixTimestamp(((DateTimeOffset)entry.Value).UtcDateTime);
                    }
                    else
                    {
                        //   doc.Add(new StringField(entry.Name, DateTools.DateToString(((DateTime)entry.Value).ToUniversalTime(), DateTools.Resolution.SECOND), store));
                        Document[entry.Name] = DateTimeHelper.DateTimeToUnixTimestamp(((DateTime)entry.Value).ToUniversalTime());
                    }
                    break;

                case DocumentIndex.Types.Integer:
                    //   doc.Add(new Int32Field(entry.Name, Convert.ToInt32(entry.Value), store));
                    Document[entry.Name] = Convert.ToInt32(entry.Value);
                    break;

                case DocumentIndex.Types.Number:
                    // doc.Add(new DoubleField(entry.Name, Convert.ToDouble(entry.Value), store));
                    Document[entry.Name] = Convert.ToDouble(entry.Value);
                    break;

                case DocumentIndex.Types.Text:
                    if (entry.Options.HasFlag(DocumentIndexOptions.Analyze))
                    {
//
                        // doc.Add(new TextField(entry.Name, Convert.ToString(entry.Value), store));
                        Document[entry.Name] = Convert.ToString(entry.Value.ToString().RemoveTags(true));
                    }
                    else
                    {
                        //doc.Add(new StringField(entry.Name, Convert.ToString(entry.Value), store));
                        Document[entry.Name] = Convert.ToString(entry.Value.ToString().RemoveTags(true));
                    }
                    break;
                }
            }
        }
コード例 #11
0
        private Document CreateLuceneDocument(DocumentIndex documentIndex)
        {
            var doc = new Document
            {
                // Always store the content item id
                new StringField("ContentItemId", documentIndex.ContentItemId.ToString(), Field.Store.YES)
            };

            foreach (var entry in documentIndex.Entries)
            {
                var store = entry.Options.HasFlag(DocumentIndexOptions.Store)
                            ? Field.Store.YES
                            : Field.Store.NO;

                switch (entry.Type)
                {
                case DocumentIndex.Types.Boolean:
                    // store "true"/"false" for booleans
                    doc.Add(new StringField(entry.Name, Convert.ToString(entry.Value).ToLowerInvariant(), store));
                    break;

                case DocumentIndex.Types.DateTime:
                    if (entry.Value != null)
                    {
                        if (entry.Value is DateTimeOffset)
                        {
                            doc.Add(new StringField(entry.Name, DateTools.DateToString(((DateTimeOffset)entry.Value).UtcDateTime, DateTools.Resolution.SECOND), store));
                        }
                        else
                        {
                            doc.Add(new StringField(entry.Name, DateTools.DateToString(((DateTime)entry.Value).ToUniversalTime(), DateTools.Resolution.SECOND), store));
                        }
                    }
                    else
                    {
                        doc.Add(new StringField(entry.Name, "NULL", store));
                    }
                    break;

                case DocumentIndex.Types.Integer:
                    if (entry.Value != null)
                    {
                        doc.Add(new Int32Field(entry.Name, Convert.ToInt32(entry.Value), store));
                    }
                    else
                    {
                        doc.Add(new StringField(entry.Name, "NULL", store));
                    }

                    break;

                case DocumentIndex.Types.Number:
                    if (entry.Value != null)
                    {
                        doc.Add(new DoubleField(entry.Name, Convert.ToDouble(entry.Value), store));
                    }
                    else
                    {
                        doc.Add(new StringField(entry.Name, "NULL", store));
                    }
                    break;

                case DocumentIndex.Types.Text:
                    if (!String.IsNullOrEmpty(Convert.ToString(entry.Value)))
                    {
                        if (entry.Options.HasFlag(DocumentIndexOptions.Analyze))
                        {
                            doc.Add(new TextField(entry.Name, Convert.ToString(entry.Value), store));
                        }
                        else
                        {
                            doc.Add(new StringField(entry.Name, Convert.ToString(entry.Value), store));
                        }
                    }
                    else
                    {
                        doc.Add(new StringField(entry.Name, "NULL", store));
                    }
                    break;
                }
            }

            return(doc);
        }
コード例 #12
0
        public void ShouldFilterByText()
        {
            // Given

            const string searchSingleWordFilter                        = "text('coffee')";
            const string searchWithoutTermFilter                       = "text('coffee -shop')";
            const string searchWithLanguageFilter                      = "text('leche', 'es')";
            const string diacriticInsensitiveSearchFilter              = "text('сы́рники CAFÉS')";
            const string caseSensitiveSearchForTermFilter              = "text('Coffee', null, true)";
            const string caseSensitiveSearchForPhraseFilter            = "text('\"Café Con Leche\"', null, true)";
            const string caseSensitiveSearchWithNegatedTermFilter      = "text('Coffee -shop', null, true)";
            const string diacriticSensitiveSearchForTermFilter         = "text('CAFÉ', null, false, true)";
            const string diacriticSensitiveSearchWithNegatedTermFilter = "text('leches -cafés', null, false, true)";

            Func <IDocumentFilterBuilder, object> searchSingleWordExpectedFilter                        = f => f.Text("coffee");
            Func <IDocumentFilterBuilder, object> searchWithoutTermExpectedFilter                       = f => f.Text("coffee -shop");
            Func <IDocumentFilterBuilder, object> searchWithLanguageExpectedFilter                      = f => f.Text("leche", "es");
            Func <IDocumentFilterBuilder, object> diacriticInsensitiveSearchExpectedFilter              = f => f.Text("сы́рники CAFÉS");
            Func <IDocumentFilterBuilder, object> caseSensitiveSearchForTermExpectedFilter              = f => f.Text("Coffee", caseSensitive: true);
            Func <IDocumentFilterBuilder, object> caseSensitiveSearchForPhraseExpectedFilter            = f => f.Text("\"Café Con Leche\"", caseSensitive: true);
            Func <IDocumentFilterBuilder, object> caseSensitiveSearchWithNegatedTermExpectedFilter      = f => f.Text("Coffee -shop", caseSensitive: true);
            Func <IDocumentFilterBuilder, object> diacriticSensitiveSearchForTermExpectedFilter         = f => f.Text("CAFÉ", diacriticSensitive: true);
            Func <IDocumentFilterBuilder, object> diacriticSensitiveSearchWithNegatedTermExpectedFilter = f => f.Text("leches -cafés", diacriticSensitive: true);

            var items = new[]
            {
                new DynamicWrapper {
                    { "_id", 1 }, { "subject", "coffee" }, { "author", "xyz" }, { "views", 50 }
                },
                new DynamicWrapper {
                    { "_id", 2 }, { "subject", "Coffee Shopping" }, { "author", "efg" }, { "views", 5 }
                },
                new DynamicWrapper {
                    { "_id", 3 }, { "subject", "Baking a cake" }, { "author", "abc" }, { "views", 90 }
                },
                new DynamicWrapper {
                    { "_id", 4 }, { "subject", "baking" }, { "author", "xyz" }, { "views", 100 }
                },
                new DynamicWrapper {
                    { "_id", 5 }, { "subject", "Café Con Leche" }, { "author", "abc" }, { "views", 200 }
                },
                new DynamicWrapper {
                    { "_id", 6 }, { "subject", "Сырники" }, { "author", "jkl" }, { "views", 80 }
                },
                new DynamicWrapper {
                    { "_id", 7 }, { "subject", "coffee and cream" }, { "author", "efg" }, { "views", 10 }
                },
                new DynamicWrapper {
                    { "_id", 8 }, { "subject", "Cafe con Leche" }, { "author", "xyz" }, { "views", 10 }
                }
            };

            // When
            var searchSingleWordActualFilter                        = ParseFilter(searchSingleWordFilter);
            var searchWithoutTermActualFilter                       = ParseFilter(searchWithoutTermFilter);
            var searchWithLanguageActualFilter                      = ParseFilter(searchWithLanguageFilter);
            var diacriticInsensitiveSearchActualFilter              = ParseFilter(diacriticInsensitiveSearchFilter);
            var caseSensitiveSearchForTermActualFilter              = ParseFilter(caseSensitiveSearchForTermFilter);
            var caseSensitiveSearchForPhraseActualFilter            = ParseFilter(caseSensitiveSearchForPhraseFilter);
            var caseSensitiveSearchWithNegatedTermActualFilter      = ParseFilter(caseSensitiveSearchWithNegatedTermFilter);
            var diacriticSensitiveSearchForTermActualFilter         = ParseFilter(diacriticSensitiveSearchForTermFilter);
            var diacriticSensitiveSearchWithNegatedTermActualFilter = ParseFilter(diacriticSensitiveSearchWithNegatedTermFilter);

            // Then

            var textIndex = new DocumentIndex {
                Key = new Dictionary <string, DocumentIndexKeyType> {
                    { "subject", DocumentIndexKeyType.Text }
                }
            };
            var documentStorage = DocumentStorageTestHelpers.GetEmptyStorage(nameof(ShouldFilterByText), textIndex);

            documentStorage.InsertMany(items);

            AssertFilter(documentStorage, searchSingleWordExpectedFilter, searchSingleWordActualFilter);
            AssertFilter(documentStorage, searchWithoutTermExpectedFilter, searchWithoutTermActualFilter);
            AssertFilter(documentStorage, searchWithLanguageExpectedFilter, searchWithLanguageActualFilter);
            AssertFilter(documentStorage, diacriticInsensitiveSearchExpectedFilter, diacriticInsensitiveSearchActualFilter);
            AssertFilter(documentStorage, caseSensitiveSearchForTermExpectedFilter, caseSensitiveSearchForTermActualFilter);
            AssertFilter(documentStorage, caseSensitiveSearchForPhraseExpectedFilter, caseSensitiveSearchForPhraseActualFilter);
            AssertFilter(documentStorage, caseSensitiveSearchWithNegatedTermExpectedFilter, caseSensitiveSearchWithNegatedTermActualFilter);
            AssertFilter(documentStorage, diacriticSensitiveSearchForTermExpectedFilter, diacriticSensitiveSearchForTermActualFilter);
            AssertFilter(documentStorage, diacriticSensitiveSearchWithNegatedTermExpectedFilter, diacriticSensitiveSearchWithNegatedTermActualFilter);
        }
コード例 #13
0
        public void CreateVectorExtractor()
        {
            var index = new DocumentIndex();

            var docs = TestData.TestCorpus().Select(t => XDocument.Parse(t)).ToList().AsQueryable();

            int id = 0;

            var blocks = docs.SelectMany(d => new Corpus(index.Tokeniser.Tokenise(d.Root.Value)).Blocks.ToList()).ToList();

            var tdocs = blocks
                .Select(b => new TokenisedTextDocument((id++).ToString(), b))
                .ToList();

            index.IndexDocuments(tdocs);

            var ve = index.CreateVectorExtractor();

            var vect = ve.ExtractColumnVector(index.Tokeniser.Tokenise("love time fortune"));

            Console.WriteLine(vect);
        }
コード例 #14
0
        public void CreateVectorExtractor_LargeCorpus()
        {
            var index = new DocumentIndex();

            using (var corpusStream = GetResource("shakespeare.txt"))
            {
                var corpus = new Corpus(corpusStream.Tokenise());

                int id = 0;

                index.IndexDocuments(corpus.Blocks.Select(b => new TokenisedTextDocument((id++).ToString(), b)));
            }

            var ve = index.CreateVectorExtractor(1024);

            var vect = ve.ExtractColumnVector(index.Tokeniser.Tokenise("love time fortune"));

            Console.WriteLine(vect);
        }
コード例 #15
0
        private static async Task <IList <DocumentIndex> > GetCollectionIndexesAsync(IMongoCollection <BsonDocument> collection)
        {
            var result = new List <DocumentIndex>();

            using (var cursor = await collection.Indexes.ListAsync())
            {
                var indexes = await cursor.ToListAsync();

                foreach (var index in indexes)
                {
                    var indexName = TryGetValue(index, "name", v => v.AsString);

                    // Не рассматриваются системные индексы
                    if (!string.Equals(indexName, "_id_", StringComparison.OrdinalIgnoreCase))
                    {
                        var indexUnique = TryGetValue(index, "unique", v => v.AsBoolean);
                        var indexKey    = TryGetValue(index, "key", v => v.AsBsonDocument);

                        var indexMetadata = new DocumentIndex
                        {
                            Name   = indexName,
                            Unique = indexUnique,
                            Key    = new Dictionary <string, DocumentIndexKeyType>()
                        };

                        var knowKeyType = true;

                        if (indexKey != null)
                        {
                            foreach (var property in indexKey)
                            {
                                var keyType = property.Value;

                                if (keyType == 1)
                                {
                                    indexMetadata.Key[property.Name] = DocumentIndexKeyType.Asc;
                                }
                                else if (keyType == -1)
                                {
                                    indexMetadata.Key[property.Name] = DocumentIndexKeyType.Desc;
                                }
                                else if (keyType == "text")
                                {
                                    indexMetadata.Key[property.Name] = DocumentIndexKeyType.Text;
                                }
                                else
                                {
                                    // Не рассматриваются индексы с неизвестным типом индексации
                                    knowKeyType = false;
                                    break;
                                }
                            }
                        }

                        if (knowKeyType && indexMetadata.Key.Count > 0)
                        {
                            result.Add(indexMetadata);
                        }
                    }
                }
            }

            return(result);
        }
コード例 #16
0
        /// <summary>
        /// Создаёт объект PersonInfo из строки таблицы данных
        /// </summary>
        public PersonInfo(DataTable InTable, int Position)
        {
            Line = (Position + MTS_PDF_Window.Head + 1).ToString("D6");
            foreach (DataColumn Col in InTable.Columns)
            {
                switch (Col.Caption.ToLowerInvariant())
                {
                case "номер":
                    try
                    {
                        Number = InTable.Rows[Position].ItemArray[Col.Ordinal].ToString();
                        Number = Number.Replace("-", "").Replace("(", "").Replace(")", "");
                        Regex phone = new Regex(@"^((8|\+7)[\- ]?)?(\(?\d{3}\)?[\- ]?)?([\d\- ]{3})([\d\- ]{4,5})$");
                        Number = phone.Replace(Number, "$3$4$5");
                    }
                    catch (Exception e)
                    {
                        Number = "";
                        ToLog(InTable.TableName, Position, Col.Caption, e.Message);
                    }
                    break;

                case "icc":
                    try
                    {
                        string ICC_Str = InTable.Rows[Position].ItemArray[Col.Ordinal].ToString().
                                         Replace('-', ' ').Replace('_', ' ').Replace('=', ' ').Replace('+', ' ');
                        string[] ICC_Arr = ICC_Str.Split(' ');
                        ICC        = ICC_Arr[0];
                        ICC_Suffix = ICC_Arr[1];
                    }
                    catch (Exception e)
                    {
                        ICC        = "";
                        ICC_Suffix = "";
                        ToLog(InTable.TableName, Position, Col.Caption, e.Message);
                    }
                    break;

                case "фамилия":
                    try
                    {
                        Surname = InTable.Rows[Position].ItemArray[Col.Ordinal].ToString();
                    }
                    catch (Exception e)
                    {
                        Surname = "";
                        ToLog(InTable.TableName, Position, Col.Caption, e.Message);
                    }
                    break;

                case "имя":
                    try
                    {
                        Name = InTable.Rows[Position].ItemArray[Col.Ordinal].ToString();
                    }
                    catch (Exception e)
                    {
                        Name = "";
                        ToLog(InTable.TableName, Position, Col.Caption, e.Message);
                    }
                    break;

                case "отчество":
                    try
                    {
                        SecondName = InTable.Rows[Position].ItemArray[Col.Ordinal].ToString();
                    }
                    catch (Exception e)
                    {
                        SecondName = "";
                        ToLog(InTable.TableName, Position, Col.Caption, e.Message);
                    }
                    break;

                case "пол":
                    try
                    {
                        Sex = (InTable.Rows[Position].ItemArray[Col.Ordinal].ToString().ToLowerInvariant() == "м") ||
                              (InTable.Rows[Position].ItemArray[Col.Ordinal].ToString().ToLowerInvariant() == "m");
                    }
                    catch (Exception e)
                    {
                        Sex = false;
                        ToLog(InTable.TableName, Position, Col.Caption, e.Message);
                    }
                    break;

                case "место рождения":
                    try
                    {
                        BirthPlace = InTable.Rows[Position].ItemArray[Col.Ordinal].ToString();
                    }
                    catch (Exception e)
                    {
                        BirthPlace = "";
                        ToLog(InTable.TableName, Position, Col.Caption, e.Message);
                    }
                    break;

                case "гражданство":
                    try
                    {
                        Citizenship = InTable.Rows[Position].ItemArray[Col.Ordinal].ToString();
                    }
                    catch (Exception e)
                    {
                        Citizenship = "";
                        ToLog(InTable.TableName, Position, Col.Caption, e.Message);
                    }
                    break;

                case "документ удост личность":
                    try
                    {
                        Document = InTable.Rows[Position].ItemArray[Col.Ordinal].ToString();
                    }
                    catch (Exception e)
                    {
                        Document = "";
                        ToLog(InTable.TableName, Position, Col.Caption, e.Message);
                    }
                    break;

                case "серия":
                    try
                    {
                        DocumentSerie = InTable.Rows[Position].ItemArray[Col.Ordinal].ToString();
                    }
                    catch (Exception e)
                    {
                        DocumentSerie = "";
                        ToLog(InTable.TableName, Position, Col.Caption, e.Message);
                    }
                    break;

                case "номер документа":
                    try
                    {
                        DocumentNumber = InTable.Rows[Position].ItemArray[Col.Ordinal].ToString();
                    }
                    catch (Exception e)
                    {
                        DocumentNumber = "";
                        ToLog(InTable.TableName, Position, Col.Caption, e.Message);
                    }
                    break;

                case "кем выдан":
                    try
                    {
                        string Str = InTable.Rows[Position].ItemArray[Col.Ordinal].ToString();
                        if (Str.Length < 50)
                        {
                            DocumentIssuedBy[0] = Str;
                            DocumentIssuedBy[1] = "";
                        }
                        else
                        {
                            for (int i = 50; i > 0; i--)
                            {
                                if (Str[i] == ' ')
                                {
                                    DocumentIssuedBy[0] = Str.Remove(i);
                                    DocumentIssuedBy[1] = Str.Substring(i + 1);
                                    break;
                                }
                            }
                        }
                    }
                    catch (Exception e)
                    {
                        DocumentIssuedBy = new string[] { "", "" };
                        ToLog(InTable.TableName, Position, Col.Caption, e.Message);
                    }
                    break;

                case "дата выдачи":
                    try
                    {
                        DocumentIssueDate = DateTime.Parse(InTable.Rows[Position].ItemArray[Col.Ordinal].ToString());
                    }
                    catch (Exception e)
                    {
                        DocumentIssueDate = DateTime.Now;
                        ToLog(InTable.TableName, Position, Col.Caption, e.Message);
                    }
                    break;

                case "код подразделения":
                    try
                    {
                        DocumentIndex  = InTable.Rows[Position].ItemArray[Col.Ordinal].ToString();
                        DocumentIndex2 = DocumentIndex.IndexOf('-') == -1
                                ? new string[] { DocumentIndex, "" }
                                : DocumentIndex.Split('-');
                    }
                    catch (Exception e)
                    {
                        DocumentIndex  = "";
                        DocumentIndex2 = new string[] { "", "" };
                        ToLog(InTable.TableName, Position, Col.Caption, e.Message);
                    }
                    break;

                case "дата рождения":
                    try
                    {
                        Birth = DateTime.Parse(InTable.Rows[Position].ItemArray[Col.Ordinal].ToString());
                    }
                    catch (Exception e)
                    {
                        Birth = DateTime.Now;
                        ToLog(InTable.TableName, Position, Col.Caption, e.Message);
                    }
                    break;

                case "индекс":
                    try
                    {
                        PlaceIndex = InTable.Rows[Position].ItemArray[Col.Ordinal].ToString();
                    }
                    catch (Exception e)
                    {
                        PlaceIndex = "";
                        ToLog(InTable.TableName, Position, Col.Caption, e.Message);
                    }
                    break;

                case "город":
                    try
                    {
                        PlaceCity = InTable.Rows[Position].ItemArray[Col.Ordinal].ToString();
                    }
                    catch (Exception e)
                    {
                        PlaceCity = "";
                        ToLog(InTable.TableName, Position, Col.Caption, e.Message);
                    }
                    break;

                case "улица":
                    try
                    {
                        PlaceStreet = InTable.Rows[Position].ItemArray[Col.Ordinal].ToString();
                    }
                    catch (Exception e)
                    {
                        PlaceStreet = "";
                        ToLog(InTable.TableName, Position, Col.Caption, e.Message);
                    }
                    break;

                case "дом":
                    try
                    {
                        PlaceBuilding = InTable.Rows[Position].ItemArray[Col.Ordinal].ToString();
                    }
                    catch (Exception e)
                    {
                        PlaceBuilding = "";
                        ToLog(InTable.TableName, Position, Col.Caption, e.Message);
                    }
                    break;

                case "кв.":
                    try
                    {
                        PlaceFlat = InTable.Rows[Position].ItemArray[Col.Ordinal].ToString();
                    }
                    catch (Exception e)
                    {
                        PlaceFlat = "";
                        ToLog(InTable.TableName, Position, Col.Caption, e.Message);
                    }
                    break;

                case "тариф":
                    try
                    {
                        Rate = InTable.Rows[Position].ItemArray[Col.Ordinal].ToString();
                    }
                    catch (Exception e)
                    {
                        Rate = "";
                        ToLog(InTable.TableName, Position, Col.Caption, e.Message);
                    }
                    break;

                case "дата заключения догвора":
                    try
                    {
                        ContractConclusionDate = DateTime.Parse(InTable.Rows[Position].ItemArray[Col.Ordinal].ToString());
                    }
                    catch (Exception e)
                    {
                        ContractConclusionDate = DateTime.Now;
                        ToLog(InTable.TableName, Position, Col.Caption, e.Message);
                    }
                    break;

                case "место заключения":
                    try
                    {
                        ContractConclusionPlace = InTable.Rows[Position].ItemArray[Col.Ordinal].ToString();
                    }
                    catch (Exception e)
                    {
                        ContractConclusionPlace = "";
                        ToLog(InTable.TableName, Position, Col.Caption, e.Message);
                    }
                    break;

                case "продавец":
                    try
                    {
                        Seller = InTable.Rows[Position].ItemArray[Col.Ordinal].ToString();
                    }
                    catch (Exception e)
                    {
                        Seller = "";
                        ToLog(InTable.TableName, Position, Col.Caption, e.Message);
                    }
                    break;

                case "код торговой точки":
                    try
                    {
                        SellerID = InTable.Rows[Position].ItemArray[Col.Ordinal].ToString();
                    }
                    catch (Exception e)
                    {
                        SellerID = "";
                        ToLog(InTable.TableName, Position, Col.Caption, e.Message);
                    }
                    break;
                }
            }
        }