177 lines
5.7 KiB
Java
177 lines
5.7 KiB
Java
package com.kofax.mobile.sdk.w;
|
|
|
|
import bolts.CancellationToken;
|
|
import com.kofax.mobile.sdk.extract.id.DataField;
|
|
import java.util.ArrayList;
|
|
import java.util.Arrays;
|
|
import java.util.List;
|
|
import o.InterfaceC13391fZD;
|
|
import o.gjJ;
|
|
|
|
/* loaded from: classes3.dex */
|
|
public class z extends ae {
|
|
private static final double Qg = 80.0d;
|
|
private final a Qh;
|
|
private final com.kofax.mobile.sdk._internal.extraction.id.o Qi;
|
|
|
|
/* loaded from: classes3.dex */
|
|
public interface a {
|
|
|
|
/* renamed from: com.kofax.mobile.sdk.w.z$a$a, reason: collision with other inner class name */
|
|
/* loaded from: classes3.dex */
|
|
public static abstract class AbstractC0066a {
|
|
public abstract void e(DataField dataField);
|
|
|
|
public abstract void f(DataField dataField);
|
|
|
|
public abstract void g(DataField dataField);
|
|
|
|
public abstract DataField oL();
|
|
|
|
public abstract DataField oM();
|
|
|
|
public abstract DataField oN();
|
|
}
|
|
|
|
void a(com.kofax.mobile.sdk.e.a aVar, Exception exc);
|
|
|
|
boolean u(com.kofax.mobile.sdk.e.a aVar);
|
|
|
|
AbstractC0066a v(com.kofax.mobile.sdk.e.a aVar);
|
|
|
|
AbstractC0066a w(com.kofax.mobile.sdk.e.a aVar);
|
|
}
|
|
|
|
@Override // com.kofax.mobile.sdk.w.ae, com.kofax.mobile.sdk.e.c
|
|
public /* bridge */ /* synthetic */ void a(Object obj, CancellationToken cancellationToken) {
|
|
super.a(obj, cancellationToken);
|
|
}
|
|
|
|
@InterfaceC13391fZD
|
|
public z(a aVar, com.kofax.mobile.sdk._internal.extraction.id.o oVar) {
|
|
this.Qh = aVar;
|
|
this.Qi = oVar;
|
|
}
|
|
|
|
@Override // com.kofax.mobile.sdk.w.ae
|
|
public void a(com.kofax.mobile.sdk.e.a aVar) {
|
|
try {
|
|
if (p(aVar)) {
|
|
q(aVar);
|
|
}
|
|
e = null;
|
|
} catch (Exception e) {
|
|
e = e;
|
|
}
|
|
this.Qh.a(aVar, e);
|
|
}
|
|
|
|
private boolean p(com.kofax.mobile.sdk.e.a aVar) {
|
|
a.AbstractC0066a w = this.Qh.w(aVar);
|
|
return this.Qh.u(aVar) && !(w.oL() == null && w.oM() == null && w.oN() == null);
|
|
}
|
|
|
|
private void q(com.kofax.mobile.sdk.e.a aVar) {
|
|
if (r(aVar)) {
|
|
s(aVar);
|
|
} else {
|
|
t(aVar);
|
|
}
|
|
}
|
|
|
|
private boolean r(com.kofax.mobile.sdk.e.a aVar) {
|
|
a.AbstractC0066a v = this.Qh.v(aVar);
|
|
return (v.oL() == null && v.oM() == null && v.oN() == null) ? false : true;
|
|
}
|
|
|
|
private void s(com.kofax.mobile.sdk.e.a aVar) {
|
|
a.AbstractC0066a w = this.Qh.w(aVar);
|
|
DataField oL = w.oL();
|
|
DataField oM = w.oM();
|
|
DataField oN = w.oN();
|
|
a.AbstractC0066a v = this.Qh.v(aVar);
|
|
DataField oL2 = v.oL();
|
|
DataField oM2 = v.oM();
|
|
DataField oN2 = v.oN();
|
|
StringBuilder sb = new StringBuilder();
|
|
sb.append(oN2.getObject());
|
|
sb.append(" ");
|
|
sb.append(oL2.getObject());
|
|
sb.append(" ");
|
|
sb.append(oM2.getObject());
|
|
String obj = sb.toString();
|
|
StringBuilder sb2 = new StringBuilder();
|
|
sb2.append(oN.getObject());
|
|
sb2.append(" ");
|
|
sb2.append(oL.getObject());
|
|
sb2.append(" ");
|
|
sb2.append(oM.getObject());
|
|
String obj2 = sb2.toString();
|
|
if (F(obj, obj2)) {
|
|
ArrayList arrayList = new ArrayList(Arrays.asList(obj2.split(" ")));
|
|
DataField a2 = a(oN2, oN, arrayList);
|
|
DataField a3 = a(oL2, oL, arrayList);
|
|
DataField a4 = a(oM2, oM, arrayList);
|
|
v.e(a3);
|
|
v.f(a4);
|
|
v.g(a2);
|
|
w.e(a3);
|
|
w.f(a4);
|
|
w.g(a2);
|
|
}
|
|
}
|
|
|
|
private boolean F(String str, String str2) {
|
|
return G(str, str2) > Qg;
|
|
}
|
|
|
|
private double G(String str, String str2) {
|
|
double length = str.length();
|
|
return ((length - this.Qi.p(str, str2)) * 100.0d) / length;
|
|
}
|
|
|
|
private DataField a(DataField dataField, DataField dataField2, List<String> list) {
|
|
String object = dataField.getObject();
|
|
String str = "";
|
|
if (!gjJ.b((CharSequence) object)) {
|
|
for (int length = object.split(" ").length; length > 0; length--) {
|
|
String remove = list.remove(0);
|
|
StringBuilder sb = new StringBuilder();
|
|
sb.append(str);
|
|
sb.append(remove);
|
|
sb.append(" ");
|
|
str = sb.toString();
|
|
}
|
|
}
|
|
String trim = str.trim();
|
|
char[] charArray = object.toCharArray();
|
|
char[] charArray2 = trim.toCharArray();
|
|
if (charArray2.length < charArray.length) {
|
|
System.arraycopy(charArray2, 0, charArray, 0, trim.length());
|
|
trim = new String(charArray);
|
|
}
|
|
return new DataField(dataField.getName(), trim, dataField2.getConfidence(), dataField.getLocation());
|
|
}
|
|
|
|
private void t(com.kofax.mobile.sdk.e.a aVar) {
|
|
a.AbstractC0066a w = this.Qh.w(aVar);
|
|
DataField oL = w.oL();
|
|
DataField oM = w.oM();
|
|
DataField oN = w.oN();
|
|
StringBuilder sb = new StringBuilder();
|
|
sb.append(oN.getObject());
|
|
sb.append(" ");
|
|
sb.append(oL.getObject());
|
|
String obj = sb.toString();
|
|
String[] c = gjJ.c(oM.getObject(), " ");
|
|
String str = c.length > 0 ? c[0] : "";
|
|
String str2 = c.length > 1 ? c[1] : "";
|
|
DataField dataField = new DataField("FirstName", str, oL.getConfidence(), oL.getLocation());
|
|
DataField dataField2 = new DataField("LastName", obj, oN.getConfidence(), oN.getLocation());
|
|
DataField dataField3 = new DataField("MiddleName", str2, oM.getConfidence(), oM.getLocation());
|
|
w.e(dataField);
|
|
w.f(dataField3);
|
|
w.g(dataField2);
|
|
}
|
|
}
|