showing syntacticprops

master
Malar Kannan 2017-07-21 08:03:58 +05:30
parent 9d39bab8ca
commit 951015c543
6 changed files with 44 additions and 10539 deletions

1
.gitignore vendored
View File

@ -19,6 +19,7 @@
npm-debug.log*
yarn-debug.log*
yarn-error.log*
package-lock.json*
public/png
*.xml

4852
package-lock.json generated

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -48,7 +48,6 @@ function simpleAttrAccessor(attrPred: any) {
function listAttrAccessor(attrPred: any) {
let { attribKey, pred, lens } = attrPred;
// let def = (value: any) => ({ _: value, $: { [attribKey]: attribVal } });
return {
get: (li: any) => {
let def: any = [];
@ -57,86 +56,33 @@ function listAttrAccessor(attrPred: any) {
return pred(m);
});
let mEs = morphExps.map((me) => {
let value = _.get<any>(me, '_', '');
let value = _.get<any>(me, '_', me);
let key = _.get<any>(me, '$.' + attribKey, '');
return { value, key };
});
return mEs;
},
// set: (li: any, value: string) => {
// let lexItem = _.cloneDeep(li);
// let allProps = _.get<any>(lexItem, lens, []);
// if (allProps.length > 0) {
// let prop = _.filter<any>(allProps, (m) => {
// return pred(m);
// });
// _.set(prop, '[0]._', value);
// } else {
// _.set(lexItem, lens, def(value));
// }
// return lexItem;
// }
set: (li: any, value: any) => {
let lexItem = _.cloneDeep(li);
let allProps = _.get<any>(lexItem, lens, []);
if (allProps.length > 0) {
let prop = _.filter<any>(allProps, (m) => {
return pred(m);
});
_.set(prop, '[0]._', value);
} else {
_.set(lexItem, lens, value);
}
return lexItem;
}
};
}
// function attribListAccessor(lens: string, attrib: string, pred: any) {
// let def = (value: any) => ({ _: value, $: { form: attrib } });
// return {
// get: (li: any) => {
// // let def = [{ _: '', $: { form: attrib } }];
// let allProps = _.get<any>(li, lens, def(''));
// let prop = _.filter<any>(allProps, (m) => {
// return pred(m);
// });
// let mcls = _.get<any>(prop, '[0]._', '');
// return mcls;
// },
// set: (li: any, value: string) => {
// let lexItem = _.cloneDeep(li);
// let allProps = _.get<any>(lexItem, lens, []);
// if (allProps.length > 0) {
// let prop = _.filter<any>(allProps, (m) => {
// return pred(m);
// });
// if (prop.length > 0) {
// _.set(prop[0], '_', value);
// } else {
// allProps.push(def(value));
// }
// } else {
// _.set(lexItem, lens, def(value));
// }
// return lexItem;
// }
// };
// }
const attrPredGen = (lens: string, key: string, val: string, comp: any) => {
const pred = (m: any) => comp(_.get<any>(m, '$.' + key, ''), val);
return { lens, attribKey: key, attribVal: val, pred };
};
const mcParams = attrPredGen(
'lexprops[0].morphology[0].morph',
'form',
'morphclass',
_.isEqual
);
const meParams = attrPredGen(
'lexprops[0].morphology[0].morph',
'form',
'morphclass',
_.negate(_.isEqual)
);
const frParams = attrPredGen(
'syntacticprops[0].property',
'id',
'frame',
_.isEqual
);
const fieldMetaMap = {
label: {
type: 'text',
@ -150,35 +96,45 @@ const fieldMetaMap = {
relations: { type: 'text', ...simpleAccessor('relations[0]'), },
frame: {
type: 'select',
...simpleAttrAccessor(frParams),
...simpleAttrAccessor(attrPredGen(
'syntacticprops[0].property',
'id',
'frame',
_.isEqual
)),
},
morphclass: {
type: 'select',
...simpleAttrAccessor(mcParams)
...simpleAttrAccessor(attrPredGen(
'lexprops[0].morphology[0].morph',
'form',
'morphclass',
_.isEqual
))
},
morphexceptions: {
type: 'list',
...listAttrAccessor(meParams)
// get: (li: any) => {
// let lens = 'lexprops[0].morphology[0].morph';
// let def: any = [];
// let morphProps = _.get<any>(li, lens, def);
// let morphExps = _.filter<any>(morphProps, (m) => {
// return _.get<any>(m, '$.form', '') !== 'morphclass';
// });
// let mEs = morphExps.map((me) => {
// let value = _.get<any>(me, '_', '');
// let key = _.get<any>(me, '$.form', '');
// return { value, key };
// });
// return mEs;
// }
...listAttrAccessor(attrPredGen(
'lexprops[0].morphology[0].morph',
'form',
'morphclass',
_.negate(_.isEqual)
))
},
stats: { type: 'text', ...simpleAccessor('stats[0].property[0]._'), },
lang: {
type: 'select',
options: ['en', 'es'], ...simpleAccessor('$.id', 'en'),
},
syntacticprops: {
type: 'list',
...listAttrAccessor(attrPredGen(
'syntacticprops[0].property',
'id',
'frame',
_.negate(_.isEqual)
))
},
};
const xmlToEntries = (xmlData: any) => {

View File

@ -114,7 +114,7 @@ export function listInput(params: any) {
let { oldIndex, newIndex } = idxs;
arrayMove(value, oldIndex, newIndex);
};
console.log('value: ', value);
console.log('field: ', field, 'value: ', value);
return (
<LexSingleInput key={field} label={changedLabel(changed, field)}>
<SortableList

View File

@ -1,7 +1,7 @@
from flask import Flask,send_from_directory,request
app = Flask(__name__,static_url_path='',static_folder='build')
# from freespeech_walle.get_morph_rule import get_morph
from freespeech_walle.wizard_helpers import get_morph_rule,get_frequency
# from freespeech_walle.wizard_helpers import get_morph_rule,get_frequency
import json
# from flask_cors import CORS, cross_origin