Giter Club home page Giter Club logo

softconcoursecord19's Introduction

SoftConcourseCORD19

WebApp for filtering and searching CORD19 titles and abstracts in MeSH contexts

softconcoursecord19's People

Contributors

kerwizzy avatar forrestcavalier avatar

Watchers

 avatar  avatar

softconcoursecord19's Issues

Improve search term syntax support

Rudimentary implementation of OR and AND is supported, but there should be support for parenthesis.
And less usefully, it would be good to have support for double quotes.

The way splitWords() works is by creating an array of strings that are either punctuation or alphanumeric, starting with punctuation. (If there is no prefix punctuation, the first element will be blank.) Adjacent punctuation is combined into one element.

The first change for better syntax support is to alter the way splitWords (and callers) work, to be more of a tokenizer for punctuation: we want each punctuation character to be in its own string element. That will require placing empty string elements for text in between adjacent punctuation, and some callers will need to be adapted for this change.

Both before and after this intermediate change, everything should work as before, and splitWords(s,0).join('') is always supposed to == s.

Update splitWords and callers to support highlighting of matches.

I refactored splitWords() in a companion parser in order to support highlighting. Callers have to be updated. Anything that used to have a second argument of false, needs a second argument of -1. Anything that had a second argument of true, needs a second argument of 1.

function splitWords(phrase, iCase)
{
	var words = [];
	var p = 0;
	var lastp =0;
	var wordchars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-";
	while(p < phrase.length) {
		lastp = p;
		while (p < phrase.length) {
			var code = phrase.charCodeAt(p);
			if (code >= 0x41) {
				if (code <= 0x5a) {
				} else if (code >= 0x61 && code <= 0x7a) {
				} else {
					break;
				}
			} else if (code <= 0x39) {
				if (code >= 0x30 || code == 0x2d) {
				} else {
					break;
				}
			}
			p++;
		}

		if (lastp == 0) {
			words.push("");
		}
		if (p > lastp) {
			/* Got a string of alphanumerics */
			if (words.length > 1 && (words[words.length-1]=="'" || words[words.length-1]=="โ€™")) {
				/* Contraction */
				var prev = words[words.length-2];
				if (phrase.substr(lastp,p-lastp).toLowerCase() == 't') {
					if (prev.substr(prev.length-1).toLowerCase() == 'n') {
						words[words.length-2] = prev.substr(0,prev.length-1);
						lastp -= 2;
					}
					words.push(phrase.substr(lastp,p-lastp).toLowerCase());
					words.push("");
				} else {
					words.push(phrase.substr(lastp,p-lastp).toLowerCase());
					words.push("");
				}
			} else {
				word = phrase.substr(lastp,p-lastp).toLowerCase();
				if (iCase==1 && (word == 'or' || word == 'and')) {/* DEBUG: if not in double-quotes */
					words.push(word.toUpperCase());
				} else if (iCase == 0) {
					words.push(phrase.substr(lastp,p-lastp));
				} else {
					words.push(word.toLowerCase());
				}
				words.push("");
			}
		}
		if (p < phrase.length) {
			/* Punctuation */
			words[words.length-1] += phrase.substr(p,1);
		}
		p++;
	}
	//WScript.Echo("I-90 " + words.join(';'));
	return words;
}

That allows usage for highlighting like this:

                        var terms = splitWords(filterText,1); // Leave OR and AND as special.
			var positions = wordsMatchTerms(splitWords(s,-1), terms); //Get indices
			if (positions) {
				var highlighted = splitWords(s,0);
				positions.forEach(i => { highlighted[i] = '<b>' + highlighted[i] + "</b>"});
				//Use highlighted.join('').
			}

Show counts by years

With the move to date selectors, we lost the indication of article counts by years. Under the date selectors, show year and count of at least the last 10 years.

Lock Pub. Type. column width

The Pub. Type. Column width should be fixed so that it does not change size when the results are updated or abstracts are shown.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.