code wiki / (root) / nx_intelmine_propose.nx

nx_intelmine_propose.nx source

↩ module page · 113 lines · 6341 B

1// nx_intelmine_propose.nx -- ONE CALL from a mined title to the boards: the thin program over nx_intelmine_lib. 2// nx_intelmine_propose <appid> [language=english] [min_support=3] [top=15] [outdir=buildroot/knowledge/compare] 3// Runs the review rubric over knowledge/reviews/steam/<appid>.jrnl (the lexicons as data), reads the title's installed 4// census row (knowledge/reviews/installed/steam.census), routes every signal through knowledge/reviewmine/ 5// capability_map.conf and APPENDS deduped rows to <outdir>/<domain>.proposed. It never writes a board. The rows are the 6// answer to "what do they do well that we take, what is wrong that we do better, what do they ship" per board. 7// license_tier: ORIGINAL 8import "nx_syscalls.nx" 9import "nx_reviewmine_lib.nx" 10import "nx_intelmine_lib.nx" 11 12const PP_STOPWORDS: *u8 = "knowledge/reviewmine/stopwords.conf" 13const PP_LEX_DEFECT: *u8 = "knowledge/reviewmine/lexicon_defect.conf" 14const PP_LEX_FEATURE: *u8 = "knowledge/reviewmine/lexicon_feature.conf" 15const PP_LEX_EXCEED: *u8 = "knowledge/reviewmine/lexicon_exceed.conf" 16const PP_LEX_NOTMEET: *u8 = "knowledge/reviewmine/lexicon_notmeet.conf" 17const PP_LEX_VALUE: *u8 = "knowledge/reviewmine/lexicon_value.conf" 18const PP_LEX_DEMAND: *u8 = "knowledge/reviewmine/lexicon_demand.conf" 19const PP_MAP: *u8 = "knowledge/reviewmine/capability_map.conf" 20const PP_CENSUS: *u8 = "knowledge/reviews/installed/steam.census" 21const PP_REVIEWS: *u8 = "knowledge/reviews/steam/" 22const PP_OUTDIR: *u8 = "buildroot/knowledge/compare" 23const PP_DEFAULT_TOP: i64 = 15 24const PP_DEFAULT_MIN_SUPPORT: i64 = 3 25const PP_PATH_CAP: i64 = 512 26const PP_EXIT_USAGE: i64 = 2 // no or bad appid 27const PP_EXIT_NO_MAP: i64 = 3 // the capability map is absent or empty 28const PP_ARG_APPID: i64 = 1 // argv positions 29const PP_ARG_LANG: i64 = 2 30const PP_ARG_MIN_SUPPORT: i64 = 3 31const PP_ARG_TOP: i64 = 4 32const PP_ARG_OUTDIR: i64 = 5 33 34func main(argc: i64, argv: *i64) -> i64 { 35 if argc <= PP_ARG_APPID { 36 rm_w("usage: nx_intelmine_propose <appid> [language=english] [min_support=3] [top=15] [outdir=buildroot/knowledge/compare]\n" as *u8) 37 sys_exit(PP_EXIT_USAGE); return PP_EXIT_USAGE 38 } 39 let appid_s: *u8 = argv[PP_ARG_APPID] as *u8 40 let appid: i64 = rm_atoi(appid_s) 41 if appid <= 0 { rm_w("REFUSED appid must be a positive integer\n" as *u8); sys_exit(PP_EXIT_USAGE); return PP_EXIT_USAGE } 42 var lang: *u8 = "english" as *u8 43 var ms: i64 = PP_DEFAULT_MIN_SUPPORT 44 var top: i64 = PP_DEFAULT_TOP 45 var outdir: *u8 = PP_OUTDIR 46 if argc > PP_ARG_LANG { lang = argv[PP_ARG_LANG] as *u8 } 47 if argc > PP_ARG_MIN_SUPPORT { ms = rm_atoi(argv[PP_ARG_MIN_SUPPORT] as *u8); if ms <= 0 { ms = PP_DEFAULT_MIN_SUPPORT } } 48 if argc > PP_ARG_TOP { top = rm_atoi(argv[PP_ARG_TOP] as *u8); if top <= 0 { top = PP_DEFAULT_TOP } } 49 if argc > PP_ARG_OUTDIR { outdir = argv[PP_ARG_OUTDIR] as *u8 } 50 ip_init() 51 let maps: i64 = ip_map_load(PP_MAP) 52 if maps == 0 { rm_w("REFUSED capability map absent or empty at " as *u8); rm_w(PP_MAP); rm_w("\n" as *u8); sys_exit(PP_EXIT_NO_MAP); return PP_EXIT_NO_MAP } 53 let journal: *u8 = sys_mmap(PP_PATH_CAP) 54 var o: i64 = rm_cat(journal, 0, PP_REVIEWS) 55 o = rm_cat(journal, o, appid_s) 56 o = rm_cat(journal, o, ".jrnl" as *u8) 57 journal[o] = 0 as u8 58 rm_vocab_reset() 59 let sw: i64 = rm_stopwords_load(PP_STOPWORDS) 60 var lex: i64 = 0 61 lex = lex + rm_lexicon_load(PP_LEX_DEFECT, RM_LEX_DEFECT) 62 lex = lex + rm_lexicon_load(PP_LEX_FEATURE, RM_LEX_FEATURE) 63 lex = lex + rm_lexicon_load(PP_LEX_EXCEED, RM_LEX_EXCEED) 64 lex = lex + rm_lexicon_load(PP_LEX_NOTMEET, RM_LEX_NOTMEET) 65 lex = lex + rm_lexicon_load(PP_LEX_VALUE, RM_LEX_VALUE) 66 lex = lex + rm_lexicon_load(PP_LEX_DEMAND, RM_LEX_DEMAND) 67 let docs: i64 = rm_rubric(journal, lang) 68 let have_census: i64 = ip_census_load(PP_CENSUS, appid) 69 var name: *u8 = appid_s 70 var name_src: *u8 = "appid" as *u8 71 if have_census == 1 { if ip_census_name_get()[0] != (0 as u8) { name = ip_census_name_get(); name_src = "census" as *u8 } } 72 // IM27: no census row names the title (the census is laptop-side until IM23) -> the platform's own name, banked by 73 // nx_steam_reviews name <appid>; only when THAT is absent too does the appid stand in, and the receipt says which 74 if rm_streq(name_src, "appid" as *u8) == 1 { 75 let np: *u8 = sys_mmap(PP_PATH_CAP) 76 var no: i64 = rm_cat(np, 0, PP_REVIEWS) 77 no = rm_cat(np, no, appid_s) 78 no = rm_cat(np, no, ".name" as *u8) 79 np[no] = 0 as u8 80 let nb: *u8 = sys_mmap(RM_NAME_CAP) 81 if rm_name_file_load(np, nb, RM_NAME_CAP) > 0 { name = nb; name_src = "platform-api" as *u8 } 82 } 83 rm_mkdirp(outdir) 84 let epoch: i64 = sys_now_realtime_sec() 85 ip_counters_reset() 86 var nd: i64 = 0 87 var nf: i64 = 0 88 if docs > 0 { nd = ip_propose_defects(outdir, epoch, appid, name, top, ms); nf = ip_propose_features(outdir, epoch, appid, name, top, ms) } 89 var ni: i64 = 0 90 if have_census == 1 { ni = ip_propose_installed(outdir, epoch, appid, name) } 91 rm_w("INTELMINE-PROPOSE appid=" as *u8); rm_wn(appid) 92 rm_w(" name=" as *u8); rm_w(name) 93 rm_w(" name_src=" as *u8); rm_w(name_src) 94 rm_w(" lang=" as *u8); rm_w(lang) 95 rm_w(" docs=" as *u8); rm_wn(docs) 96 rm_w(" tiers=" as *u8); var t: i64 = 0; while t < RM_TIER_N { if t > 0 { rm_w("/" as *u8) } rm_wn(rm_rubric_tier(t)); t = t + 1 } 97 rm_w(" census_row=" as *u8); rm_wn(have_census) 98 rm_w(" map_rows=" as *u8); rm_wn(maps) 99 rm_w(" stopwords=" as *u8); rm_wn(sw) 100 rm_w(" lexicon_terms=" as *u8); rm_wn(lex) 101 rm_w(" min_support=" as *u8); rm_wn(ms) 102 rm_w(" proposed_defects=" as *u8); rm_wn(nd) 103 rm_w(" proposed_features=" as *u8); rm_wn(nf) 104 rm_w(" proposed_installed=" as *u8); rm_wn(ni) 105 rm_w(" written=" as *u8); rm_wn(ip_rows_written_get()) 106 rm_w(" already_present=" as *u8); rm_wn(ip_rows_dup_get()) 107 rm_w(" unmapped=" as *u8); rm_wn(ip_rows_unmapped_get()) 108 rm_w(" outdir=" as *u8); rm_w(outdir) 109 rm_w("\n" as *u8) 110 if docs == 0 { if have_census == 0 { rm_w(" NOTHING-TO-PROPOSE no journal for this language and no census row; run nx_steam_reviews fetch and nx_installed_census steam first\n" as *u8); sys_exit(1); return 1 } } 111 sys_exit(0) 112 return 0 113}