Skip to content

Commit dc7c106

Browse files
committed
Move some files around
1 parent 87384fd commit dc7c106

File tree

10 files changed

+25
-35
lines changed

10 files changed

+25
-35
lines changed

src/components/tree/Tree.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ import sortBy from "lodash.sortby";
44
import StarImgage from "../vectors/StarImage";
55

66
import Reference from "./Reference";
7+
import { mostCommon } from "../../utils/arrays";
78
import { Article } from "../../utils/customTypes";
89

910
import "./Tree.css";
10-
import { mostCommon } from "../../utils/isiUtils";
1111

1212
interface Props {
1313
data: { [section: string]: Article[] };

src/components/upload/FileCard.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import React, { FC } from "react";
33
import CancelFile from "../vectors/CancelFile";
44
import MoveFirstIcon from "../vectors/MoveFirstIcon";
55

6-
import { round } from "../../utils/mathUtils";
6+
import { round } from "../../utils/math";
77
import { MAX_SIZE } from "../../utils/computeQuantities";
88

99
import "./FileCard.css";

src/components/upload/FileDropper.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ import React, { FC, useCallback } from "react";
22
import { useDropzone } from "react-dropzone";
33
import "./FileDropper.css";
44

5-
import { looksLikeIsi } from "../../utils/isiUtils";
6-
import { looksLikeScopus } from "../../utils/scopusUtils";
5+
import { looksLikeIsi } from "../../utils/isi";
6+
import { looksLikeScopus } from "../../utils/scopus";
77
import useUpload from "../../hooks/useUpload";
88
import useError from "../../hooks/useError";
99

src/components/upload/Home.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import useFiles from "../../hooks/useFiles";
1111
import FirebaseContext from "../../context/FirebaseContext";
1212

1313
import computeQuantities, { MAX_SIZE } from "../../utils/computeQuantities";
14-
import { round } from "../../utils/mathUtils";
14+
import { round } from "../../utils/math";
1515

1616
import "./Home.css";
1717

src/components/upload/UploadIndicator.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
import React, { FC, useContext, useEffect, useState } from "react";
2-
import "./UploadIndicator.css";
32

43
import FileCard from "./FileCard";
54
import FileContext from "../../context/FileContext";
65
import useFiles from "../../hooks/useFiles";
76
import { MAX_SIZE } from "../../utils/computeQuantities";
87

8+
import "./UploadIndicator.css";
9+
910
interface Props {}
1011

1112
const UploadIndicator: FC<Props> = () => {

src/utils/arrays.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
const mostCommon = (keywordsList: string[], max: number): string[] => {
2+
let count: { [keyword: string]: number } = {};
3+
for (let keyword of keywordsList) {
4+
count[keyword] = (count[keyword] ? count[keyword] : 0) + 1;
5+
}
6+
const sortCount = Object.entries(count).sort((first, second) =>
7+
first[1] < second[1] ? 1 : -1
8+
);
9+
return sortCount.slice(0, max).map((item) => item[0]);
10+
};
11+
12+
export { mostCommon };

src/utils/isiUtils.tsx renamed to src/utils/isi.ts

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -30,22 +30,6 @@ const keywords = (text: string): string[] => {
3030
.flat();
3131
};
3232

33-
function mostCommon(keywordsList: string[], max: number): string[] {
34-
let count: { [keyword: string]: number } = {};
35-
for (let keyword of keywordsList) {
36-
count[keyword] = (count[keyword] ? count[keyword] : 0) + 1;
37-
}
38-
const sortCount = Object.entries(count).sort((first, second) =>
39-
first[1] < second[1] ? 1 : -1
40-
);
41-
return sortCount.slice(0, max).map((item) => item[0]);
42-
}
43-
44-
const mostCommonKeywords = (text: string, max: number = 3) => {
45-
const keywordsList = keywords(text);
46-
return mostCommon(keywordsList, max);
47-
};
48-
4933
const countArticles = (text: string): number => {
5034
const identifier = "PT ";
5135
return text.split("\n").filter((line) => line.startsWith(identifier)).length;
@@ -60,12 +44,4 @@ const countReferences = (text: string): number => {
6044
.reduce((n, m) => n + m, 0);
6145
};
6246

63-
export {
64-
ISI_PATTERN,
65-
looksLikeIsi,
66-
keywords,
67-
mostCommonKeywords,
68-
mostCommon,
69-
countArticles,
70-
countReferences,
71-
};
47+
export { ISI_PATTERN, looksLikeIsi, keywords, countArticles, countReferences };
File renamed without changes.

src/utils/metadata.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { FileMetadata } from "./customTypes";
2-
import * as isi from "./isiUtils";
3-
import * as scopus from "./scopusUtils";
2+
import { mostCommon } from "./arrays";
3+
import * as isi from "./isi";
4+
import * as scopus from "./scopus";
45
import md5 from "md5";
56

67
const metadata = async (name: string, blob: Blob): Promise<FileMetadata> => {
@@ -12,7 +13,7 @@ const metadata = async (name: string, blob: Blob): Promise<FileMetadata> => {
1213
name,
1314
blob,
1415
hash,
15-
keywords: isi.mostCommon(isi.keywords(content), 3),
16+
keywords: mostCommon(isi.keywords(content), 3),
1617
articles: isi.countArticles(content),
1718
citations: isi.countReferences(content),
1819
valid: true,
@@ -24,7 +25,7 @@ const metadata = async (name: string, blob: Blob): Promise<FileMetadata> => {
2425
name,
2526
blob,
2627
hash,
27-
keywords: isi.mostCommon(scopus.keywords(content), 3),
28+
keywords: mostCommon(scopus.keywords(content), 3),
2829
articles: scopus.countArticles(content),
2930
citations: scopus.countReferences(content),
3031
valid: true,
File renamed without changes.

0 commit comments

Comments
 (0)