Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added average frequency tag #1303

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions ext/js/display/display-generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@

this._appendMultiple(inflectionRuleChainsContainer, this._createInflectionRuleChain.bind(this), inflectionRuleChainCandidates);
this._appendMultiple(frequencyGroupListContainer, this._createFrequencyGroup.bind(this), groupedFrequencies, false);
this._createMeanFrequency(frequencyGroupListContainer, groupedFrequencies);
this._appendMultiple(groupedPronunciationsContainer, this._createGroupedPronunciation.bind(this), groupedPronunciations);
this._appendMultiple(headwordTagsContainer, this._createTermTag.bind(this), termTags, headwords.length);

Expand Down Expand Up @@ -989,6 +990,33 @@
}
}

_createMeanFrequency(container, groupedFrequencies) {

Check failure on line 993 in ext/js/display/display-generator.js

View workflow job for this annotation

GitHub Actions / Static Analysis

Missing JSDoc comment
let partialSum = 0;
for (let i = 0, ii = groupedFrequencies.length; i < ii; ++i) {

Check failure on line 995 in ext/js/display/display-generator.js

View workflow job for this annotation

GitHub Actions / Static Analysis

Unsafe assignment of an `any` value
let {dictionary, frequencies} = groupedFrequencies[i];

Check failure on line 996 in ext/js/display/display-generator.js

View workflow job for this annotation

GitHub Actions / Static Analysis

Unsafe assignment of an `any` value

Check failure on line 996 in ext/js/display/display-generator.js

View workflow job for this annotation

GitHub Actions / Static Analysis

'dictionary' is assigned a value but never used

Check failure on line 996 in ext/js/display/display-generator.js

View workflow job for this annotation

GitHub Actions / Static Analysis

'dictionary' is never reassigned. Use 'const' instead

Check failure on line 996 in ext/js/display/display-generator.js

View workflow job for this annotation

GitHub Actions / Static Analysis

'frequencies' is never reassigned. Use 'const' instead
if(frequencies[0]['values'][0]['frequency'] == null) {continue;}

Check failure on line 997 in ext/js/display/display-generator.js

View workflow job for this annotation

GitHub Actions / Static Analysis

Expected space(s) after "if"

Check failure on line 997 in ext/js/display/display-generator.js

View workflow job for this annotation

GitHub Actions / Static Analysis

["values"] is better written in dot notation

Check failure on line 997 in ext/js/display/display-generator.js

View workflow job for this annotation

GitHub Actions / Static Analysis

["frequency"] is better written in dot notation

Check failure on line 997 in ext/js/display/display-generator.js

View workflow job for this annotation

GitHub Actions / Static Analysis

Expected '===' and instead saw '=='
partialSum += 1/(frequencies[0]['values'][0]['frequency']);
}
partialSum = Math.floor(groupedFrequencies.length/partialSum);
const itemNode = this._instantiate('term-frequency-item');


itemNode.dataset.displayValue = String(partialSum);
itemNode.dataset.frequency = String(partialSum);

itemNode.dataset.dictionary = 'Average';

const groupNode = this._instantiate('frequency-group-item');
const body = this._querySelector(groupNode, '.tag-body-content');

const tagLabel = this._querySelector(groupNode, '.tag-label-content');
this._setTextContent(tagLabel, 'Average');
this._setTextContent(itemNode, String(partialSum), this._language);
groupNode.dataset.details = 'Average';
body.appendChild(itemNode);
container.appendChild(groupNode);
}

/**
* @param {string} dictionary
* @returns {import('dictionary').Tag}
Expand Down
Loading