Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

academia

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

academia - npm Package Compare versions

Comparing version 0.1.0 to 0.1.1

tmp/index.d.ts

142

academia.d.ts
declare module "academia" {
import academia = require('index');
export = academia;
module styles {
module acl {
function stringifyNames(names: string[]): string;
const citeRegExp: RegExp;
/**
Given the text of a paper, extract the `Cite`s using regular expressions.
*/
function parseCites(body: string): types.AuthorYearCite[];
/**
Given a list of strings representing individual references in a bibliography,
parse each one into a Reference structure.
*/
function parseReferences(references: string[]): types.Reference[];
/**
In-place modifies `cites` by setting the `reference` value of each one where
a unique match from `references` is found.
TODO: handle multiple matches somehow.
*/
function linkCites(cites: types.AuthorYearCite[], references: types.Reference[]): void;
}
}
module names {
/**
1. Typical list of 3+
'David Mimno, Hanna M Wallach, and Andrew McCallum' ->
['David Mimno', 'Hanna M Wallach', 'Andrew McCallum']
2. List of 3+ without the Oxford comma, in case that ever happens
'Aravind K Joshi, Ben King and Steven Abney' ->
['David Mimno', 'Hanna M Wallach', 'Andrew McCallum']
3. Duo
'Daniel Ramage and Chris Callison-Burch' ->
['David Mimno', 'Chris Callison-Burch']
4. Single author
'David Sankofl' ->
['David Sankofl']
5. Et al. abbreviation
'Zhao et al.' ->
['Zhao', 'et al.']
*/
function splitNames(input: string): string[];
/**
Typically, in-paper citations (`Cite`s) only have the last names of the authors,
while the `Reference`s in the Bibliography have full names, or at least first
initials and last names.
This method determines whether a `Cite`'s names match a `Reference`'s authors.
authorsMatch(['Joshi'], ['Aravind K Joshi']) -> true
authorsMatch(['Diab', 'Kamboj'], ['Mona Diab', 'Ankit Kamboj']) -> true
'et al.' gets special treatment. 'et al.' is a match if and only if there are
more reference authors beyond the one parallel to the 'et al.' citation author.
In other words, 'et al.' cannot stand in for a single author.
authorsMatch(['Blei', 'et al.'], ['David M Blei', 'Andrew Y Ng', 'Michael I Jordan']) -> true
*/
function authorsMatch(citeAuthors: types.Name[], referenceAuthors: types.Name[]): boolean;
/**
Given a name represented by a single string, parse it into first name, middle
name, and last name.
parseAuthor('Leonardo da Vinci') -> { first: 'Leonardo', last: 'da Vinci' }
parseAuthor('Chris Callison-Burch') -> { first: 'Chris', last: 'Callison-Burch' }
parseAuthor('Hanna M Wallach') -> { first: 'Hanna', middle: 'M', last: 'Wallach' }
parseAuthor('Zhou') -> { last: 'Zhou' }
parseAuthor('McCallum, Andrew') -> { first: 'Andrew', last: 'McCallum' }
*/
function parseName(input: string): types.Name;
}
module types {
/**
Textual: Brown (2015)
Parenthetical: (Brown 2015)
Alternate: Brown 2015
*/
enum CiteStyle {
Textual = 0,
Parenthetical = 1,
Alternate = 2,
}
/**
Cite: in-paper reference to an article listed in the Bibliography.
*/
interface Cite {
/** the style of citation */
style: CiteStyle;
/** the location within the paper */
range?: [number, number];
/** the full reference it matches */
reference?: Reference;
}
interface AuthorYearCite extends Cite {
/** usually only last names, one of which may be 'et al.' */
authors: Name[];
/** not necessarily a number, if there is a letter suffix */
year: string;
}
interface Name {
first?: string;
middle?: string;
last: string;
}
/**
Reference: an article as listed in a Bibliography. This means that the authors
may be truncated, the year may include a suffix (for disambiguation), and other
fields may include abbreviations.
*/
interface Reference {
/** not always full names */
authors: Name[];
year: string;
title: string;
/** journal / specific conference / website; may be abbreviated */
venue?: string;
/** company name / conference */
publisher?: string;
pages?: [number, number];
}
interface Section {
/** 'title' could also be called 'header' */
title: string;
paragraphs: string[];
}
/**
Paper: a representation of any kind of academic paper / conference
presentation / manuscript. This preserves no formatting beyond sections /
paragraph distinctions.
`sections` is a flat list; abstracts / subsections / references all count at
the same level.
*/
interface Paper {
title?: string;
authors?: Name[];
year?: number;
sections: Section[];
references?: Reference[];
}
}
}

41

index.js

@@ -72,3 +72,3 @@ var academia;

a unique match from `references` is found.
TODO: handle multiple matches somehow.

@@ -89,16 +89,2 @@ */

})(styles = academia.styles || (academia.styles = {}));
var types;
(function (types) {
/**
Textual: Brown (2015)
Parenthetical: (Brown 2015)
Alternate: Brown 2015
*/
(function (CiteStyle) {
CiteStyle[CiteStyle["Textual"] = 0] = "Textual";
CiteStyle[CiteStyle["Parenthetical"] = 1] = "Parenthetical";
CiteStyle[CiteStyle["Alternate"] = 2] = "Alternate";
})(types.CiteStyle || (types.CiteStyle = {}));
var CiteStyle = types.CiteStyle;
})(types = academia.types || (academia.types = {}));
var names;

@@ -133,12 +119,12 @@ (function (names) {

initials and last names.
This method determines whether a `Cite`'s names match a `Reference`'s authors.
authorsMatch(['Joshi'], ['Aravind K Joshi']) -> true
authorsMatch(['Diab', 'Kamboj'], ['Mona Diab', 'Ankit Kamboj']) -> true
'et al.' gets special treatment. 'et al.' is a match if and only if there are
more reference authors beyond the one parallel to the 'et al.' citation author.
In other words, 'et al.' cannot stand in for a single author.
authorsMatch(['Blei', 'et al.'], ['David M Blei', 'Andrew Y Ng', 'Michael I Jordan']) -> true

@@ -161,3 +147,3 @@ */

name, and last name.
parseAuthor('Leonardo da Vinci') -> { first: 'Leonardo', last: 'da Vinci' }

@@ -179,2 +165,3 @@ parseAuthor('Chris Callison-Burch') -> { first: 'Chris', last: 'Callison-Burch' }

var n = parts.length;
// 3. TODO: handle 'van', 'von', 'da', etc.
if (n >= 3) {

@@ -199,3 +186,17 @@ return {

})(names = academia.names || (academia.names = {}));
var types;
(function (types) {
/**
Textual: Brown (2015)
Parenthetical: (Brown 2015)
Alternate: Brown 2015
*/
(function (CiteStyle) {
CiteStyle[CiteStyle["Textual"] = 0] = "Textual";
CiteStyle[CiteStyle["Parenthetical"] = 1] = "Parenthetical";
CiteStyle[CiteStyle["Alternate"] = 2] = "Alternate";
})(types.CiteStyle || (types.CiteStyle = {}));
var CiteStyle = types.CiteStyle;
})(types = academia.types || (academia.types = {}));
})(academia || (academia = {}));
module.exports = academia;

@@ -1,2 +0,2 @@

import * as types from './types';
import types = require('./types');

@@ -3,0 +3,0 @@ /**

@@ -11,3 +11,3 @@ {

],
"version": "0.1.0",
"version": "0.1.1",
"homepage": "https://github.com/chbrown/academia",

@@ -17,4 +17,3 @@ "repository": "git://github.com/chbrown/academia.git",

"license": "MIT",
"dependencies": {
},
"dependencies": {},
"devDependencies": {

@@ -21,0 +20,0 @@ "mocha": "*",

@@ -1,3 +0,3 @@

import * as types from '../types';
import * as names from '../names';
import types = require('../types');
import names = require('../names');

@@ -4,0 +4,0 @@ export function stringifyNames(names: string[]): string {

@@ -17,9 +17,5 @@ // the original text from the paper (for debugging)

import academia = require('styles/acl.d.ts');
import academia = require('styles/acl');
export = academia;
find . -name "*.ts" -type f > typescript-src.txt
tsc @typescript-src.txt --module commonjs --out ./build.js
// export import types = require('./types');

@@ -32,18 +28,2 @@ export import * as academia_types from './types';

// module academia {
// console.log('hello');
// export var types = types;
// export var names = names;
// export var styles = styles;
// }
/// <reference path="types.d.ts" />
/// <reference path="names.d.ts" />
import types = require('types');
declare module 'academia' {
export var types: types;
}
import {CiteStyle, AuthorYearCite, Reference} from '../types';

@@ -81,1 +61,50 @@ import {splitNames, parseName, authorsMatch} from '../names';

/**
names can vary a lot;
1: Maxwell
2: Bendersky
Bendersky and Croft
Bendersky et al.
3. Shen
Shen et al.
(Song et al., 2008)
Lin and Pantel (2001)
*/
getPatterns(): string[] {
var year = this.paper.year;
var lastNames = (this.paper.author || '').split(/\s+and\s+/).map(getLastName);
var names = [lastNames[0]];
if (lastNames.length > 1) {
names.push(`${lastNames[0]} et al.`);
}
if (lastNames.length === 2) {
names.push(`${lastNames[0]} and ${lastNames[1]}`);
}
var patternss = names.map(name => {
// "Brown, 2015" & "Brown (2015)"
return [`${name}, ${year}`, `${name} (${year})`].map(unorm.nfkc);
});
return Array.prototype.concat.apply([], patternss);
}
.PHONY: all clean
all:
%.js: %.ts
node_modules/.bin/tsc -m commonjs -t ES5 $<
clean:
rm -f $(TYPESCRIPT:%.ts=%.js)
rm -f $(TYPESCRIPT:%.ts=%.d.ts)
build.js:
tsc --module commonjs --target ES5 --declaration index.ts
// var dts_string =
// console.log(dts_string);

@@ -73,2 +73,4 @@ /**

sections: Section[];
// analysis
references?: Reference[];
}

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc