Warning: session_start(): open(/var/lib/php/sessions/sess_v14629rsnkvn3qkdcarb46u92q, O_RDWR) failed: No space left on device (28) in /var/www/tb-usercake/models/config.php on line 51
Warning: session_start(): Failed to read session data: files (path: /var/lib/php/sessions) in /var/www/tb-usercake/models/config.php on line 51
sbool englishToConceptLanguage_xyz_debug;
sS englishToConceptLanguage_xyz(S s, O preprocess) {
assertNotNull("Input", s);
s = postProcess(preprocess, s);
// pattern matching all concepts against full string
new Matches m;
for (AIConcept c : englishToConceptLanguage_concepts()) {
if (empty(c.name)) {
print("Warning, empty name: " + c.globalID);
continue;
}
S name = postProcess(preprocess, c.name);
L tok = javaTokC(name);
if (tok.contains("*")) continue; // Don't want those, use X and Y here
int iX = tok.indexOf("X");
if (iX >= 0) {
int iY = tok.indexOf("Y");
if (iY >= 0) {
int iZ = tok.indexOf("Z");
if (iZ >= 0) {
// X and Y and Z
S pat = formatXYZ(name, "*", "*", "*");
bool b = flexMatchIC2(pat, s, m, false);
if (englishToConceptLanguage_xyz_debug)
print("xyz: " + pat + " - " + s + " => " + (b ? struct(m) : "-"));
if (b) {
assertEquals(name, 3, l(m.m));
new TreeMap map;
map.put(iX, englishToConceptLanguage_xyz_sub($1));
map.put(iY, englishToConceptLanguage_xyz_sub($2));
map.put(iZ, englishToConceptLanguage_xyz_sub($3));
ret c.globalID + " " + join(" ", values(map));
}
} else {
// X and Y
S pat = formatXYZ(name, "*", "*");
bool complicated = containsSubList(tok, "X", "Y");
if (complicated ? jmatch(pat, s, m) : flexMatchIC2(pat, s, m, false)) {
assertEquals(name, 2, l(m.m));
S a = englishToConceptLanguage_xyz_sub($1);
S b = englishToConceptLanguage_xyz_sub($2);
ret c.globalID + " " +
(iX < iY ? a + " " + b : b + " " + a);
}
}
} else {
// X only
S pat = formatXYZ(name, "*");
if (flexMatchIC2(pat, s, m, false)) {
assertEquals(name, 1, l(m.m));
S a = englishToConceptLanguage_xyz_sub($1);
ret c.globalID + " " + a;
}
}
}
}
// no full string match. go word by word
L tok = javaTok(s);
if (l(tok) <= 3) null;
for (int i = 1; i < l(tok); i += 2) {
S x = englishToConceptLanguage(unquote(tok.get(i)));
if (nempty(x)) tok.set(i, conceptQuote(x));
}
S x = join(tok);
ret eq(x, s) ? null : x;
}
sS englishToConceptLanguage_xyz_sub(S s) {
s = or2(englishToConceptLanguage(s), s);
if (englishToConceptLanguage_xyz_debug)
print("xyz_sub " + quote(s));
ret conceptQuote(s);
}