mirror of
https://github.com/qeeqbox/social-analyzer.git
synced 2026-05-26 13:54:38 +00:00
[auto-b] Added finding ages option (req) - ref 38d56f839602
This commit is contained in:
@@ -258,6 +258,7 @@ app.post('/analyze_string', async function (req, res, next) {
|
||||
unknown: [],
|
||||
maybe: []
|
||||
}
|
||||
let ages = []
|
||||
let names_origins = []
|
||||
const words_info = []
|
||||
const temp_words = []
|
||||
@@ -421,6 +422,12 @@ app.post('/analyze_string', async function (req, res, next) {
|
||||
await stringAnalysis.find_numbers(req, all_words)
|
||||
helper.log_to_file_queue(req.body.uuid, '[Done] Finding Numbers')
|
||||
}
|
||||
if (req.body.option.includes('FindAges')) {
|
||||
helper.log_to_file_queue(req.body.uuid, '[Starting] Finding Ages')
|
||||
ages = await stringAnalysis.guess_age_from_string(req)
|
||||
helper.log_to_file_queue(req.body.uuid, '[Done] Finding Ages')
|
||||
}
|
||||
|
||||
req.body.string = req.body.string.toLowerCase()
|
||||
|
||||
if (req.body.option.includes('ConvertNumbers')) {
|
||||
@@ -491,26 +498,28 @@ app.post('/analyze_string', async function (req, res, next) {
|
||||
helper.log_to_file_queue(req.body.uuid, '[Finished] Analyzing: ' + req.body.string + ' Task: ' + req.body.uuid)
|
||||
|
||||
/*fs.writeFileSync('./test.json', JSON.stringify({
|
||||
username: username,
|
||||
uuid: temp_uuid,
|
||||
info,
|
||||
table: all_words,
|
||||
common: temp_words,
|
||||
words_info: words_info,
|
||||
user_info_normal: user_info_normal,
|
||||
user_info_advanced: user_info_advanced,
|
||||
user_info_special: user_info_special,
|
||||
names_origins: names_origins,
|
||||
custom_search: custom_search,
|
||||
graph: graph,
|
||||
stats: stats_default,
|
||||
logs: logs
|
||||
username: username,
|
||||
uuid: temp_uuid,
|
||||
info,
|
||||
ages: ages,
|
||||
table: all_words,
|
||||
common: temp_words,
|
||||
words_info: words_info,
|
||||
user_info_normal: user_info_normal,
|
||||
user_info_advanced: user_info_advanced,
|
||||
user_info_special: user_info_special,
|
||||
names_origins: names_origins,
|
||||
custom_search: custom_search,
|
||||
graph: graph,
|
||||
stats: stats_default,
|
||||
logs: logs
|
||||
}, null, 2) , 'utf-8');*/
|
||||
|
||||
res.json({
|
||||
username: username,
|
||||
uuid: temp_uuid,
|
||||
info,
|
||||
ages: ages,
|
||||
table: all_words,
|
||||
common: temp_words,
|
||||
words_info: words_info,
|
||||
|
||||
@@ -225,6 +225,53 @@ async function get_maybe_words (req, all_words) {
|
||||
}).filter(word => word.length > 1)
|
||||
}
|
||||
|
||||
async function guess_age_from_string(req) {
|
||||
let results = []
|
||||
|
||||
try {
|
||||
let age_4_numbers = /\d{4}|\d{2}/g
|
||||
let current_year = new Date().getFullYear()
|
||||
while ((match = age_4_numbers.exec(req.body.string)) != null) {
|
||||
let temp_dict = {"found":"","year":"","age":""}
|
||||
let found = 0
|
||||
let year = 0
|
||||
let age = 0
|
||||
temp_dict.found = match[0]
|
||||
found = parseInt(match[0])
|
||||
if (found >= 50 && found <= 99){
|
||||
year = found + 1900
|
||||
age = current_year - year
|
||||
if (age <= 75){
|
||||
temp_dict.year = year.toString()
|
||||
temp_dict.age = age.toString()
|
||||
}
|
||||
}
|
||||
if (found >= 14 && found <= 49){
|
||||
year = current_year - found
|
||||
age = found
|
||||
if (age <= 75){
|
||||
temp_dict.year = year.toString()
|
||||
temp_dict.age = age.toString()
|
||||
}
|
||||
}
|
||||
if (found >= 1950){
|
||||
year = found
|
||||
age = current_year - year
|
||||
if (age <= 75){
|
||||
temp_dict.year = year.toString()
|
||||
temp_dict.age = age.toString()
|
||||
}
|
||||
}
|
||||
|
||||
results.push(temp_dict)
|
||||
}
|
||||
|
||||
} catch (err) {
|
||||
}
|
||||
|
||||
return results
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
get_maybe_words,
|
||||
find_symbols,
|
||||
@@ -235,5 +282,6 @@ module.exports = {
|
||||
split_alphabet_case,
|
||||
most_common,
|
||||
find_other,
|
||||
analyze_string
|
||||
analyze_string,
|
||||
guess_age_from_string
|
||||
}
|
||||
|
||||
+39
-9
@@ -261,6 +261,7 @@
|
||||
#words-info-section,
|
||||
#stats-section,
|
||||
#metadata-section,
|
||||
#ages-section,
|
||||
#custom-search-section,
|
||||
#names-origins-section {
|
||||
display: none;
|
||||
@@ -805,6 +806,21 @@
|
||||
<div id="names-origins-table" class="collapse show">
|
||||
</div>
|
||||
</div>
|
||||
<div class="box-border-style" id="possible-words-section">
|
||||
<div class="div-header">
|
||||
<div class="div-left">Extracted combinations</div>
|
||||
<div class="div-right"><i class="div-right-icon fa fa-caret-up"></i></div>
|
||||
</div>
|
||||
<div id="possible-words-section-table" class="collapse show"></div>
|
||||
</div>
|
||||
<div class="box-border-style" id="ages-section">
|
||||
<div class="div-header">
|
||||
<div class="div-left">Extracted Profile\Person age (Maybe)</div>
|
||||
<div class="div-right"><i class="div-right-icon fa fa-caret-up"></i></div>
|
||||
</div>
|
||||
<div id="ages-table" class="collapse show">
|
||||
</div>
|
||||
</div>
|
||||
<div class="box-border-style" id="words-info-section">
|
||||
<div class="div-header">
|
||||
<div class="div-left">Extracted words information </div>
|
||||
@@ -821,13 +837,6 @@
|
||||
<div id="custom-search-table" class="collapse show">
|
||||
</div>
|
||||
</div>
|
||||
<div class="box-border-style" id="possible-words-section">
|
||||
<div class="div-header">
|
||||
<div class="div-left">Possible words for combinations</div>
|
||||
<div class="div-right"><i class="div-right-icon fa fa-caret-up"></i></div>
|
||||
</div>
|
||||
<div id="possible-words-section-table" class="collapse show"></div>
|
||||
</div>
|
||||
<div class="box-border-style" id="combinations-section">
|
||||
<div class="div-header">
|
||||
<div class="div-left">Save Report</div>
|
||||
@@ -1003,6 +1012,12 @@
|
||||
name: 'Find numbers in names or words before analyzing',
|
||||
disable: false,
|
||||
},
|
||||
{
|
||||
group: 'Other options',
|
||||
value: 'FindAges',
|
||||
name: 'Find age in names or words before analyzing',
|
||||
disable: false,
|
||||
},
|
||||
{
|
||||
group: 'Other options',
|
||||
value: 'FindSymbols',
|
||||
@@ -1199,6 +1214,8 @@
|
||||
$('#stats-section').hide();
|
||||
$('#metadata-table').html('');
|
||||
$('#metadata-section').hide();
|
||||
$('#ages-table').html('');
|
||||
$('#ages-section').hide();
|
||||
clearInterval(interval_logs);
|
||||
}
|
||||
|
||||
@@ -1467,8 +1484,8 @@
|
||||
$('#stats-tables').last().append(`<table><tr><th>[${status_key} profiles] ${type_key}</th><th>Percentage</th></tr>${temp_tr}</table>`);
|
||||
}
|
||||
});
|
||||
$('#stats-section').show();
|
||||
}
|
||||
$('#stats-section').show();
|
||||
}
|
||||
if(typeof data.stats[type_key] === "object" && Array.isArray(data.stats[type_key])){
|
||||
temp_tr = '';
|
||||
@@ -1484,6 +1501,19 @@
|
||||
}
|
||||
});
|
||||
|
||||
if(data.ages.length > 0){
|
||||
temp_tr = '';
|
||||
data.ages.forEach((item) => {
|
||||
temp_tr += `<tr><td>${item.found}</td><td>${item.year}</td><td>${item.age}</td></tr>`;
|
||||
});
|
||||
|
||||
if (temp_tr.length > 0) {
|
||||
$('#ages-table').last().append(`<table><tr><th>Found</th><th>Year</th><th>Age</th></tr>${temp_tr}</table>`);
|
||||
}
|
||||
|
||||
$('#ages-section').show();
|
||||
}
|
||||
|
||||
if (data.logs.length > 0) {
|
||||
$('#logs-pre').html(`<pre>${data.logs}</pre>`);
|
||||
$('#logs-section').show();
|
||||
@@ -1625,7 +1655,7 @@
|
||||
e.preventDefault();
|
||||
$('#analyzed-options')[0].selectize.clear();
|
||||
$('#analyzed-options')[0].selectize.setValue(['WordInfo', 'MostCommon', 'FindOrigins', 'LookUps', 'CustomSearch', 'FindUserProfilesFast,GetUserProfilesFast', 'ExtractMetadata', 'ExtractPatterns', 'NetworkGraph', 'FindNumbers',
|
||||
'CategoriesStats','MetadataStats',
|
||||
'CategoriesStats','MetadataStats','FindAges',
|
||||
'FindSymbols', 'SplitWordsByAlphabet', 'SplitWordsByUpperCase',
|
||||
]);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user