解决 如何在没有索引的情况下从JSON中的元素获取值?

Weyardwiz

成员
加入
10月23日,2020年
消息
23
编程经验
3-5
我有以下代码将JSON元素值和输出提取到CSV:

C#:
public static void Json_to_Csv(string jsonInputFile, string csvFile)
{
    using (var p = new ChoJSONReader(jsonInputFile).WithJSONPath("$..readResults")) // "readResults": [
    {
        using (var w = new ChoCSVWriter(csvFile).WithFirstLineHeader())
        {
            w.Write(p
                .Select(r1 =>
                {
                    var lines = (dynamic[])r1.lines;
                    return new
                    {
                        FileName = jsonInputFile,
                        Page = r1.page,
                        PracticeName = lines[2].text,
                        OwnerFullName = lines[4].text,
                        OwnerEmail = lines[6].text,
                    };
                }
        }
    }
}

CSV输出:

文件名,页面,练习名称,所有者全名,所有者电子邮件
file1.json,1,一些练习名,Bob Lee,[email protected]

目前,每个项目没有其他上下文信息来引用它们,因此唯一的方法是通过索引,例如索引。行[2]

这是现在的作品,但我可能有其他有额外字段的JSON文件,因此拉出的值将是错误的。

为了解决这种情况, 如何设置上下文,而不是索引行才能提取值?

我试过了
C#:
PracticeName = lines["Practice Name"].text

但我得到了 无法隐式将字符串转换为int error


file1.json示例:

JSON:
{
  "status": "succeeded",
  "createdDateTime": "2020-10-22T19:35:35Z",
  "lastUpdatedDateTime": "2020-10-22T19:35:36Z",
  "analyzeResult": {
    "version": "3.0.0",
    "readResults": [
      {
        "page": 1,
        "angle": 0,
        "width": 8.5,
        "height": 11,
        "unit": "inch",
        "lines": [        
          {
            "boundingBox": [
              0.5016,
              1.9141,
              2.5726,
              1.9141,
              2.5726,
              2.0741,
              0.5016,
              2.0741
            ],          
           "text": "Account Information",
            "words": [
              {
                "boundingBox": [
                  0.5016,
                  1.9345,
                  1.3399,
                  1.9345,
                  1.3399,
                  2.0741,
                  0.5016,
                  2.0741
                ],
                "text": "Account",
                "confidence": 1
              },
              {
                "boundingBox": [
                  1.3974,
                  1.9141,
                  2.5726,
                  1.9141,
                  2.5726,
                  2.0741,
                  1.3974,
                  2.0741
                ],
                "text": "Information",
                "confidence": 1
              }
            ]
          },
          {
            "boundingBox": [
              1.7716,
              2.4855,
              2.8793,
              2.4855,
              2.8793,
              2.6051,
              1.7716,
              2.6051
            ],
            "text": "Practice Name",
            "words": [
              {
                "boundingBox": [
                  1.7716,
                  2.4855,
                  2.3803,
                  2.4855,
                  2.3803,
                  2.6051,
                  1.7716,
                  2.6051
                ],
                "text": "Practice",
                "confidence": 1
              },
              {
                "boundingBox": [
                  2.4362,
                  2.4948,
                  2.8793,
                  2.4948,
                  2.8793,
                  2.6051,
                  2.4362,
                  2.6051
                ],
                "text": "Name",
                "confidence": 1
              }
            ]
          },
          {
            "boundingBox": [
              2.9993,
              2.5257,
              4.7148,
              2.5257,
              4.7148,
              2.714,
              2.9993,
              2.714
            ],
            "text": "Some Practice Name",
            "words": [
              {
                "boundingBox": [
                  3.0072,
                  2.5385,
                  3.6546,
                  2.5284,
                  3.6516,
                  2.7131,
                  3.0105,
                  2.712
                ],
                "text": "Some",
                "confidence": 0.984
              },
              {
                "boundingBox": [
                  3.6887,
                  2.5281,
                  4.2112,
                  2.5262,
                  4.2028,
                  2.7159,
                  3.6854,
                  2.7132
                ],
                "text": "Parctice",
                "confidence": 0.986
              },
              {
                "boundingBox": [
                  4.2453,
                  2.5263,
                  4.7223,
                  2.5297,
                  4.7091,
                  2.72,
                  4.2366,
                  2.7161
                ],
                "text": "Name",
                "confidence": 0.986
              }
            ]
          },
          {
            "boundingBox": [
              1.6116,
              2.9999,
              2.8816,
              2.9999,
              2.8816,
              3.1158,
              1.6116,
              3.1158
            ],
            "text": "Owner Full Name",
            "words": [
              {
                "boundingBox": [
                  1.6116,
                  3.0039,
                  2.1026,
                  3.0039,
                  2.1026,
                  3.1157,
                  1.6116,
                  3.1157
                ],
                "text": "Owner",
                "confidence": 1
              },
              {
                "boundingBox": [
                  2.1541,
                  2.9999,
                  2.3784,
                  2.9999,
                  2.3784,
                  3.1158,
                  2.1541,
                  3.1158
                ],
                "text": "Full",
                "confidence": 1
              },
              {
                "boundingBox": [
                  2.4384,
                  3.0052,
                  2.8816,
                  3.0052,
                  2.8816,
                  3.1155,
                  2.4384,
                  3.1155
                ],
                "text": "Name",
                "confidence": 1
              }
            ]
          },
          {
            "boundingBox": [
              2.9993,
              3.0242,
              3.6966,
              3.0242,
              3.6966,
              3.2125,
              2.9993,
              3.2014
            ],
            "text": "Bob Lee",
            "words": [
              {
                "boundingBox": [
                  3.0063,
                  3.0303,
                  3.3439,
                  3.0349,
                  3.3461,
                  3.2125,
                  3.007,
                  3.2081
                ],
                "text": "Bob",
                "confidence": 0.987
              },
              {
                "boundingBox": [
                  3.3788,
                  3.0349,
                  3.6931,
                  3.0326,
                  3.697,
                  3.2121,
                  3.3813,
                  3.2125
                ],
                "text": "Lee",
                "confidence": 0.983
              }
            ]
          },
          {
            "boundingBox": [
              1.945,
              3.5063,
              2.8748,
              3.5063,
              2.8748,
              3.6261,
              1.945,
              3.6261
            ],
            "text": "Owner Email",
            "words": [
              {
                "boundingBox": [
                  1.945,
                  3.5143,
                  2.4359,
                  3.5143,
                  2.4359,
                  3.6261,
                  1.945,
                  3.6261
                ],
                "text": "Owner",
                "confidence": 1
              },
              {
                "boundingBox": [
                  2.4874,
                  3.5063,
                  2.8748,
                  3.5063,
                  2.8748,
                  3.6259,
                  2.4874,
                  3.6259
                ],
                "text": "Email",
                "confidence": 1
              }
            ]
          },
          {
            "boundingBox": [
              3.0104,
              3.5005,
              4.6042,
              3.5005,
              4.6042,
              3.6888,
              3.0104,
              3.6777
            ],
            "text": "[email protected]",
            "words": [
              {
                "boundingBox": [
                  3.0212,
                  3.5047,
                  4.5837,
                  3.5039,
                  4.5769,
                  3.6886,
                  3.0129,
                  3.6787
                ],
                "text": "[email protected]",
                "confidence": 0.951
              }
            ]
          }
        ]
      }
    ]
  }
}
 
最后编辑了主持人:
Solution
以下输出对控制台的对:
C#:
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Newtonsoft.Json;

class RootObject
{
    [JsonProperty("analyzeResult")]
    public AnalyzeResult AnalyzeResult { get; set; }
}

class AnalyzeResult
{
    [JsonProperty("readResults")]
    public ReadResults[] ReadResults { get; set; }
}

class ReadResults
{
    [JsonProperty("lines")]
    public Line[] Lines { get; set; }
}

class Line
{
    [JsonProperty("text")]
    public string Text { get; set; }

    public override string ToString() => Text;
}

public static class IEnumerableExtensions
{
    public static IEnumerable<KeyValuePair<T, T>> Pairs<T>(this IEnumerable<T> items)
    {...

Weyardwiz

成员
加入
10月23日,2020年
消息
23
编程经验
3-5
这增加了我的建议,这增加了 @skydiver在第10篇文章中的代码。
这很棒!我刚刚测试了它,它像魅力一样工作!
夫妇问题:
  1. 如果我将ToDictionary更改为Tolookup,我会为值获得异常:序列不包含任何元素。当然,使用firstordfault()抑制例外,但无论如何,我都会使用空输出......我是否需要调整值中的某些东西,以便打印出来?
  2. Ive在图像上运行Azure Vision,其具有与PDF文件相同的格式,除了其JPEG文件。
API将服务器选择解释为"I" instead of "V"(我认为它会像i)一样解析方框的右边缘)

1604034524121.png.


所以由此产生的json
是这样的:

JSON:
{
  "status": "succeeded",
  "createdDateTime": "2020-10-22T19:35:35Z",
  "lastUpdatedDateTime": "2020-10-22T19:35:36Z",
  "analyzeResult": {
    "version": "3.0.0",
    "readResults": [
      {
        "page": 1,
        "angle": 0,
        "width": 8.5,
        "height": 11,
        "unit": "inch",
        "lines": [    
          {
            "boundingBox": [
              0.5016,
              1.9141,
              2.5726,
              1.9141,
              2.5726,
              2.0741,
              0.5016,
              2.0741
            ],      
           "text": "Account Information",
            "words": [
              {
                "boundingBox": [
                  0.5016,
                  1.9345,
                  1.3399,
                  1.9345,
                  1.3399,
                  2.0741,
                  0.5016,
                  2.0741
                ],
                "text": "Account",
                "confidence": 1
              },
              {
                "boundingBox": [
                  1.3974,
                  1.9141,
                  2.5726,
                  1.9141,
                  2.5726,
                  2.0741,
                  1.3974,
                  2.0741
                ],
                "text": "Information",
                "confidence": 1
              }
            ]
          },
          {
            "boundingBox": [
              1.7716,
              2.4855,
              2.8793,
              2.4855,
              2.8793,
              2.6051,
              1.7716,
              2.6051
            ],
            "text": "Practice Name",
            "words": [
              {
                "boundingBox": [
                  1.7716,
                  2.4855,
                  2.3803,
                  2.4855,
                  2.3803,
                  2.6051,
                  1.7716,
                  2.6051
                ],
                "text": "Practice",
                "confidence": 1
              },
              {
                "boundingBox": [
                  2.4362,
                  2.4948,
                  2.8793,
                  2.4948,
                  2.8793,
                  2.6051,
                  2.4362,
                  2.6051
                ],
                "text": "Name",
                "confidence": 1
              }
            ]
          },
          {
            "boundingBox": [
              2.9993,
              2.5257,
              4.7148,
              2.5257,
              4.7148,
              2.714,
              2.9993,
              2.714
            ],
            "text": "Some Practice Name",
            "words": [
              {
                "boundingBox": [
                  3.0072,
                  2.5385,
                  3.6546,
                  2.5284,
                  3.6516,
                  2.7131,
                  3.0105,
                  2.712
                ],
                "text": "Some",
                "confidence": 0.984
              },
              {
                "boundingBox": [
                  3.6887,
                  2.5281,
                  4.2112,
                  2.5262,
                  4.2028,
                  2.7159,
                  3.6854,
                  2.7132
                ],
                "text": "Practice",
                "confidence": 0.986
              },
              {
                "boundingBox": [
                  4.2453,
                  2.5263,
                  4.7223,
                  2.5297,
                  4.7091,
                  2.72,
                  4.2366,
                  2.7161
                ],
                "text": "Name",
                "confidence": 0.986
              }
            ]
          },
          {
            "boundingBox": [
              1.6116,
              2.9999,
              2.8816,
              2.9999,
              2.8816,
              3.1158,
              1.6116,
              3.1158
            ],
            "text": "Owner Full Name",
            "words": [
              {
                "boundingBox": [
                  1.6116,
                  3.0039,
                  2.1026,
                  3.0039,
                  2.1026,
                  3.1157,
                  1.6116,
                  3.1157
                ],
                "text": "Owner",
                "confidence": 1
              },
              {
                "boundingBox": [
                  2.1541,
                  2.9999,
                  2.3784,
                  2.9999,
                  2.3784,
                  3.1158,
                  2.1541,
                  3.1158
                ],
                "text": "Full",
                "confidence": 1
              },
              {
                "boundingBox": [
                  2.4384,
                  3.0052,
                  2.8816,
                  3.0052,
                  2.8816,
                  3.1155,
                  2.4384,
                  3.1155
                ],
                "text": "Name",
                "confidence": 1
              }
            ]
          },
          {
            "boundingBox": [
              2.9993,
              3.0242,
              3.6966,
              3.0242,
              3.6966,
              3.2125,
              2.9993,
              3.2014
            ],
            "text": "Bob Lee",
            "words": [
              {
                "boundingBox": [
                  3.0063,
                  3.0303,
                  3.3439,
                  3.0349,
                  3.3461,
                  3.2125,
                  3.007,
                  3.2081
                ],
                "text": "Bob",
                "confidence": 0.987
              },
              {
                "boundingBox": [
                  3.3788,
                  3.0349,
                  3.6931,
                  3.0326,
                  3.697,
                  3.2121,
                  3.3813,
                  3.2125
                ],
                "text": "Lee",
                "confidence": 0.983
              }
            ]
          },
          {
            "boundingBox": [
              1.945,
              3.5063,
              2.8748,
              3.5063,
              2.8748,
              3.6261,
              1.945,
              3.6261
            ],
            "text": "Owner Email",
            "words": [
              {
                "boundingBox": [
                  1.945,
                  3.5143,
                  2.4359,
                  3.5143,
                  2.4359,
                  3.6261,
                  1.945,
                  3.6261
                ],
                "text": "Owner",
                "confidence": 1
              },
              {
                "boundingBox": [
                  2.4874,
                  3.5063,
                  2.8748,
                  3.5063,
                  2.8748,
                  3.6259,
                  2.4874,
                  3.6259
                ],
                "text": "Email",
                "confidence": 1
              }
            ]
          },
          {
            "boundingBox": [
              3.0104,
              3.5005,
              4.6042,
              3.5005,
              4.6042,
              3.6888,
              3.0104,
              3.6777
            ],
            "text": "[email protected]",
            "words": [
              {
                "boundingBox": [
                  3.0212,
                  3.5047,
                  4.5837,
                  3.5039,
                  4.5769,
                  3.6886,
                  3.0129,
                  3.6787
                ],
                "text": "[email protected]",
                "confidence": 0.951
              }
            ]
          },
          {
            "boundingBox": [
              863,
              1690,
              1082,
              1692,
              1082,
              1729,
              863,
              1727
            ],
            "text": "Server Setup",
            "words": [
              {
                "boundingBox": [
                  866,
                  1691,
                  970,
                  1691,
                  970,
                  1729,
                  867,
                  1727
                ],
                "text": "Server",
                "confidence": 0.985
              },
              {
                "boundingBox": [
                  977,
                  1691,
                  1081,
                  1692,
                  1081,
                  1730,
                  977,
                  1729
                ],
                "text": "Setup",
                "confidence": 0.986
              }
            ]
          },
          {
            "boundingBox": [
              1203,
              1679,
              1361,
              1688,
              1358,
              1737,
              1201,
              1733
            ],
            "text": "Icloud",
            "words": [
              {
                "boundingBox": [
                  1235,
                  1680,
                  1358,
                  1685,
                  1355,
                  1738,
                  1233,
                  1734
                ],
                "text": "Icloud",
                "confidence": 0.641
              }
            ]
          },
          {
            "boundingBox": [
              1514,
              1703,
              1643,
              1700,
              1644,
              1734,
              1514,
              1735
            ],
            "text": "ocation",
            "words": [
              {
                "boundingBox": [
                  1516,
                  1705,
                  1643,
                  1700,
                  1643,
                  1735,
                  1515,
                  1735
                ],
                "text": "ocation",
                "confidence": 0.985
              }
            ]
          },
          {
            "boundingBox": [
              1808,
              1698,
              2140,
              1697,
              2141,
              1736,
              1808,
              1737
            ],
            "text": "中央(多地点)",
            "words": [
              {
                "boundingBox": [
                  1809,
                  1702,
                  1916,
                  1699,
                  1915,
                  1736,
                  1808,
                  1735
                ],
                "text": "Central",
                "confidence": 0.981
              },
              {
                "boundingBox": [
                  1923,
                  1699,
                  2140,
                  1698,
                  2138,
                  1737,
                  1922,
                  1736
                ],
                "text": "(multi-location)",
                "confidence": 0.889
              }
            ]
          },
          {
            "boundingBox": [
              0.6466,
              7.0788,
              2.8775,
              7.0788,
              2.8775,
              7.2388,
              0.6466,
              7.2388
            ],
            "text": "Number of Locations Enrolling",
            "words": [
              {
                "boundingBox": [
                  0.6466,
                  7.0832,
                  1.2496,
                  7.0832,
                  1.2496,
                  7.1991,
                  0.6466,
                  7.1991
                ],
                "text": "Number",
                "confidence": 1
              },
              {
                "boundingBox": [
                  1.2969,
                  7.0788,
                  1.4364,
                  7.0788,
                  1.4364,
                  7.1988,
                  1.2969,
                  7.1988
                ],
                "text": "of",
                "confidence": 1
              },
              {
                "boundingBox": [
                  1.4892,
                  7.0793,
                  2.2013,
                  7.0793,
                  2.2013,
                  7.1988,
                  1.4892,
                  7.1988
                ],
                "text": "Locations",
                "confidence": 1
              },
              {
                "boundingBox": [
                  2.2576,
                  7.0793,
                  2.8775,
                  7.0793,
                  2.8775,
                  7.2388,
                  2.2576,
                  7.2388
                ],
                "text": "Enrolling",
                "confidence": 1
              }
            ]
          },
          {
            "boundingBox": [
              3.4421,
              7.0342,
              3.6413,
              7.0453,
              3.6413,
              7.3001,
              3.4421,
              7.289
            ],
            "text": "1",
            "words": [
              {
                "boundingBox": [
                  3.4757,
                  7.0352,
                  3.6451,
                  7.0446,
                  3.631,
                  7.299,
                  3.4616,
                  7.2896
                ],
                "text": "1",
                "confidence": 0.987
              }
            ]
          },
          {
            "boundingBox": [
              4.1835,
              7.0896,
              7.8999,
              7.0896,
              7.8999,
              7.2158,
              4.1835,
              7.2158
            ],
            "text": "*If more than 1 location, add info on the locations form",
            "words": [
              {
                "boundingBox": [
                  4.1835,
                  7.0896,
                  4.3291,
                  7.0896,
                  4.3291,
                  7.1979,
                  4.1835,
                  7.1979
                ],
                "text": "*If",
                "confidence": 1
              },
              {
                "boundingBox": [
                  4.3611,
                  7.1193,
                  4.725,
                  7.1193,
                  4.725,
                  7.1988,
                  4.3611,
                  7.1988
                ],
                "text": "more",
                "confidence": 1
              },
              {
                "boundingBox": [
                  4.7701,
                  7.0936,
                  5.0809,
                  7.0936,
                  5.0809,
                  7.1988,
                  4.7701,
                  7.1988
                ],
                "text": "than",
                "confidence": 1
              },
              {
                "boundingBox": [
                  5.1307,
                  7.0985,
                  5.1613,
                  7.0985,
                  5.1613,
                  7.1979,
                  5.1307,
                  7.1979
                ],
                "text": "1",
                "confidence": 1
              },
              {
                "boundingBox": [
                  5.2006,
                  7.09,
                  5.7803,
                  7.09,
                  5.7803,
                  7.2158,
                  5.2006,
                  7.2158
                ],
                "text": "location,",
                "confidence": 1
              },
              {
                "boundingBox": [
                  5.8268,
                  7.0936,
                  6.102,
                  7.0936,
                  6.102,
                  7.1988,
                  5.8268,
                  7.1988
                ],
                "text": "add",
                "confidence": 1
              },
              {
                "boundingBox": [
                  6.1394,
                  7.0896,
                  6.3896,
                  7.0896,
                  6.3896,
                  7.1988,
                  6.1394,
                  7.1988
                ],
                "text": "info",
                "confidence": 1
              },
              {
                "boundingBox": [
                  6.435,
                  7.1193,
                  6.6005,
                  7.1193,
                  6.6005,
                  7.1988,
                  6.435,
                  7.1988
                ],
                "text": "on",
                "confidence": 1
              },
              {
                "boundingBox": [
                  6.6481,
                  7.0936,
                  6.865,
                  7.0936,
                  6.865,
                  7.1988,
                  6.6481,
                  7.1988
                ],
                "text": "the",
                "confidence": 1
              },
              {
                "boundingBox": [
                  6.9081,
                  7.09,
                  7.5365,
                  7.09,
                  7.5365,
                  7.1988,
                  6.9081,
                  7.1988
                ],
                "text": "locations",
                "confidence": 1
              },
              {
                "boundingBox": [
                  7.5783,
                  7.0896,
                  7.8999,
                  7.0896,
                  7.8999,
                  7.1988,
                  7.5783,
                  7.1988
                ],
                "text": "form",
                "confidence": 1
              }
            ]
          }
        ]
      }
    ]
  }
}

如何通过服务器选择进一步优化代码来处理像这样的EDGecase?

3.我将值打印到控制台,如控制台.Writeline(value1);
如何使用键使用键打印值
C#:
IEnumerable<KeyValuePair<T, T>> Pairs<T>(this IEnumerable<T> items)

我试过了:
C#:
dictionary.Select(i => $"{i.Key}: {i.Value.FirstOrDefault()}").ToList().ForEach(Console.WriteLine);
但是,我获得了如打印的帐户信息等字段,而服务器设置打印v for值(预期,因为某些键/值具有特殊考虑,例如从练习名称作为第一键或类似服务器设置开始打印。这为什么为每个键设置单个值?换句话说,我不能像上面尝试的代码一样动态?
 

约翰

C#论坛主持人
工作人员
加入
2011年4月23日
消息
1,152
地点
挪威
编程经验
10+
如果我将ToDictionary更改为Tolookup,我会为值获得异常:序列不包含任何元素。当然,使用firstordfault()抑制例外,但无论如何,我都会使用空输出......我是否需要调整值中的某些东西,以便打印出来?
Yes, remember a Lookup can have multiple value series for each key, so the 'value' of one key will be IEnumerable<IEnumerable<string>>.
C#:
var value1 = lookup["Practice Name"].First().First(); //first set, first value
 

约翰

C#论坛主持人
工作人员
加入
2011年4月23日
消息
1,152
地点
挪威
编程经验
10+
Ive在图像上运行Azure Vision,其具有与PDF文件相同的格式,除了其JPEG文件。
API将服务器选择解释为"I" instead of "V"(我认为它会像i)一样解析方框的右边缘)
从我所看到的图像中,OCR相当不可靠。
所以由此产生的json
是这样的:
"something like this", right :翻白眼: 坐标系不匹配,似乎您有来自不同数据文件的混合部分。
1,9141帐户信息
2,4855练习名称
2,5257一些练习名称
2,9999所有者全名
3,0242 Bob Lee.
3,5063所有者电子邮件
3,5005 [email protected]
1690服务器设置
1679 icloud.
1703 ocation.
1698中央(多地点)
7,0788注册的位置数量
7,0342 1
7,0896 *如果超过1个位置,请在位置表格添加信息
或者它可能只是它产生的字符串的一个例子?
 

跳伞运动员

工作人员
加入
2019年4月6日
消息
2,849
地点
切萨皮克,va.
编程经验
10+
API将服务器选择解释为"I" instead of "V"(我认为它会像i)一样解析方框的右边缘)
不,这是因为你的图像处于一定角度,因此复选标记现在实际上是垂直的,并且OCR将其视为“我”。 OCR不足以首先旋转整个图像,然后执行OCR过程。
 

Weyardwiz

成员
加入
10月23日,2020年
消息
23
编程经验
3-5
不,这是因为你的图像处于一定角度,因此复选标记现在实际上是垂直的,并且OCR将其视为“我”。 OCR不足以首先旋转整个图像,然后执行OCR过程。
哦,这是一个很好的解释,从来没有想过那样的方式。但即使是非标题的图像,我仍然有一个"I"cloud.
 

Weyardwiz

成员
加入
10月23日,2020年
消息
23
编程经验
3-5
从我所看到的图像中,OCR相当不可靠。

"something like this", right :翻白眼: 坐标系不匹配,似乎您有来自不同数据文件的混合部分。

或者它可能只是它产生的字符串的一个例子?
我的坏,你是对的,只是它产生的字符串的一个例子。

这是一个未倾斜的图像版本,并产生json:

1604073819198.png.


杰森:

JSON:
{
  "status": "succeeded",
  "createdDateTime": "2020-10-30T15:56:11Z",
  "lastUpdatedDateTime": "2020-10-30T15:56:12Z",
  "analyzeResult": {
    "version": "3.0.0",
    "readResults": [
      {
        "page": 1,
        "angle": 0.086,
        "width": 684,
        "height": 272,
        "unit": "pixel",
        "lines": [
          {
            "boundingBox": [
              7,
              6,
              196,
              5,
              196,
              24,
              7,
              25
            ],
            "text": "Account Information",
            "words": [
              {
                "boundingBox": [
                  10,
                  7,
                  83,
                  7,
                  81,
                  24,
                  7,
                  26
                ],
                "text": "Account",
                "confidence": 0.981
              },
              {
                "boundingBox": [
                  87,
                  7,
                  196,
                  6,
                  196,
                  24,
                  85,
                  24
                ],
                "text": "Information",
                "confidence": 0.939
              }
            ]
          },
          {
            "boundingBox": [
              120,
              56,
              223,
              57,
              223,
              70,
              120,
              70
            ],
            "text": "Practice Name",
            "words": [
              {
                "boundingBox": [
                  120,
                  57,
                  176,
                  57,
                  176,
                  70,
                  120,
                  71
                ],
                "text": "Practice",
                "confidence": 0.982
              },
              {
                "boundingBox": [
                  179,
                  57,
                  222,
                  57,
                  222,
                  71,
                  179,
                  70
                ],
                "text": "Name",
                "confidence": 0.985
              }
            ]
          },
          {
            "boundingBox": [
              236,
              62,
              390,
              62,
              390,
              77,
              236,
              77
            ],
            "text": "Some Practice Name",
            "words": [
              {
                "boundingBox": [
                  236,
                  62,
                  277,
                  62,
                  277,
                  78,
                  236,
                  78
                ],
                "text": "Some",
                "confidence": 0.987
              },
              {
                "boundingBox": [
                  280,
                  62,
                  340,
                  62,
                  341,
                  78,
                  280,
                  77
                ],
                "text": "Practice",
                "confidence": 0.984
              },
              {
                "boundingBox": [
                  343,
                  62,
                  390,
                  62,
                  390,
                  78,
                  344,
                  78
                ],
                "text": "Name",
                "confidence": 0.987
              }
            ]
          },
          {
            "boundingBox": [
              107,
              102,
              223,
              102,
              223,
              115,
              107,
              115
            ],
            "text": "Owner Full Name",
            "words": [
              {
                "boundingBox": [
                  108,
                  103,
                  151,
                  102,
                  151,
                  116,
                  107,
                  116
                ],
                "text": "Owner",
                "confidence": 0.985
              },
              {
                "boundingBox": [
                  154,
                  102,
                  177,
                  102,
                  176,
                  116,
                  153,
                  116
                ],
                "text": "Full",
                "confidence": 0.954
              },
              {
                "boundingBox": [
                  180,
                  102,
                  224,
                  103,
                  223,
                  116,
                  179,
                  116
                ],
                "text": "Name",
                "confidence": 0.987
              }
            ]
          },
          {
            "boundingBox": [
              237,
              104,
              298,
              104,
              298,
              119,
              237,
              119
            ],
            "text": "Bob Lee",
            "words": [
              {
                "boundingBox": [
                  238,
                  104,
                  266,
                  104,
                  266,
                  119,
                  238,
                  120
                ],
                "text": "Bob",
                "confidence": 0.987
              },
              {
                "boundingBox": [
                  269,
                  104,
                  298,
                  105,
                  298,
                  120,
                  269,
                  119
                ],
                "text": "Lee",
                "confidence": 0.987
              }
            ]
          },
          {
            "boundingBox": [
              136,
              147,
              223,
              147,
              223,
              160,
              137,
              161
            ],
            "text": "Owner Email",
            "words": [
              {
                "boundingBox": [
                  137,
                  148,
                  181,
                  147,
                  181,
                  161,
                  137,
                  162
                ],
                "text": "Owner",
                "confidence": 0.985
              },
              {
                "boundingBox": [
                  184,
                  147,
                  224,
                  147,
                  224,
                  161,
                  184,
                  161
                ],
                "text": "Email",
                "confidence": 0.985
              }
            ]
          },
          {
            "boundingBox": [
              239,
              144,
              361,
              144,
              361,
              162,
              239,
              162
            ],
            "text": "[email protected]",
            "words": [
              {
                "boundingBox": [
                  240,
                  145,
                  362,
                  146,
                  361,
                  163,
                  240,
                  163
                ],
                "text": "[email protected]",
                "confidence": 0.974
              }
            ]
          },
          {
            "boundingBox": [
              137,
              193,
              224,
              193,
              224,
              208,
              137,
              208
            ],
            "text": "Server Setup",
            "words": [
              {
                "boundingBox": [
                  137,
                  194,
                  179,
                  194,
                  179,
                  208,
                  137,
                  208
                ],
                "text": "Server",
                "confidence": 0.985
              },
              {
                "boundingBox": [
                  182,
                  194,
                  224,
                  194,
                  224,
                  209,
                  182,
                  208
                ],
                "text": "Setup",
                "confidence": 0.985
              }
            ]
          },
          {
            "boundingBox": [
              276,
              188,
              340,
              192,
              339,
              211,
              275,
              209
            ],
            "text": "Icloud",
            "words": [
              {
                "boundingBox": [
                  297,
                  192,
                  339,
                  194,
                  339,
                  211,
                  297,
                  211
                ],
                "text": "Icloud",
                "confidence": 0.933
              }
            ]
          },
          {
            "boundingBox": [
              376,
              187,
              461,
              191,
              460,
              212,
              376,
              211
            ],
            "text": "Location",
            "words": [
              {
                "boundingBox": [
                  394,
                  191,
                  460,
                  196,
                  459,
                  211,
                  394,
                  211
                ],
                "text": "Location",
                "confidence": 0.844
              }
            ]
          },
          {
            "boundingBox": [
              500,
              189,
              666,
              192,
              665,
              212,
              499,
              211
            ],
            "text": "LIcentral (multi-location)",
            "words": [
              {
                "boundingBox": [
                  501,
                  190,
                  567,
                  195,
                  567,
                  212,
                  500,
                  212
                ],
                "text": "LIcentral",
                "confidence": 0.665
              },
              {
                "boundingBox": [
                  572,
                  195,
                  665,
                  195,
                  665,
                  212,
                  571,
                  212
                ],
                "text": "(multi-location)",
                "confidence": 0.899
              }
            ]
          },
          {
            "boundingBox": [
              21,
              238,
              224,
              238,
              223,
              255,
              21,
              253
            ],
            "text": "Number of Locations Enrolling",
            "words": [
              {
                "boundingBox": [
                  21,
                  239,
                  76,
                  239,
                  76,
                  253,
                  21,
                  253
                ],
                "text": "Number",
                "confidence": 0.985
              },
              {
                "boundingBox": [
                  79,
                  239,
                  92,
                  239,
                  92,
                  253,
                  79,
                  253
                ],
                "text": "of",
                "confidence": 0.983
              },
              {
                "boundingBox": [
                  95,
                  239,
                  161,
                  239,
                  161,
                  254,
                  95,
                  253
                ],
                "text": "Locations",
                "confidence": 0.981
              },
              {
                "boundingBox": [
                  164,
                  239,
                  224,
                  239,
                  223,
                  256,
                  163,
                  254
                ],
                "text": "Enrolling",
                "confidence": 0.983
              }
            ]
          },
          {
            "boundingBox": [
              273,
              237,
              289,
              239,
              288,
              257,
              272,
              255
            ],
            "text": "1",
            "words": [
              {
                "boundingBox": [
                  278,
                  237,
                  290,
                  239,
                  287,
                  257,
                  276,
                  255
                ],
                "text": "1",
                "confidence": 0.981
              }
            ]
          },
          {
            "boundingBox": [
              337,
              239,
              670,
              239,
              670,
              253,
              337,
              252
            ],
            "text": "*If more than 1 location, add info on the locations form",
            "words": [
              {
                "boundingBox": [
                  338,
                  239,
                  347,
                  239,
                  347,
                  252,
                  338,
                  252
                ],
                "text": "*If",
                "confidence": 0.874
              },
              {
                "boundingBox": [
                  350,
                  239,
                  384,
                  239,
                  384,
                  253,
                  350,
                  252
                ],
                "text": "more",
                "confidence": 0.983
              },
              {
                "boundingBox": [
                  386,
                  239,
                  416,
                  239,
                  416,
                  253,
                  386,
                  253
                ],
                "text": "than",
                "confidence": 0.986
              },
              {
                "boundingBox": [
                  419,
                  239,
                  422,
                  239,
                  422,
                  253,
                  419,
                  253
                ],
                "text": "1",
                "confidence": 0.635
              },
              {
                "boundingBox": [
                  425,
                  239,
                  478,
                  239,
                  478,
                  253,
                  425,
                  253
                ],
                "text": "location,",
                "confidence": 0.955
              },
              {
                "boundingBox": [
                  481,
                  239,
                  506,
                  239,
                  506,
                  253,
                  481,
                  253
                ],
                "text": "add",
                "confidence": 0.986
              },
              {
                "boundingBox": [
                  509,
                  239,
                  533,
                  239,
                  533,
                  253,
                  509,
                  253
                ],
                "text": "info",
                "confidence": 0.981
              },
              {
                "boundingBox": [
                  535,
                  239,
                  551,
                  239,
                  552,
                  253,
                  535,
                  253
                ],
                "text": "on",
                "confidence": 0.988
              },
              {
                "boundingBox": [
                  554,
                  239,
                  574,
                  239,
                  575,
                  253,
                  554,
                  253
                ],
                "text": "the",
                "confidence": 0.987
              },
              {
                "boundingBox": [
                  577,
                  239,
                  634,
                  239,
                  634,
                  253,
                  577,
                  253
                ],
                "text": "locations",
                "confidence": 0.973
              },
              {
                "boundingBox": [
                  636,
                  239,
                  666,
                  240,
                  666,
                  253,
                  637,
                  253
                ],
                "text": "form",
                "confidence": 0.986
              }
            ]
          }
        ]
      }
    ]
  }
}
 

跳伞运动员

工作人员
加入
2019年4月6日
消息
2,849
地点
切萨皮克,va.
编程经验
10+
这是可能的。看看它是如何变成的"LICentral"对于最后一个复选框。
 

跳伞运动员

工作人员
加入
2019年4月6日
消息
2,849
地点
切萨皮克,va.
编程经验
10+
:)

OCR. ==光学 特点 Recognition

图像识别是AI略微不同的分支。
 

Weyardwiz

成员
加入
10月23日,2020年
消息
23
编程经验
3-5
:)

OCR. ==光学 特点 Recognition

图像识别是AI略微不同的分支。
嗯,嗯,据 Azure Computer Vision REST API , the doc says:
提取印刷和手写 图片 使用新的 OCR. 技术可用作计算机Vision的一部分3.1 REST API。与新的 获得读取结果 方法, 您可以检测图像中的文本和extract recognized characters into a machine-readable character stream.
这就是为什么我一直将其称为OCR"Azure Computer Vision读取API"是一个很长的描述lol
 

跳伞运动员

工作人员
加入
2019年4月6日
消息
2,849
地点
切萨皮克,va.
编程经验
10+
是的,但您正在调用读取的方法,该方法是识别文本,而不是图像。
 

Weyardwiz

成员
加入
10月23日,2020年
消息
23
编程经验
3-5
也许尝试将线条分组在边界箱中的第二个数字,似乎是y坐标,需要+ -0.12的近距离比较,看看 LINQ(或伪代码)通过邻近分组项目
然后,您可以处理每个组,其中第一个文本将是标签和第二个值。这"Server Setup"线需要特殊的治疗,了解哪个文本"V" selection.
嘿约翰
如果你不介意,你能解释你如何达到+/- 0.12的门槛?
在伪代码页面上,它容易确定海报试图组5,但是在这里使用线路分组,我认为它可能是从一个标签到另一个标签的坐标之间的区别,但它不会出现在0.12。
 

约翰

C#论坛主持人
工作人员
加入
2011年4月23日
消息
1,152
地点
挪威
编程经验
10+
Hey John
如果你不介意,你能解释你如何达到+/- 0.12的门槛?
在伪代码页面上,它容易确定海报试图组5,但是在这里使用线路分组,我认为它可能是从一个标签到另一个标签的坐标之间的区别,但它不会出现在0.12。
看看"Y"有关指示的值和文本需要分组,以及与组中的第一项和其他人的最大差异。我实际上错误地估计了最大的差异 之内 该组(0.112),而不是比较算法所做的第一项(0.0743)。以下是值,查看服务器设置组:
1,9141帐户信息

2,4855练习名称
2,5257一些练习名称

2,9999所有者全名
3,0242 Bob Lee.

3,5063所有者电子邮件
3,5005 [email protected]

6,5768服务器设置
6,5025 V.
6,6145云
6,6105地点
6,6037中央(多地点)

7,0788注册的位置数量
7,0342 1
7,0896 *如果超过1个位置,请在位置表格添加信息
 

Weyardwiz

成员
加入
10月23日,2020年
消息
23
编程经验
3-5
Just look at the "Y"有关指示的值和文本需要分组,以及与组中的第一项和其他人的最大差异。我实际上错误地估计了最大的差异 之内 该组(0.112),而不是比较算法所做的第一项(0.0743)。以下是值,查看服务器设置组:
哦,我看到了!具有标签的第一项的差异,例如, 6.5768(服务器设置)-6.5025(v)= 0.0743
群体中的最大差异是第1项项目,例如, 6.6145(云) - 6.5025(v)= 0.112

顺便说一句,查找而不是Todictionary给了我问题......

C#:
var lookup = groups.ToLookup(g => g.First().Text, g => g.Skip(1).Select(line => line.Text));
var serverSetup = lookup["Server Setup"].SkipWhile(s => s.ToString().ToUpper() != "V").Skip(1).First().First();

我正进入(状态"序列不包含任何元素"错误,对于我解析的所有文件。如果我将其更改为Todictionary,我就可以解析大多数文件,只需尝试将更多的文件(具有重复)解析为无法解析的更好的文件,但它看起来更好地解析为Todictionary,但它看起来不像它不起作用对于任何文件,甚至没有重复的文件......
为您的参考,我能够通过这个JSON(以及我最初发布的那个)来重现这个错误)
JSON:
{
  "status": "succeeded",
  "createdDateTime": "2020-10-22T19:35:35Z",
  "lastUpdatedDateTime": "2020-10-22T19:35:36Z",
  "analyzeResult": {
    "version": "3.0.0",
    "readResults": [
      {
        "page": 1,
        "angle": 0,
        "width": 8.5,
        "height": 11,
        "unit": "inch",
        "lines": [       
          {
            "boundingBox": [
              0.5016,
              1.9141,
              2.5726,
              1.9141,
              2.5726,
              2.0741,
              0.5016,
              2.0741
            ],         
           "text": "Account Information",
            "words": [
              {
                "boundingBox": [
                  0.5016,
                  1.9345,
                  1.3399,
                  1.9345,
                  1.3399,
                  2.0741,
                  0.5016,
                  2.0741
                ],
                "text": "Account",
                "confidence": 1
              },
              {
                "boundingBox": [
                  1.3974,
                  1.9141,
                  2.5726,
                  1.9141,
                  2.5726,
                  2.0741,
                  1.3974,
                  2.0741
                ],
                "text": "Information",
                "confidence": 1
              }
            ]
          },
          {
            "boundingBox": [
              1.7716,
              2.4855,
              2.8793,
              2.4855,
              2.8793,
              2.6051,
              1.7716,
              2.6051
            ],
            "text": "Practice Name",
            "words": [
              {
                "boundingBox": [
                  1.7716,
                  2.4855,
                  2.3803,
                  2.4855,
                  2.3803,
                  2.6051,
                  1.7716,
                  2.6051
                ],
                "text": "Practice",
                "confidence": 1
              },
              {
                "boundingBox": [
                  2.4362,
                  2.4948,
                  2.8793,
                  2.4948,
                  2.8793,
                  2.6051,
                  2.4362,
                  2.6051
                ],
                "text": "Name",
                "confidence": 1
              }
            ]
          },
          {
            "boundingBox": [
              2.9993,
              2.5257,
              4.7148,
              2.5257,
              4.7148,
              2.714,
              2.9993,
              2.714
            ],
            "text": "Some Practice Name",
            "words": [
              {
                "boundingBox": [
                  3.0072,
                  2.5385,
                  3.6546,
                  2.5284,
                  3.6516,
                  2.7131,
                  3.0105,
                  2.712
                ],
                "text": "Some",
                "confidence": 0.984
              },
              {
                "boundingBox": [
                  3.6887,
                  2.5281,
                  4.2112,
                  2.5262,
                  4.2028,
                  2.7159,
                  3.6854,
                  2.7132
                ],
                "text": "Practice",
                "confidence": 0.986
              },
              {
                "boundingBox": [
                  4.2453,
                  2.5263,
                  4.7223,
                  2.5297,
                  4.7091,
                  2.72,
                  4.2366,
                  2.7161
                ],
                "text": "Name",
                "confidence": 0.986
              }
            ]
          },
          {
            "boundingBox": [
              1.6116,
              2.9999,
              2.8816,
              2.9999,
              2.8816,
              3.1158,
              1.6116,
              3.1158
            ],
            "text": "Owner Full Name",
            "words": [
              {
                "boundingBox": [
                  1.6116,
                  3.0039,
                  2.1026,
                  3.0039,
                  2.1026,
                  3.1157,
                  1.6116,
                  3.1157
                ],
                "text": "Owner",
                "confidence": 1
              },
              {
                "boundingBox": [
                  2.1541,
                  2.9999,
                  2.3784,
                  2.9999,
                  2.3784,
                  3.1158,
                  2.1541,
                  3.1158
                ],
                "text": "Full",
                "confidence": 1
              },
              {
                "boundingBox": [
                  2.4384,
                  3.0052,
                  2.8816,
                  3.0052,
                  2.8816,
                  3.1155,
                  2.4384,
                  3.1155
                ],
                "text": "Name",
                "confidence": 1
              }
            ]
          },
          {
            "boundingBox": [
              2.9993,
              3.0242,
              3.6966,
              3.0242,
              3.6966,
              3.2125,
              2.9993,
              3.2014
            ],
            "text": "Bob Lee",
            "words": [
              {
                "boundingBox": [
                  3.0063,
                  3.0303,
                  3.3439,
                  3.0349,
                  3.3461,
                  3.2125,
                  3.007,
                  3.2081
                ],
                "text": "Bob",
                "confidence": 0.987
              },
              {
                "boundingBox": [
                  3.3788,
                  3.0349,
                  3.6931,
                  3.0326,
                  3.697,
                  3.2121,
                  3.3813,
                  3.2125
                ],
                "text": "Lee",
                "confidence": 0.983
              }
            ]
          },
          {
            "boundingBox": [
              1.945,
              3.5063,
              2.8748,
              3.5063,
              2.8748,
              3.6261,
              1.945,
              3.6261
            ],
            "text": "Owner Email",
            "words": [
              {
                "boundingBox": [
                  1.945,
                  3.5143,
                  2.4359,
                  3.5143,
                  2.4359,
                  3.6261,
                  1.945,
                  3.6261
                ],
                "text": "Owner",
                "confidence": 1
              },
              {
                "boundingBox": [
                  2.4874,
                  3.5063,
                  2.8748,
                  3.5063,
                  2.8748,
                  3.6259,
                  2.4874,
                  3.6259
                ],
                "text": "Email",
                "confidence": 1
              }
            ]
          },
          {
            "boundingBox": [
              3.0104,
              3.5005,
              4.6042,
              3.5005,
              4.6042,
              3.6888,
              3.0104,
              3.6777
            ],
            "text": "[email protected]",
            "words": [
              {
                "boundingBox": [
                  3.0212,
                  3.5047,
                  4.5837,
                  3.5039,
                  4.5769,
                  3.6886,
                  3.0129,
                  3.6787
                ],
                "text": "[email protected]",
                "confidence": 0.951
              }
            ]
          },
          {
            "boundingBox": [
              1.945,
              6.5768,
              2.8886,
              6.5768,
              2.8886,
              6.7271,
              1.945,
              6.7271
            ],
            "text": "Server Setup",
            "words": [
              {
                "boundingBox": [
                  1.945,
                  6.5768,
                  2.4165,
                  6.5768,
                  2.4165,
                  6.6884,
                  1.945,
                  6.6884
                ],
                "text": "Server",
                "confidence": 1
              },
              {
                "boundingBox": [
                  2.4643,
                  6.5768,
                  2.8886,
                  6.5768,
                  2.8886,
                  6.7271,
                  2.4643,
                  6.7271
                ],
                "text": "Setup",
                "confidence": 1
              }
            ]
          },
          {
            "boundingBox": [
              3.5085,
              6.5025,
              3.7298,
              6.5136,
              3.7188,
              6.7351,
              3.4974,
              6.7241
            ],
            "text": "V",
            "words": [
              {
                "boundingBox": [
                  3.5672,
                  6.5046,
                  3.7293,
                  6.5128,
                  3.7183,
                  6.734,
                  3.5561,
                  6.7259
                ],
                "text": "V",
                "confidence": 0.984
              }
            ]
          },
          {
            "boundingBox": [
              3.7471,
              6.6145,
              4.1792,
              6.6145,
              4.1792,
              6.7304,
              3.7471,
              6.7304
            ],
            "text": "Cloud",
            "words": [
              {
                "boundingBox": [
                  3.7471,
                  6.6145,
                  4.1792,
                  6.6145,
                  4.1792,
                  6.7304,
                  3.7471,
                  6.7304
                ],
                "text": "Cloud",
                "confidence": 1
              }
            ]
          },
          {
            "boundingBox": [
              4.904,
              6.6105,
              5.5344,
              6.6105,
              5.5344,
              6.7301,
              4.904,
              6.7301
            ],
            "text": "Location",
            "words": [
              {
                "boundingBox": [
                  4.904,
                  6.6105,
                  5.5344,
                  6.6105,
                  5.5344,
                  6.7301,
                  4.904,
                  6.7301
                ],
                "text": "Location",
                "confidence": 1
              }
            ]
          },
          {
            "boundingBox": [
              6.2924,
              6.6037,
              7.8618,
              6.6037,
              7.8618,
              6.752,
              6.2924,
              6.752
            ],
            "text": "中央(多地点)",
            "words": [
              {
                "boundingBox": [
                  6.2924,
                  6.6145,
                  6.8385,
                  6.6145,
                  6.8385,
                  6.7301,
                  6.2924,
                  6.7301
                ],
                "text": "Central",
                "confidence": 1
              },
              {
                "boundingBox": [
                  6.8929,
                  6.6037,
                  7.8618,
                  6.6037,
                  7.8618,
                  6.752,
                  6.8929,
                  6.752
                ],
                "text": "(multi-location)",
                "confidence": 1
              }
            ]
          },
          {
            "boundingBox": [
              0.6466,
              7.0788,
              2.8775,
              7.0788,
              2.8775,
              7.2388,
              0.6466,
              7.2388
            ],
            "text": "Number of Locations Enrolling",
            "words": [
              {
                "boundingBox": [
                  0.6466,
                  7.0832,
                  1.2496,
                  7.0832,
                  1.2496,
                  7.1991,
                  0.6466,
                  7.1991
                ],
                "text": "Number",
                "confidence": 1
              },
              {
                "boundingBox": [
                  1.2969,
                  7.0788,
                  1.4364,
                  7.0788,
                  1.4364,
                  7.1988,
                  1.2969,
                  7.1988
                ],
                "text": "of",
                "confidence": 1
              },
              {
                "boundingBox": [
                  1.4892,
                  7.0793,
                  2.2013,
                  7.0793,
                  2.2013,
                  7.1988,
                  1.4892,
                  7.1988
                ],
                "text": "Locations",
                "confidence": 1
              },
              {
                "boundingBox": [
                  2.2576,
                  7.0793,
                  2.8775,
                  7.0793,
                  2.8775,
                  7.2388,
                  2.2576,
                  7.2388
                ],
                "text": "Enrolling",
                "confidence": 1
              }
            ]
          },
          {
            "boundingBox": [
              3.4421,
              7.0342,
              3.6413,
              7.0453,
              3.6413,
              7.3001,
              3.4421,
              7.289
            ],
            "text": "1",
            "words": [
              {
                "boundingBox": [
                  3.4757,
                  7.0352,
                  3.6451,
                  7.0446,
                  3.631,
                  7.299,
                  3.4616,
                  7.2896
                ],
                "text": "1",
                "confidence": 0.987
              }
            ]
          },
          {
            "boundingBox": [
              4.1835,
              7.0896,
              7.8999,
              7.0896,
              7.8999,
              7.2158,
              4.1835,
              7.2158
            ],
            "text": "*If more than 1 location, add info on the locations form",
            "words": [
              {
                "boundingBox": [
                  4.1835,
                  7.0896,
                  4.3291,
                  7.0896,
                  4.3291,
                  7.1979,
                  4.1835,
                  7.1979
                ],
                "text": "*If",
                "confidence": 1
              },
              {
                "boundingBox": [
                  4.3611,
                  7.1193,
                  4.725,
                  7.1193,
                  4.725,
                  7.1988,
                  4.3611,
                  7.1988
                ],
                "text": "more",
                "confidence": 1
              },
              {
                "boundingBox": [
                  4.7701,
                  7.0936,
                  5.0809,
                  7.0936,
                  5.0809,
                  7.1988,
                  4.7701,
                  7.1988
                ],
                "text": "than",
                "confidence": 1
              },
              {
                "boundingBox": [
                  5.1307,
                  7.0985,
                  5.1613,
                  7.0985,
                  5.1613,
                  7.1979,
                  5.1307,
                  7.1979
                ],
                "text": "1",
                "confidence": 1
              },
              {
                "boundingBox": [
                  5.2006,
                  7.09,
                  5.7803,
                  7.09,
                  5.7803,
                  7.2158,
                  5.2006,
                  7.2158
                ],
                "text": "location,",
                "confidence": 1
              },
              {
                "boundingBox": [
                  5.8268,
                  7.0936,
                  6.102,
                  7.0936,
                  6.102,
                  7.1988,
                  5.8268,
                  7.1988
                ],
                "text": "add",
                "confidence": 1
              },
              {
                "boundingBox": [
                  6.1394,
                  7.0896,
                  6.3896,
                  7.0896,
                  6.3896,
                  7.1988,
                  6.1394,
                  7.1988
                ],
                "text": "info",
                "confidence": 1
              },
              {
                "boundingBox": [
                  6.435,
                  7.1193,
                  6.6005,
                  7.1193,
                  6.6005,
                  7.1988,
                  6.435,
                  7.1988
                ],
                "text": "on",
                "confidence": 1
              },
              {
                "boundingBox": [
                  6.6481,
                  7.0936,
                  6.865,
                  7.0936,
                  6.865,
                  7.1988,
                  6.6481,
                  7.1988
                ],
                "text": "the",
                "confidence": 1
              },
              {
                "boundingBox": [
                  6.9081,
                  7.09,
                  7.5365,
                  7.09,
                  7.5365,
                  7.1988,
                  6.9081,
                  7.1988
                ],
                "text": "locations",
                "confidence": 1
              },
              {
                "boundingBox": [
                  7.5783,
                  7.0896,
                  7.8999,
                  7.0896,
                  7.8999,
                  7.1988,
                  7.5783,
                  7.1988
                ],
                "text": "form",
                "confidence": 1
              }
            ]
          }
        ]
      }
    ]
  }
}
 
Last edited:

约翰

C#论坛主持人
工作人员
加入
2011年4月23日
消息
1,152
地点
挪威
编程经验
10+
Look back to post 22. A lookup value is an IEnumerable<IEnumerable<string>>, not an IEnumerable<string>.
将令人愉快的纪念作为数组更熟悉,字典将返回字符串数组,而查找将返回字符串数组数组。
例如,你可以"某事:像|这" and "某事:像|那", so lookup["Something"]将包含两组:{"like", "this"} and {"like", "that"}.
即使只有一个项目(一个集合或字符串数​​组,如果您愿意)是一个键,所以查找返回的值将永远是"a set of sets".
 

Weyardwiz

成员
加入
10月23日,2020年
消息
23
编程经验
3-5
Look back to post 22. A lookup value is an IEnumerable<IEnumerable<string>>, not an IEnumerable<string>.
将令人愉快的纪念作为数组更熟悉,字典将返回字符串数组,而查找将返回字符串数组数组。
例如,你可以"某事:像|这" and "某事:像|那", so lookup["Something"]将包含两组:{"like", "this"} and {"like", "that"}.
即使只有一个项目(一个集合或字符串数​​组,如果您愿意)是一个键,所以查找返回的值将永远是"a set of sets".
说得通。所以根据文档 这里,我们通常循环通过像这样的集合(数组数组),或者通过LINQ ...

我以为从帖子22返回第1次返回的帖子以来,那么我们返回值(这将是另一个集),第3个第一个()应该执行诀窍来返回设置的1个值表单。

C#:
var serverSetup = lookup["Server Setup"].SkipWhile(s => s.ToString().ToUpper() != "V").Skip(1).First().First().First();

however, still received 序列不包含任何元素 error...I realized the 3rd First() is now a set/Enumerable of chars which is not right.

那么循环它是唯一的方法吗?
 

约翰

C#论坛主持人
工作人员
加入
2011年4月23日
消息
1,152
地点
挪威
编程经验
10+
抬头["Server Setup"].First is the first "set"...
 

Weyardwiz

成员
加入
10月23日,2020年
消息
23
编程经验
3-5
抬头["Server Setup"].First is the first "set"...
所以:
Server Setup
V

地点
中央(多地点)
收益率2套:
{{v,cloud} {location,central(multi-location)}}

然后
抬头["Server Setup"].First() 产量{v,cloud},在技术上是第2次()
C#:
抬头["Server Setup"].First().First()
产量V?
 

约翰

C#论坛主持人
工作人员
加入
2011年4月23日
消息
1,152
地点
挪威
编程经验
10+
不,这五个字符串都属于一个组,在文档中的一个可视行。"server setup"是标签/键,其他是该文档行的一组字符串。
 
最佳 底部