_id
stringlengths
2
6
title
stringlengths
0
58
partition
stringclasses
3 values
text
stringlengths
52
373k
language
stringclasses
1 value
meta_information
dict
q58600
warn
validation
function warn(msg) { if (PDFJS.verbosity >= PDFJS.VERBOSITY_LEVELS.warnings) { console.log('Warning: ' + msg); } }
javascript
{ "resource": "" }
q58601
error
validation
function error(msg) { // If multiple arguments were passed, pass them all to the log function. if (arguments.length > 1) { var logArguments = ['Error:']; logArguments.push.apply(logArguments, arguments); console.log.apply(console, logArguments); // Join the arguments into a single string for the lin...
javascript
{ "resource": "" }
q58602
combineUrl
validation
function combineUrl(baseUrl, url) { if (!url) { return baseUrl; } if (/^[a-z][a-z0-9+\-.]*:/i.test(url)) { return url; } var i; if (url.charAt(0) === '/') { // absolute path i = baseUrl.indexOf('://'); if (url.charAt(1) === '/') { ++i; } else { i = baseUrl.indexOf('/', i ...
javascript
{ "resource": "" }
q58603
PageViewPort_clone
validation
function PageViewPort_clone(args) { args = args || {}; var scale = 'scale' in args ? args.scale : this.scale; var rotation = 'rotation' in args ? args.rotation : this.rotation; return new PageViewport(this.viewBox.slice(), scale, rotation, this.offsetX, this.offsetY...
javascript
{ "resource": "" }
q58604
PageViewport_convertToViewportRectangle
validation
function PageViewport_convertToViewportRectangle(rect) { var tl = Util.applyTransform([rect[0], rect[1]], this.transform); var br = Util.applyTransform([rect[2], rect[3]], this.transform); return [tl[0], tl[1], br[0], br[1]]; }
javascript
{ "resource": "" }
q58605
createPromiseCapability
validation
function createPromiseCapability() { var capability = {}; capability.promise = new Promise(function (resolve, reject) { capability.resolve = resolve; capability.reject = reject; }); return capability; }
javascript
{ "resource": "" }
q58606
messageHandlerSend
validation
function messageHandlerSend(actionName, data, transfers) { var message = { action: actionName, data: data }; this.postMessage(message, transfers); }
javascript
{ "resource": "" }
q58607
messageHandlerSendWithPromise
validation
function messageHandlerSendWithPromise(actionName, data, transfers) { var callbackId = this.callbackIndex++; var message = { action: actionName, data: data, callbackId: callbackId }; var capability = createPromiseCapability(); this.callbacksCapabilities[callbackId] = capability; ...
javascript
{ "resource": "" }
q58608
validation
function (message, transfers) { if (transfers && this.postMessageTransfers) { this.comObj.postMessage(message, transfers); } else { this.comObj.postMessage(message); } }
javascript
{ "resource": "" }
q58609
hookCallbacks
validation
function hookCallbacks(stackHelper) { let stack = stackHelper._stack; // hook up callbacks controls.addEventListener('OnScroll', function(e) { if (e.delta > 0) { if (stackHelper.index >= stackHelper.orientationMaxIndex - 1) { return false; } stackHelper.index += 1; ...
javascript
{ "resource": "" }
q58610
onWindowResize
validation
function onWindowResize() { let threeD = document.getElementById('r3d'); camera.canvas = { width: threeD.clientWidth, height: threeD.clientHeight, }; camera.fitBox(2); renderer.setSize(threeD.clientWidth, threeD.clientHeight); // update info to draw borders properly...
javascript
{ "resource": "" }
q58611
onWindowKeyPressed
validation
function onWindowKeyPressed(event) { ctrlDown = event.ctrlKey; if (!ctrlDown) { drag.start.x = null; drag.start.y = null; } }
javascript
{ "resource": "" }
q58612
onMouseMove
validation
function onMouseMove(event) { if (ctrlDown) { if (drag.start.x === null) { drag.start.x = event.clientX; drag.start.y = event.clientY; } let threshold = 15; stackHelper.slice.intensityAuto = false; let dynamicRange = stack.minMax[1] - stack.minMax[0]; ...
javascript
{ "resource": "" }
q58613
handleSeries
validation
function handleSeries(seriesContainer) { // cleanup the loader and its progress bar loader.free(); loader = null; // prepare for slice visualization // first stack of first series let stack = seriesContainer[0].mergeSeries(seriesContainer)[0].stack[0]; let stackHelper = new HelpersStack(sta...
javascript
{ "resource": "" }
q58614
loadSequenceGroup
validation
function loadSequenceGroup(files) { const fetchSequence = []; for (let i = 0; i < files.length; i++) { fetchSequence.push( new Promise((resolve, reject) => { const myReader = new FileReader(); // should handle errors too... myReader.addEventListener('lo...
javascript
{ "resource": "" }
q58615
init
validation
function init() { /** * Animation loop */ function animate() { updateGeometries(); render(); // request new frame requestAnimationFrame(function() { animate(); }); } // renderer threeD = document.getElementById('r3d'); renderer = new THREE.WebGLRenderer({ antialias: tru...
javascript
{ "resource": "" }
q58616
init
validation
function init() { /** * Called on each animation frame */ function animate() { render(); // request new frame requestAnimationFrame(function() { animate(); }); } // renderers initRenderer3D(r0); initRenderer2D(r1); initRenderer2D(r2); initRenderer2D(r3); // start renderi...
javascript
{ "resource": "" }
q58617
updateLocalizer
validation
function updateLocalizer(refObj, targetLocalizersHelpers) { let refHelper = refObj.stackHelper; let localizerHelper = refObj.localizerHelper; let plane = refHelper.slice.cartesianEquation(); localizerHelper.referencePlane = plane; // bit of a hack... works fine for this applicat...
javascript
{ "resource": "" }
q58618
mapCanvasToData
validation
function mapCanvasToData() { for (let i = ijkBBox[0]; i < ijkBBox[1] + 1; i++) { for (let j = ijkBBox[2]; j < ijkBBox[3] + 1; j++) { for (let k = ijkBBox[4]; k < ijkBBox[5] + 1; k++) { // ijk to world // center of voxel let worldCoordinate = new THREE.Vector3(i, j, k).app...
javascript
{ "resource": "" }
q58619
getShortlinker
validation
function getShortlinker() { if ( globalScope.yoast.shortlinker === null ) { globalScope.yoast.shortlinker = new Shortlinker(); } return globalScope.yoast.shortlinker; }
javascript
{ "resource": "" }
q58620
validation
function( sentencePartText, auxiliaries, locale ) { this._sentencePartText = sentencePartText; this._auxiliaries = auxiliaries; this._locale = locale; this._isPassive = false; }
javascript
{ "resource": "" }
q58621
validation
function( i18n, options = {} ) { Assessor.call( this, i18n, options ); this.type = "ContentAssessor"; const locale = ( options.hasOwnProperty( "locale" ) ) ? options.locale : "en_US"; this._assessments = [ new FleschReadingEase( contentConfiguration( locale ).fleschReading ), new SubheadingDistributionTooLong...
javascript
{ "resource": "" }
q58622
DeviationFragment
validation
function DeviationFragment( options ) { this._location = options.location; this._fragment = options.word; this._syllables = options.syllables; this._regex = null; this._options = pick( options, [ "notFollowedBy", "alsoFollowedBy" ] ); }
javascript
{ "resource": "" }
q58623
sortResults
validation
function sortResults( assessmentResults ) { return assessmentResults.sort( ( a, b ) => { // First compare the score. if ( a.score < b.score ) { return -1; } if ( a.score > b.score ) { return 1; } // If there is no difference then compare the id. return a.id.localeCompare( b.id ); } ); }
javascript
{ "resource": "" }
q58624
mapResult
validation
function mapResult( result ) { result.id = result.getIdentifier(); result.rating = scoreToRating( result.score ); result.hasMarks = result.hasMarks(); result.marker = result.getMarker(); // Because of inconsistency between YoastSEO and yoast-components. if ( result.rating === "ok" ) { result.rating = "OK"; } ...
javascript
{ "resource": "" }
q58625
mapResults
validation
function mapResults( results ) { const mappedResults = []; for ( let i = 0; i < results.length; i++ ) { if ( ! results[ i ].text ) { continue; } mappedResults.push( mapResult( results[ i ] ) ); } return sortResults( mappedResults ); }
javascript
{ "resource": "" }
q58626
validation
function( participle, sentencePart, attributes ) { Participle.call( this, participle, sentencePart, attributes ); this.setSentencePartPassiveness( this.isPassive() ); }
javascript
{ "resource": "" }
q58627
validation
function( args ) { this.keyword = args.keyword; this.assessor = args.assessor; this.i18n = args.i18n; this.output = args.targets.output; this.overall = args.targets.overall || "overallScore"; this.presenterConfig = createConfig( args.i18n ); this._disableMarkerButtons = false; this._activeMarker = false; }
javascript
{ "resource": "" }
q58628
getBlocks
validation
function getBlocks( text ) { var blocks = [], depth = 0, blockStartTag = "", currentBlock = "", blockEndTag = ""; // Remove all comments because it is very hard to tokenize them. text = text.replace( commentRegex, "" ); createTokenizer(); htmlBlockTokenizer.onText( text ); htmlBlockTokenizer.end(); forE...
javascript
{ "resource": "" }
q58629
formatNumber
validation
function formatNumber( number ) { if ( Math.round( number ) === number ) { return number; } return Math.round( number * 10000 ) / 10000; }
javascript
{ "resource": "" }
q58630
validation
function( participle, sentencePart, attributes ) { Participle.call( this, participle, sentencePart, attributes ); checkException.call( this ); }
javascript
{ "resource": "" }
q58631
validation
function( participleExceptionRegexes ) { var participle = this.getParticiple(); var match = []; forEach( participleExceptionRegexes, function( participleExceptionRegex ) { var exceptionMatch = participle.match( participleExceptionRegex ); if ( exceptionMatch ) { match.push( exceptionMatch[ 0 ] ); } } ); ...
javascript
{ "resource": "" }
q58632
getSentenceBeginning
validation
function getSentenceBeginning( sentence, firstWordExceptions ) { const words = getWords( stripTags( stripSpaces( sentence ) ) ); if ( words.length === 0 ) { return ""; } let firstWord = words[ 0 ].toLocaleLowerCase(); if ( firstWordExceptions.indexOf( firstWord ) > -1 && words.length > 1 ) { firstWord += " ...
javascript
{ "resource": "" }
q58633
textPresenceAssessment
validation
function textPresenceAssessment( paper, researcher, i18n ) { const text = stripHTMLTags( paper.getText() ); const urlTitle = createAnchorOpeningTag( "https://yoa.st/35h" ); const urlCallToAction = createAnchorOpeningTag( "https://yoa.st/35i" ); if ( text.length < 50 ) { const result = new AssessmentResult(); ...
javascript
{ "resource": "" }
q58634
splitOnWords
validation
function splitOnWords( sentence, stopwords ) { const splitSentences = []; // Split the sentence on each found stopword and push this part in an array. forEach( stopwords, function( stopword ) { const sentenceSplit = sentence.split( stopword ); if ( ! isEmpty( sentenceSplit[ 0 ] ) ) { splitSentences.push( sen...
javascript
{ "resource": "" }
q58635
createSentenceParts
validation
function createSentenceParts( sentences, language ) { const auxiliaryRegex = languageVariables[ language ].auxiliaryRegex; const SentencePart = languageVariables[ language ].SentencePart; const sentenceParts = []; forEach( sentences, function( part ) { const foundAuxiliaries = sanitizeMatches( part.match( auxilia...
javascript
{ "resource": "" }
q58636
splitSentence
validation
function splitSentence( sentence, language ) { const stopwordRegex = languageVariables[ language ].stopwordRegex; const stopwords = sentence.match( stopwordRegex ) || []; const splitSentences = splitOnWords( sentence, stopwords ); return createSentenceParts( splitSentences, language ); }
javascript
{ "resource": "" }
q58637
createDefaultSnippetPreview
validation
function createDefaultSnippetPreview() { var targetElement = document.getElementById( this.config.targets.snippet ); return new SnippetPreview( { analyzerApp: this, targetElement: targetElement, callbacks: { saveSnippetData: this.config.callbacks.saveSnippetData, }, } ); }
javascript
{ "resource": "" }
q58638
verifyArguments
validation
function verifyArguments( args ) { if ( ! isObject( args.callbacks.getData ) ) { throw new MissingArgument( "The app requires an object with a getdata callback." ); } if ( ! isObject( args.targets ) ) { throw new MissingArgument( "`targets` is a required App argument, `targets` is not an object." ); } // The...
javascript
{ "resource": "" }
q58639
getWordCombinations
validation
function getWordCombinations( text, combinationSize, functionWords ) { const sentences = getSentences( text ); let words, combination; return flatMap( sentences, function( sentence ) { sentence = sentence.toLocaleLowerCase(); sentence = normalizeQuotes( sentence ); words = getWords( sentence ); return fil...
javascript
{ "resource": "" }
q58640
calculateOccurrences
validation
function calculateOccurrences( wordCombinations ) { const occurrences = {}; forEach( wordCombinations, function( wordCombination ) { const combination = wordCombination.getCombination(); if ( ! has( occurrences, combination ) ) { occurrences[ combination ] = wordCombination; } occurrences[ combination ]...
javascript
{ "resource": "" }
q58641
getRelevantCombinations
validation
function getRelevantCombinations( wordCombinations ) { wordCombinations = wordCombinations.filter( function( combination ) { return combination.getOccurrences() !== 1 && combination.getRelevance() !== 0; } ); return wordCombinations; }
javascript
{ "resource": "" }
q58642
sortCombinations
validation
function sortCombinations( wordCombinations ) { wordCombinations.sort( function( combinationA, combinationB ) { const difference = combinationB.getRelevance() - combinationA.getRelevance(); // The combination with the highest relevance comes first. if ( difference !== 0 ) { return difference; } // In case...
javascript
{ "resource": "" }
q58643
filterOneCharacterWordCombinations
validation
function filterOneCharacterWordCombinations( wordCombinations ) { return wordCombinations.filter( function( combination ) { return ! ( combination.getLength() === 1 && combination.getWords()[ 0 ].length <= 1 ); } ); }
javascript
{ "resource": "" }
q58644
filterFunctionWordsAnywhere
validation
function filterFunctionWordsAnywhere( wordCombinations, functionWords ) { return wordCombinations.filter( function( combination ) { return isEmpty( intersection( functionWords, combination.getWords() ) ); } ); }
javascript
{ "resource": "" }
q58645
filterFunctionWordsAtBeginning
validation
function filterFunctionWordsAtBeginning( wordCombinations, functionWords ) { return wordCombinations.filter( function( combination ) { return ! includes( functionWords, combination.getWords()[ 0 ] ); } ); }
javascript
{ "resource": "" }
q58646
filterFunctionWordsAtEnding
validation
function filterFunctionWordsAtEnding( wordCombinations, functionWords ) { return wordCombinations.filter( function( combination ) { const words = combination.getWords(); const lastWordIndex = words.length - 1; return ! includes( functionWords, words[ lastWordIndex ] ); } ); }
javascript
{ "resource": "" }
q58647
filterFunctionWordsAtBeginningAndEnding
validation
function filterFunctionWordsAtBeginningAndEnding( wordCombinations, functionWords ) { wordCombinations = filterFunctionWordsAtBeginning( wordCombinations, functionWords ); wordCombinations = filterFunctionWordsAtEnding( wordCombinations, functionWords ); return wordCombinations; }
javascript
{ "resource": "" }
q58648
filterOnDensity
validation
function filterOnDensity( wordCombinations, wordCount, lowerLimit, upperLimit ) { return wordCombinations.filter( function( combination ) { return ( combination.getDensity( wordCount ) >= lowerLimit && combination.getDensity( wordCount ) < upperLimit ); } ); }
javascript
{ "resource": "" }
q58649
filterEndingWith
validation
function filterEndingWith( wordCombinations, str, exceptions ) { wordCombinations = wordCombinations.filter( function( combination ) { const combinationstr = combination.getCombination(); for ( let i = 0; i < exceptions.length; i++ ) { if ( combinationstr.endsWith( exceptions[ i ] ) ) { return true; } ...
javascript
{ "resource": "" }
q58650
filterFunctionWords
validation
function filterFunctionWords( combinations, functionWords ) { combinations = filterFunctionWordsAnywhere( combinations, functionWords.filteredAnywhere ); combinations = filterFunctionWordsAtBeginningAndEnding( combinations, functionWords.filteredAtBeginningAndEnding ); combinations = filterFunctionWordsAtEnding( com...
javascript
{ "resource": "" }
q58651
filterCombinations
validation
function filterCombinations( combinations, functionWords, language ) { combinations = filterFunctionWordsAnywhere( combinations, specialCharacters ); combinations = filterOneCharacterWordCombinations( combinations ); combinations = filterFunctionWords( combinations, functionWords ); if ( language === "en" ) { com...
javascript
{ "resource": "" }
q58652
getRelevantWords
validation
function getRelevantWords( text, locale ) { let language = getLanguage( locale ); if ( ! functionWordLists.hasOwnProperty( language ) ) { language = "en"; } const functionWords = functionWordLists[ language ]; const words = getWordCombinations( text, 1, functionWords.all ); const wordCount = words.length; l...
javascript
{ "resource": "" }
q58653
WordCombination
validation
function WordCombination( words, occurrences, functionWords ) { this._words = words; this._length = words.length; this._occurrences = occurrences || 0; this._functionWords = functionWords; }
javascript
{ "resource": "" }
q58654
createAssessment
validation
function createAssessment( name, score = 9, text = "Excellent" ) { const assessment = new Assessment(); assessment.identifier = name; assessment.getResult = () => { const result = new AssessmentResult(); result.setScore( score ); result.setText( text ); return result; }; return assessment; }
javascript
{ "resource": "" }
q58655
MissingArgumentError
validation
function MissingArgumentError( message ) { Error.captureStackTrace( this, this.constructor ); this.name = this.constructor.name; this.message = message; }
javascript
{ "resource": "" }
q58656
validation
function( participle, sentencePart, attributes ) { this.setParticiple( participle ); this.setSentencePart( sentencePart ); this._determinesSentencePartIsPassive = false; attributes = attributes || {}; defaults( attributes, defaultAttributes ); validateAttributes( attributes ); this._attributes = attributes; ...
javascript
{ "resource": "" }
q58657
getSubheadingsTopLevel
validation
function getSubheadingsTopLevel( text ) { const subheadings = []; const regex = /<h([2-3])(?:[^>]+)?>(.*?)<\/h\1>/ig; let match; while ( ( match = regex.exec( text ) ) !== null ) { subheadings.push( match ); } return subheadings; }
javascript
{ "resource": "" }
q58658
getSentencesFromBlock
validation
function getSentencesFromBlock( block ) { const sentenceTokenizer = new SentenceTokenizer(); const { tokenizer, tokens } = sentenceTokenizer.createTokenizer(); sentenceTokenizer.tokenize( tokenizer, block ); return tokens.length === 0 ? [] : sentenceTokenizer.getSentencesFromTokens( tokens ); }
javascript
{ "resource": "" }
q58659
createWorker
validation
function createWorker( url ) { let worker = null; try { worker = new Worker( url ); } catch ( e ) { try { const blobUrl = createBlobURL( url ); worker = new Worker( blobUrl ); } catch ( e2 ) { throw e2; } } return worker; }
javascript
{ "resource": "" }
q58660
validation
function( i18n, options ) { this.type = "Assessor"; this.setI18n( i18n ); this._assessments = []; this._options = options || {}; if ( ! isUndefined( this._options.researcher ) ) { this._researcher = this._options.researcher; } }
javascript
{ "resource": "" }
q58661
configureStore
validation
function configureStore( preloadedState = {}, extraMiddleware = [] ) { const enhancers = configureEnhancers( extraMiddleware ); return createStore( rootReducer, preloadedState, enhancers ); }
javascript
{ "resource": "" }
q58662
removeLinksFromText
validation
function removeLinksFromText( text ) { const anchors = getAnchorsFromText( text ); if ( anchors.length > 0 ) { anchors.forEach( function( anchor ) { text = text.replace( anchor, "" ); } ); } return text; }
javascript
{ "resource": "" }
q58663
removeImagesFromText
validation
function removeImagesFromText( text ) { const images = imageInText( text ); const imageTags = matchStringWithRegex( text, "</img>" ); if ( images.length > 0 ) { images.forEach( function( image ) { text = text.replace( image, "" ); } ); imageTags.forEach( function( imageTag ) { text = text.replace( imag...
javascript
{ "resource": "" }
q58664
paragraphHasNoText
validation
function paragraphHasNoText( text ) { // Strip links and check if paragraph consists of links only text = removeLinksFromText( text ); if ( text === "" ) { return true; } text = removeImagesFromText( text ); if ( text === "" ) { return true; } // Remove empty divisions from the text const emptyDivisions ...
javascript
{ "resource": "" }
q58665
getRelevantWords
validation
function getRelevantWords( text, locale ) { if ( ! isEqual( text, previousRelevantWords.text ) || ! isEqual( locale, previousRelevantWords.locale ) ) { previousRelevantWords = { text, locale, data: calculateRelevantWords( text, locale ), }; } return previousRelevantWords.data; }
javascript
{ "resource": "" }
q58666
validation
function() { var baseURL = this.opts.baseURL; /* * For backwards compatibility, if no URL was passed to the snippet editor we try to retrieve the base URL from the * rawData in the App. This is because the scrapers used to be responsible for retrieving the baseURL, but the base * URL is static so we can just p...
javascript
{ "resource": "" }
q58667
updateUnformattedText
validation
function updateUnformattedText( key, value ) { this.element.input[ key ].value = value; this.data[ key ] = value; }
javascript
{ "resource": "" }
q58668
rateTitleLength
validation
function rateTitleLength( titleLength ) { var rating; switch ( true ) { case titleLength > 0 && titleLength <= 399: case titleLength > 600: rating = "ok"; break; case titleLength >= 400 && titleLength <= 600: rating = "good"; break; default: rating = "bad"; break; } return rating; }
javascript
{ "resource": "" }
q58669
rateMetaDescLength
validation
function rateMetaDescLength( metaDescLength ) { var rating; switch ( true ) { case metaDescLength > 0 && metaDescLength < 120: case metaDescLength > maximumMetaDescriptionLength: rating = "ok"; break; case metaDescLength >= 120 && metaDescLength <= maximumMetaDescriptionLength: rating = "good"; br...
javascript
{ "resource": "" }
q58670
updateProgressBar
validation
function updateProgressBar( element, value, maximum, rating ) { var barElement, progress, allClasses = [ "snippet-editor__progress--bad", "snippet-editor__progress--ok", "snippet-editor__progress--good", ]; element.value = value; domManipulation.removeClasses( element, allClasses ); domManipulation.ad...
javascript
{ "resource": "" }
q58671
getAnalyzerTitle
validation
function getAnalyzerTitle() { var title = this.data.title; if ( isEmpty( title ) ) { title = this.opts.defaultValue.title; } if ( this.hasPluggable() ) { title = this.refObj.pluggable._applyModifications( "data_page_title", title ); } return stripSpaces( title ); }
javascript
{ "resource": "" }
q58672
validation
function() { var metaDesc = this.data.metaDesc; if ( isEmpty( metaDesc ) ) { metaDesc = this.opts.defaultValue.metaDesc; } if ( this.hasPluggable() ) { metaDesc = this.refObj.pluggable._applyModifications( "data_meta_desc", metaDesc ); } if ( ! isEmpty( this.opts.metaDescriptionDate ) && ! isEmpty( metaDes...
javascript
{ "resource": "" }
q58673
showTrace
validation
function showTrace( errorMessage ) { if ( isUndefined( errorMessage ) ) { errorMessage = ""; } if ( ! isUndefined( console ) && ! isUndefined( console.trace ) ) { console.trace( errorMessage ); } }
javascript
{ "resource": "" }
q58674
getIndicesByWord
validation
function getIndicesByWord( word, text ) { var startIndex = 0; var searchStringLength = word.length; var index, indices = []; while ( ( index = text.indexOf( word, startIndex ) ) > -1 ) { // Check if the previous and next character are word boundaries to determine if a complete word was detected var isPreviousCh...
javascript
{ "resource": "" }
q58675
validation
function( words, text ) { var matchedWords = []; forEach( words, function( word ) { word = stripSpaces( word ); if ( ! matchWordInSentence( word, text ) ) { return; } matchedWords = matchedWords.concat( getIndicesByWord( word, text ) ); } ); return matchedWords; }
javascript
{ "resource": "" }
q58676
validation
function( indices ) { indices = sortIndices( indices ); var filtered = []; for ( var i = 0; i < indices.length; i++ ) { // If the next index is within the range of the current index and the length of the word, remove it // This makes sure we don't match combinations twice, like "even though" and "though". if (...
javascript
{ "resource": "" }
q58677
validation
function( words, text ) { var matchedWords = []; forEach( words, function( word ) { word = stripSpaces( word ); if ( ! matchWordInSentence( word, text ) ) { return matchedWords; } matchedWords = matchedWords.concat( getIndicesByWord( word, text ) ); } ); matchedWords = matchedWords.sort( function( a, b...
javascript
{ "resource": "" }
q58678
createMeasurementElement
validation
function createMeasurementElement() { const hiddenElement = document.createElement( "div" ); hiddenElement.id = elementId; // Styles to prevent unintended scrolling in Gutenberg. hiddenElement.style.position = "absolute"; hiddenElement.style.left = "-9999em"; hiddenElement.style.top = 0; hiddenElement.style.he...
javascript
{ "resource": "" }
q58679
validation
function( app ) { this.app = app; this.loaded = false; this.preloadThreshold = 3000; this.plugins = {}; this.modifications = {}; this.customTests = []; // Allow plugins 1500 ms to register before we start polling their setTimeout( this._pollLoadingPlugins.bind( this ), 1500 ); }
javascript
{ "resource": "" }
q58680
validation
function( paper ) { this.setPaper( paper ); this.defaultResearches = { urlLength: urlLength, wordCountInText: wordCountInText, findKeywordInPageTitle: findKeywordInPageTitle, calculateFleschReading: calculateFleschReading, getLinkStatistics: getLinkStatistics, getLinks: getLinks, linkCount: linkCount, ...
javascript
{ "resource": "" }
q58681
areEqual
validation
function areEqual( urlA, urlB ) { // Make sure we are comparing URLs without query arguments and hashes. urlA = removeQueryArgs( removeHash( urlA ) ); urlB = removeQueryArgs( removeHash( urlB ) ); return addTrailingSlash( urlA ) === addTrailingSlash( urlB ); }
javascript
{ "resource": "" }
q58682
isInternalLink
validation
function isInternalLink( url, host ) { const parsedUrl = urlMethods.parse( url, false, true ); // Check if the URL starts with a single slash. if ( url.indexOf( "//" ) === -1 && url.indexOf( "/" ) === 0 ) { return true; } // Check if the URL starts with a # indicating a fragment. if ( url.indexOf( "#" ) === 0 ...
javascript
{ "resource": "" }
q58683
validation
function( word, locale ) { var numberOfSyllables = 0; var vowelRegex = new RegExp( "[^" + syllableMatchers( locale ).vowels + "]", "ig" ); var foundVowels = word.split( vowelRegex ); var filteredWords = filter( foundVowels, function( vowel ) { return vowel !== ""; } ); numberOfSyllables += filteredWords.length;...
javascript
{ "resource": "" }
q58684
validation
function( word, locale ) { var fullWordDeviations = syllableMatchers( locale ).deviations.words.full; var deviation = find( fullWordDeviations, function( fullWordDeviation ) { return fullWordDeviation.word === word; } ); if ( ! isUndefined( deviation ) ) { return deviation.syllables; } return 0; }
javascript
{ "resource": "" }
q58685
createDeviationFragments
validation
function createDeviationFragments( syllableConfig ) { var deviationFragments = []; var deviations = syllableConfig.deviations; if ( ! isUndefined( deviations.words ) && ! isUndefined( deviations.words.fragments ) ) { deviationFragments = flatMap( deviations.words.fragments, function( fragments, fragmentLocation ...
javascript
{ "resource": "" }
q58686
validation
function( word, locale ) { var deviationFragments = createDeviationFragmentsMemoized( syllableMatchers( locale ) ); var remainingParts = word; var syllableCount = 0; forEach( deviationFragments, function( deviationFragment ) { if ( deviationFragment.occursIn( remainingParts ) ) { remainingParts = deviationFra...
javascript
{ "resource": "" }
q58687
validation
function( word, locale ) { var syllableCount = 0; syllableCount += countVowelGroups( word, locale ); syllableCount += countVowelDeviations( word, locale ); return syllableCount; }
javascript
{ "resource": "" }
q58688
validation
function( word, locale ) { var syllableCount = 0; var fullWordExclusion = countFullWordDeviations( word, locale ); if ( fullWordExclusion !== 0 ) { return fullWordExclusion; } var partialExclusions = countPartialWordDeviations( word, locale ); word = partialExclusions.word; syllableCount += partialExclusions...
javascript
{ "resource": "" }
q58689
validation
function( text, locale ) { text = text.toLocaleLowerCase(); var words = getWords( text ); var syllableCounts = map( words, function( word ) { return countSyllablesInWord( word, locale ); } ); return sum( syllableCounts ); }
javascript
{ "resource": "" }
q58690
validation
function( array, language ) { if ( isUndefined( language ) || language === "" ) { language = "en"; } const functionWords = get( getFunctionWords, [ language ], [] ); if ( array.length > 1 ) { const arrayFiltered = filter( array, function( word ) { return ( ! includes( functionWords.all, word.trim().toLocal...
javascript
{ "resource": "" }
q58691
validation
function( keyphrase, synonyms, language = "en", morphologyData ) { const synonymsSplit = parseSynonyms( synonyms ); const keyphraseForms = buildForms( keyphrase, language, morphologyData ); const synonymsForms = synonymsSplit.map( synonym => buildForms( synonym, language, morphologyData ) ); return { keyphraseF...
javascript
{ "resource": "" }
q58692
collectForms
validation
function collectForms( keyphrase, synonyms, language = "en", morphologyData ) { const collectFormsWithMorphologyData = primeMorphologyData( morphologyData ); return collectFormsWithMorphologyData( keyphrase, synonyms, language ); }
javascript
{ "resource": "" }
q58693
research
validation
function research( paper, researcher ) { const language = getLanguage( paper.getLocale() ); const morphologyData = get( researcher.getData( "morphology" ), [ language ], false ); return collectForms( paper.getKeyword(), paper.getSynonyms(), language, morphologyData ); }
javascript
{ "resource": "" }
q58694
InvalidTypeError
validation
function InvalidTypeError( message ) { Error.captureStackTrace( this, this.constructor ); this.name = this.constructor.name; this.message = message; }
javascript
{ "resource": "" }
q58695
getRegexFromDoubleArray
validation
function getRegexFromDoubleArray( twoPartTransitionWords ) { const cacheKey = flattenDeep( twoPartTransitionWords ).join( "" ); if ( regexFromDoubleArrayCacheKey !== cacheKey || regexFromDoubleArray === null ) { regexFromDoubleArrayCacheKey = cacheKey; regexFromDoubleArray = createRegexFromDoubleArray( twoPartTra...
javascript
{ "resource": "" }
q58696
validation
function( sentence, twoPartTransitionWords ) { sentence = normalizeSingleQuotes( sentence ); const twoPartTransitionWordsRegex = getRegexFromDoubleArray( twoPartTransitionWords ); return sentence.match( twoPartTransitionWordsRegex ); }
javascript
{ "resource": "" }
q58697
validation
function( sentence, transitionWords ) { sentence = normalizeSingleQuotes( sentence ); return transitionWords.filter( word => matchWordInSentence( word, sentence ) ); }
javascript
{ "resource": "" }
q58698
validation
function( sentences, transitionWords ) { const results = []; sentences.forEach( sentence => { const twoPartMatches = matchTwoPartTransitionWords( sentence, transitionWords.twoPartTransitionWords() ); if ( twoPartMatches !== null ) { results.push( { sentence: sentence, transitionWords: twoPartMatches,...
javascript
{ "resource": "" }
q58699
getIndicesOfWords
validation
function getIndicesOfWords( text ) { const indices = []; const words = getWords( text ); let startSearchFrom = 0; words.forEach( function( word ) { const currentIndex = text.indexOf( word, startSearchFrom ); indices.push( currentIndex ); startSearchFrom = currentIndex + word.length; } ); return indices; }
javascript
{ "resource": "" }