1

我一直在尝试将泛卡详细信息解析为适当的字段。但我无法正确解析。在这里,我使用正则表达式查找泛卡号和出生日期,结果完美。但我无法正确找到名字和姓氏,因为位置正在变化。

泛卡有两种:

1.) 泛卡一号包含名字、姓氏、泛卡号、出生日期。2.) Pan card second 包含 Name:用户名,father's Name:用户父亲姓名,pan 卡号和 dob

这是块三个不同的文本:

泛卡类型:2

  **Block detected text 1:**

  sira
  feminT
  INCOME TAX DEPARTMENT
  Hd FOR
  GOVT. OF INDIA
  earril then tea ard
  Permanent Account Number Card
  argi Name
  EJWPM0714E
  FARHAZ MALIK
  frat ast aral Father's Name
  SHAKEEL MALIK
  a aale/ Dete of Bi-th
  08/08/1996
  ner Signature
  19012018

  **Block detected Text 2:**

  BITeTE fATHTST
  HRA TROR
  Scale document up. DEPARTMENT
  INVUND
  GOVT. OF INDIA
  Arne ste
  RITA cRaT Fran Tis
  Permanent Account Number Card
  ILDCK6689J
  T / Name
  SANJANA
  furat nT FITH / Father's Name
  CHALAMESH
  : sanjans
  10042019
  Tre aft arita
  Date of Birth
  06/06/1996
  & FaT&R / Signature

泛卡类型1:

 **Block detected Text 1:** 

  vSTreTa T feTHIST
  INCOME TAX DEPARTMENT
 HIRA thR
 D MANIKANDAN
 GOVT. OF INDIA
 DURAISAMY
 16/07/1986
 Permanent Account Number
 BNZPM2501F
 D manliamolown
 Signature
 04082011

 **Block detected Text 2**

  Sirerabe famint
  FIRA TROR
  INCOME TAX DEPARTMENT
  GOVT, OF INDIA
  ANJANA KUMARI
  KRISHAN KEWAL MUNJAL
  12/08/1978
  Parmanuit Account Numbot
  ALMPK0554A
  19 o.
  Galat
  signature

这是查找名字和姓氏的代码: 这里行数组是块检测到的文本转换为数组。

   var lines: [String] = []
            detectedText.enumerateLines { textLine, _ in
                lines.append(textLine)
            }
            print(lines)

    for (key, value) in lines.enumerated() {
                print("i:::", value)
                if self.validatePANCardNumber(value) == true {

                    print("pan card:::", value)

                }
                if self.validateDOB(value) == true {
                    print("dob pan:::", value)
                }

                if value.contains("/ Name") {

                   print("Item \(key + 1):value: \(lines[key + 1])")
                   let f_name = lines[key + 1]
                   print("first Name::", f_name)

                }

                if value.contains("/ Father's Name") {

                    print("Item \(key + 1):value: \(lines[key + 1])")
                    let last_name = lines[key + 1]
                    print("last Name::", last_name)

                }


            }

如何在正确的字段中解析名字和姓氏?

非常感谢任何帮助。

4

0 回答 0