Erste analysen
This commit is contained in:
@@ -0,0 +1,125 @@
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParser;
|
||||
import com.mongodb.*;
|
||||
|
||||
public class DoneAnalyzes {
|
||||
|
||||
DBCollection collectionPatent;
|
||||
DBCollection collectionDocument;
|
||||
|
||||
DoneAnalyzes() {
|
||||
MongoClient mongo = new MongoClient(new MongoClientURI(Settings.MONGOURL.getContent()));
|
||||
DB mongoDB = mongo.getDB(Settings.DBANALYZES.getContent());
|
||||
collectionPatent = mongoDB.getCollection(Settings.COLLECTIONANALYZEPATENT.getContent());
|
||||
collectionDocument = mongoDB.getCollection(Settings.COLLECTIONANALYZEDOCUMENT.getContent());
|
||||
}
|
||||
|
||||
public boolean isAnalyzed(FilterBuilderDocument doc, FilterBuilderPatent pat) {
|
||||
if (doc != null) {
|
||||
JsonObject test = getAnalyzeDocument(doc);
|
||||
if (test.get("SearchInvalid") != null) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (pat != null) {
|
||||
JsonObject test = getAnalyzePatent(pat);
|
||||
if (test.get("SearchInvalid") != null) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (doc == null && pat == null) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
public JsonObject getAnalyzePatent(FilterBuilderPatent pat) {
|
||||
BasicDBObject search = new BasicDBObject();
|
||||
if (pat.build().isEmpty()) {
|
||||
search.put("Search", new FilterBuilderDocument().build().toJson());
|
||||
} else {
|
||||
search.put("Search", pat.build().toJson());
|
||||
}
|
||||
DBCursor cursor = collectionPatent.find(search);
|
||||
if (cursor == null) {
|
||||
JsonObject toReturn = new JsonObject();
|
||||
toReturn.addProperty("SearchInvalid", "");
|
||||
return toReturn;
|
||||
}
|
||||
BasicDBObject result = null;
|
||||
if (cursor.hasNext()) {
|
||||
result = (BasicDBObject) cursor.next();
|
||||
}
|
||||
JsonParser parser = new JsonParser();
|
||||
JsonObject toReturn;
|
||||
if (result == null) {
|
||||
toReturn = new JsonObject();
|
||||
toReturn.addProperty("SearchInvalid", "");
|
||||
} else {
|
||||
toReturn = (JsonObject) parser.parse(result.toJson());
|
||||
toReturn.remove("_id");
|
||||
}
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public JsonObject getAnalyzeDocument(FilterBuilderDocument doc) {
|
||||
BasicDBObject search = new BasicDBObject();
|
||||
if (doc.build().isEmpty()) {
|
||||
search.put("Search", new FilterBuilderDocument().build().toJson());
|
||||
} else {
|
||||
search.put("Search", doc.build().toJson());
|
||||
}
|
||||
DBCursor cursor = collectionDocument.find(search);
|
||||
if (cursor == null) {
|
||||
JsonObject toReturn = new JsonObject();
|
||||
toReturn.addProperty("SearchInvalid", "");
|
||||
return toReturn;
|
||||
}
|
||||
BasicDBObject result = null;
|
||||
if (cursor.hasNext()) {
|
||||
result = (BasicDBObject) cursor.next();
|
||||
}
|
||||
JsonParser parser = new JsonParser();
|
||||
JsonObject toReturn;
|
||||
if (result == null) {
|
||||
toReturn = new JsonObject();
|
||||
toReturn.addProperty("SearchInvalid", "");
|
||||
} else {
|
||||
toReturn = (JsonObject) parser.parse(result.toJson());
|
||||
toReturn.remove("_id");
|
||||
}
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public void addPatentAnalyze(FilterBuilderPatent pat, String key, String value) {
|
||||
JsonObject obj = getAnalyzePatent(pat);
|
||||
BasicDBObject toRemove = (BasicDBObject) com.mongodb.util.JSON.parse(obj.toString());
|
||||
collectionPatent.remove(toRemove);
|
||||
obj.addProperty(key, value);
|
||||
BasicDBObject toAdd = (BasicDBObject) com.mongodb.util.JSON.parse(obj.toString());
|
||||
if (toAdd.get("SearchInvalid") != null) {
|
||||
toAdd.remove("SearchInvalid");
|
||||
toAdd.put("Search", pat.build().toJson());
|
||||
}
|
||||
collectionPatent.insert(toAdd);
|
||||
}
|
||||
|
||||
public void addDocumentAnalyze(FilterBuilderDocument doc, String key, String value) {
|
||||
JsonObject obj = getAnalyzeDocument(doc);
|
||||
BasicDBObject toRemove = (BasicDBObject) com.mongodb.util.JSON.parse(obj.toString());
|
||||
collectionDocument.remove(toRemove);
|
||||
obj.addProperty(key, value);
|
||||
BasicDBObject toAdd = (BasicDBObject) com.mongodb.util.JSON.parse(obj.toString());
|
||||
if (toAdd.get("SearchInvalid") != null) {
|
||||
toAdd.remove("SearchInvalid");
|
||||
toAdd.put("Search", doc.build().toJson());
|
||||
}
|
||||
collectionDocument.insert(toAdd);
|
||||
}
|
||||
|
||||
public void deleteDocumentCollection() {
|
||||
collectionDocument.drop();
|
||||
}
|
||||
}
|
||||
@@ -26,11 +26,6 @@ public class FilterBuilderDocument {
|
||||
return this;
|
||||
}
|
||||
|
||||
public FilterBuilderDocument withPublicationYear(String var) {
|
||||
obj.put("PublicationYear", new BasicDBObject("$regex", ".*" + var + ".*").append("$options", "i"));
|
||||
return this;
|
||||
}
|
||||
|
||||
public FilterBuilderDocument withAuthorKeywords(String var) {
|
||||
obj.put("AuthorKeyword", new BasicDBObject("$regex", ".*" + var + ".*").append("$options", "i"));
|
||||
return this;
|
||||
@@ -41,6 +36,54 @@ public class FilterBuilderDocument {
|
||||
return this;
|
||||
}
|
||||
|
||||
public FilterBuilderDocument withResearchArea(String var) {
|
||||
obj.put("ResearchAreas", new BasicDBObject("$regex", ".*" + var + ".*").append("$options", "i"));
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
public FilterBuilderDocument bySearchString(String var) {
|
||||
if (var.contains("TS=('")) {
|
||||
String topic = var.substring(var.indexOf("TS=('") + 5);
|
||||
topic = topic.substring(0, topic.indexOf(')') - 1);
|
||||
this.withKeywords(topic);
|
||||
this.withAuthorKeywords(topic);
|
||||
this.withWosCategory(topic);
|
||||
return this;
|
||||
}
|
||||
|
||||
if (var.contains("AK=('")) {
|
||||
String search = var.substring(var.indexOf("AK=('") + 5);
|
||||
search = search.substring(0, search.indexOf(')') - 1);
|
||||
this.withAuthorKeywords(search);
|
||||
}
|
||||
|
||||
if (var.contains("Year=('")) {
|
||||
String search = var.substring(var.indexOf("Year=('") + 5);
|
||||
search = search.substring(0, search.indexOf(')') - 1);
|
||||
this.withYear(Integer.parseInt(search));
|
||||
}
|
||||
|
||||
if (var.contains("KP=('")) {
|
||||
String search = var.substring(var.indexOf("KP=('") + 5);
|
||||
search = search.substring(0, search.indexOf(')') - 1);
|
||||
this.withKeywords(search);
|
||||
}
|
||||
|
||||
if (var.contains("SU=('")) {
|
||||
String search = var.substring(var.indexOf("SU=('") + 5);
|
||||
search = search.substring(0, search.indexOf(')') - 1);
|
||||
this.withResearchArea(search);
|
||||
}
|
||||
|
||||
if (var.contains("WC=('")) {
|
||||
String search = var.substring(var.indexOf("WC=('") + 5);
|
||||
search = search.substring(0, search.indexOf(')') - 1);
|
||||
this.withWosCategory(search);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public BasicDBObject build() {
|
||||
return obj;
|
||||
}
|
||||
|
||||
@@ -27,7 +27,16 @@ public class FilterBuilderPatent {
|
||||
}
|
||||
|
||||
public FilterBuilderPatent withYear(int var) {
|
||||
obj.put("Year", var);
|
||||
obj.put("Year", String.valueOf(var));
|
||||
return this;
|
||||
}
|
||||
|
||||
public FilterBuilderPatent bySearchString(String var) {
|
||||
if (var.contains("Classification=('")) {
|
||||
String search = var.substring(var.indexOf("Classification=('") + 17);
|
||||
search = search.substring(0, search.indexOf(')') - 1);
|
||||
this.withClassification(search);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
+17
-6
@@ -2,13 +2,13 @@ public class Main {
|
||||
|
||||
public static void main(String[] args) {
|
||||
//Crawler
|
||||
startUSPTOCrawler();
|
||||
startWOSCrawler();
|
||||
getCPC();
|
||||
//startUSPTOCrawler();
|
||||
//startWOSCrawler();
|
||||
//getCPC();
|
||||
|
||||
//Importer
|
||||
startUSPTOImport();
|
||||
startWOSImport();
|
||||
//startWOSImport();
|
||||
}
|
||||
|
||||
private static void getCPC() {
|
||||
@@ -38,7 +38,7 @@ public class Main {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
new PatentCrawler(1976, 2000);
|
||||
new PatentCrawler(1976, 2020);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@@ -55,7 +55,7 @@ public class Main {
|
||||
|
||||
private static void startUSPTOImport() {
|
||||
if (Settings.USPTSTARTIMPORT.getContent().equals("YES")) {
|
||||
new PatentImporter(2019, 2019);
|
||||
new PatentImporter().importYear(2018, 2020);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -93,4 +93,15 @@ public class Main {
|
||||
}
|
||||
}
|
||||
|
||||
private static void shutdown() {
|
||||
try {
|
||||
Runtime runtime = Runtime.getRuntime();
|
||||
Process proc = runtime.exec("shutdown -s -t 0");
|
||||
System.exit(0);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ public class PatentImporter {
|
||||
private MongoClient mongo;
|
||||
private DB mongoDB;
|
||||
|
||||
public PatentImporter(int startYear, int endYear) {
|
||||
public PatentImporter() {
|
||||
path = Settings.PATHTODOWNLOADPATENTS.getContent();
|
||||
mongo = new MongoClient(new MongoClientURI(Settings.MONGOURL.getContent()));
|
||||
mongoDB = mongo.getDB(Settings.DBPATENT.getContent());
|
||||
@@ -23,12 +23,11 @@ public class PatentImporter {
|
||||
collection = mongoDB.getCollection(Settings.COLLECTIONPATENT.getContent());
|
||||
//collection.createIndex(new BasicDBObject("DOI",1),"DOI",true);
|
||||
}
|
||||
importYear(startYear, endYear);
|
||||
}
|
||||
|
||||
public void importYear(int startYear, int endYear) {
|
||||
int todaysYear = Calendar.getInstance().get(Calendar.YEAR);
|
||||
if (endYear < todaysYear) {
|
||||
if (endYear > todaysYear) {
|
||||
endYear = todaysYear;
|
||||
}
|
||||
if (startYear < 1976) {
|
||||
@@ -44,6 +43,7 @@ public class PatentImporter {
|
||||
|
||||
private void importYear(int year) {
|
||||
unzip(year);
|
||||
System.out.println("Current Year: " + year);
|
||||
saveTXTToDB(year);
|
||||
}
|
||||
|
||||
@@ -63,11 +63,115 @@ public class PatentImporter {
|
||||
if (name.contains("xml")) {
|
||||
saveNewerXML(files[i]);
|
||||
}
|
||||
|
||||
if (name.contains("sgm")) {
|
||||
saveSGMFile(files[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void saveSGMFile(File file) {
|
||||
boolean documentId = false;
|
||||
boolean citedByExaminer = false;
|
||||
BasicDBObject patent = null;
|
||||
try (BufferedReader br = new BufferedReader(new FileReader(file))) {
|
||||
String line;
|
||||
|
||||
while ((line = br.readLine()) != null) {
|
||||
//Neues Patent
|
||||
if (line.contains("<!DOCTYPE PATDOC")) {
|
||||
if (patent != null) {
|
||||
collection.insert(patent);
|
||||
}
|
||||
patent = new BasicDBObject();
|
||||
}
|
||||
|
||||
//Titel
|
||||
if (line.contains("<B540><STEXT><PDAT>")) {
|
||||
int start = line.indexOf("<B540><STEXT><PDAT>") + 19;
|
||||
int end = line.indexOf("</");
|
||||
String title = null;
|
||||
if (end == -1) {
|
||||
|
||||
title = line.substring(start);
|
||||
} else {
|
||||
title = line.substring(start, end);
|
||||
|
||||
}
|
||||
String titleAlreadyExisting = "";
|
||||
|
||||
if (patent.getString("Text") == null) {
|
||||
|
||||
} else {
|
||||
titleAlreadyExisting = patent.getString("Text");
|
||||
}
|
||||
patent.append("Text", titleAlreadyExisting + " " + title);
|
||||
}
|
||||
|
||||
|
||||
if (line.contains("<category>cited by examiner</category>")) {
|
||||
citedByExaminer = true;
|
||||
}
|
||||
|
||||
//Classifiaction
|
||||
if (line.contains("<B582><PDAT>")) {
|
||||
int start = line.indexOf("<B582><PDAT>") + 12;
|
||||
int end = line.indexOf("</");
|
||||
String title = null;
|
||||
if (end == -1) {
|
||||
|
||||
title = line.substring(start);
|
||||
} else {
|
||||
title = line.substring(start, end);
|
||||
|
||||
}
|
||||
String titleAlreadyExisting = "";
|
||||
|
||||
if (patent.getString("Classification") == null) {
|
||||
|
||||
} else {
|
||||
titleAlreadyExisting = patent.getString("Classification");
|
||||
}
|
||||
patent.append("Classification", titleAlreadyExisting + " ; " + title);
|
||||
}
|
||||
|
||||
if (line.contains("<document-id>")) {
|
||||
documentId = true;
|
||||
}
|
||||
|
||||
if (line.contains("</documentId>")) {
|
||||
documentId = false;
|
||||
}
|
||||
|
||||
//Application Filing Year
|
||||
if (line.contains("<B220><DATE><PDAT>")) {
|
||||
String year = line.substring(18, 22);
|
||||
if (patent.getString("Year") != null) {
|
||||
continue;
|
||||
}
|
||||
patent.put("Year", year);
|
||||
}
|
||||
|
||||
//Country
|
||||
if (line.contains("<country>") && documentId == true) {
|
||||
String country = line.substring(9, line.lastIndexOf("</"));
|
||||
if (patent.getString("Country") != null) {
|
||||
continue;
|
||||
}
|
||||
patent.put("Country", country);
|
||||
}
|
||||
}
|
||||
collection.insert(patent);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (Settings.DELETEFILEAFTEIMPORT.getContent().equals("YES")) {
|
||||
file.delete();
|
||||
}
|
||||
}
|
||||
|
||||
private void saveNewerXML(File file) {
|
||||
|
||||
boolean prevLineAdress = false;
|
||||
@@ -79,6 +183,11 @@ public class PatentImporter {
|
||||
|
||||
while ((line = br.readLine()) != null) {
|
||||
|
||||
if (line.contains("<!DOCTYPE PATDOC")) {
|
||||
saveSGMFile(file);
|
||||
return;
|
||||
}
|
||||
|
||||
//Neues Patent
|
||||
if (line.contains("<us-patent-grant")) {
|
||||
if (patent != null) {
|
||||
@@ -207,8 +316,18 @@ public class PatentImporter {
|
||||
|
||||
//Application Filing Year
|
||||
if (line.contains("APD")) {
|
||||
String year = line.substring(5, 9);
|
||||
patent.put("Year", year);
|
||||
try {
|
||||
if (line.contains("*") || line.contains("\\0")) {
|
||||
patent.put("Year", "*");
|
||||
} else {
|
||||
String year = line.substring(5, 9);
|
||||
patent.put("Year", year);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
System.out.println(line);
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
collection.insert(patent);
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParser;
|
||||
import com.mongodb.*;
|
||||
|
||||
import java.util.Calendar;
|
||||
@@ -10,9 +12,11 @@ public class Queries {
|
||||
DBCollection collectionDocuments;
|
||||
private MongoClient mongo;
|
||||
private DB mongoDB;
|
||||
DoneAnalyzes analyzes;
|
||||
|
||||
|
||||
Queries() {
|
||||
analyzes = new DoneAnalyzes();
|
||||
mongo = new MongoClient(new MongoClientURI(Settings.MONGOURL.getContent()));
|
||||
mongoDB = mongo.getDB(Settings.DBPATENT.getContent());
|
||||
|
||||
@@ -20,7 +24,6 @@ public class Queries {
|
||||
collectionPatent = mongoDB.getCollection(Settings.COLLECTIONPATENT.getContent());
|
||||
} else {
|
||||
collectionPatent = mongoDB.getCollection(Settings.COLLECTIONPATENT.getContent());
|
||||
collectionPatent.createIndex(new BasicDBObject("DOI", 1), "DOI", true);
|
||||
}
|
||||
|
||||
mongoDB = mongo.getDB(Settings.DBDOCUMENT.getContent());
|
||||
@@ -38,15 +41,23 @@ public class Queries {
|
||||
}
|
||||
|
||||
public List<DBObject> getDocuments(BasicDBObject filter) {
|
||||
return collectionDocuments.find(filter).limit(2000).toArray();
|
||||
return collectionDocuments.find(filter).toArray();
|
||||
}
|
||||
|
||||
public JsonObject countSortedByYearDocuments() {
|
||||
public JsonObject countSortedByYearDocuments(FilterBuilderDocument document) {
|
||||
if (analyzes.isAnalyzed(document, null)) {
|
||||
String a = analyzes.getAnalyzeDocument(document).get("Years").getAsString();
|
||||
JsonParser parserJson = new JsonParser();
|
||||
return (JsonObject) parserJson.parse(a);
|
||||
}
|
||||
JsonObject json = new JsonObject();
|
||||
int currentYear = Calendar.getInstance().get(Calendar.YEAR);
|
||||
for (int i = 1976; i < currentYear; i++) {
|
||||
json.addProperty(String.valueOf(i), getCountDocuments(new FilterBuilderDocument().withYear(i)));
|
||||
for (int i = 1976; i <= currentYear; i++) {
|
||||
System.out.println("DocumentYear, CurrentYear:" + i);
|
||||
json.addProperty(String.valueOf(i), getCountDocuments(document.withYear(i)));
|
||||
}
|
||||
|
||||
analyzes.addDocumentAnalyze(document, "Years", json.toString());
|
||||
return json;
|
||||
}
|
||||
|
||||
@@ -55,17 +66,82 @@ public class Queries {
|
||||
}
|
||||
|
||||
public List<DBObject> getPatents(FilterBuilderPatent filter) {
|
||||
return collectionPatent.find(filter.build()).limit(2000).toArray();
|
||||
return collectionPatent.find(filter.build()).toArray();
|
||||
}
|
||||
|
||||
public JsonObject countSortedByYearPatents() {
|
||||
public JsonObject countSortedByYearPatents(FilterBuilderPatent patent) {
|
||||
if (analyzes.isAnalyzed(null, patent)) {
|
||||
String a = analyzes.getAnalyzePatent(patent).get("Years").getAsString();
|
||||
JsonParser parserJson = new JsonParser();
|
||||
return (JsonObject) parserJson.parse(a);
|
||||
}
|
||||
|
||||
JsonObject json = new JsonObject();
|
||||
int currentYear = Calendar.getInstance().get(Calendar.YEAR);
|
||||
for (int i = 1976; i < currentYear; i++) {
|
||||
json.addProperty(String.valueOf(i), getCountPatents(new FilterBuilderPatent().withYear(i)));
|
||||
for (int i = 1976; i <= currentYear; i++) {
|
||||
System.out.println("PatentYear, CurrentYear:" + i);
|
||||
json.addProperty(String.valueOf(i), getCountPatents(patent.withYear(i)));
|
||||
}
|
||||
analyzes.addPatentAnalyze(patent, "Years", json.toString());
|
||||
return json;
|
||||
}
|
||||
|
||||
public JsonObject countSortedByYearRelativePatents(FilterBuilderPatent patent) {
|
||||
if (analyzes.isAnalyzed(null, patent)) {
|
||||
JsonElement element = analyzes.getAnalyzePatent(patent).get("YearsRelative");
|
||||
if (element != null) {
|
||||
String a = element.getAsString();
|
||||
JsonParser parserJson = new JsonParser();
|
||||
return (JsonObject) parserJson.parse(a);
|
||||
}
|
||||
}
|
||||
|
||||
JsonObject json = countSortedByYearPatents(patent);
|
||||
JsonObject toReturn = new JsonObject();
|
||||
int thisYear = Calendar.getInstance().get(Calendar.YEAR);
|
||||
for (int i = 1977; i <= thisYear; i++) {
|
||||
double lastYear = json.get(String.valueOf(i - 1)).getAsInt();
|
||||
double currentYear = json.get(String.valueOf(i)).getAsInt();
|
||||
if (currentYear == 0) {
|
||||
toReturn.addProperty(String.valueOf(i), String.valueOf(0));
|
||||
} else {
|
||||
double value = lastYear / currentYear;
|
||||
toReturn.addProperty(String.valueOf(i), String.valueOf(value));
|
||||
}
|
||||
|
||||
}
|
||||
analyzes.addPatentAnalyze(patent, "YearsRelative", toReturn.toString());
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public JsonObject countSortedByYearRelativeDocuments(FilterBuilderDocument document) {
|
||||
|
||||
if (analyzes.isAnalyzed(document, null)) {
|
||||
JsonElement element = analyzes.getAnalyzeDocument(document).get("YearsRelative");
|
||||
if (element != null) {
|
||||
String a = element.getAsString();
|
||||
JsonParser parserJson = new JsonParser();
|
||||
return (JsonObject) parserJson.parse(a);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
JsonObject json = countSortedByYearDocuments(document);
|
||||
JsonObject toReturn = new JsonObject();
|
||||
int thisYear = Calendar.getInstance().get(Calendar.YEAR);
|
||||
for (int i = 1977; i <= thisYear; i++) {
|
||||
double lastYear = json.get(String.valueOf(i - 1)).getAsInt();
|
||||
double currentYear = json.get(String.valueOf(i)).getAsInt();
|
||||
if (currentYear == 0) {
|
||||
toReturn.addProperty(String.valueOf(i), String.valueOf(0));
|
||||
} else {
|
||||
double value = lastYear / currentYear;
|
||||
toReturn.addProperty(String.valueOf(i), String.valueOf(value));
|
||||
}
|
||||
}
|
||||
analyzes.addDocumentAnalyze(document, "YearsRelative", toReturn.toString());
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -10,11 +10,14 @@ import java.io.*;
|
||||
import java.net.InetSocketAddress;
|
||||
|
||||
public class Server {
|
||||
|
||||
|
||||
Server() {
|
||||
try {
|
||||
HttpServer server = HttpServer.create(new InetSocketAddress(8000), 0);
|
||||
server.createContext("/query", new QueryHandler());
|
||||
server.createContext("/searches", new SearchHandler());
|
||||
server.createContext("/analyze", new AnalyzeHandler());
|
||||
server.setExecutor(null);
|
||||
server.start();
|
||||
} catch (IOException e) {
|
||||
@@ -27,6 +30,112 @@ public class Server {
|
||||
//new WosCrawlerAndImporter();
|
||||
}
|
||||
|
||||
static class AnalyzeHandler implements HttpHandler {
|
||||
@Override
|
||||
public void handle(HttpExchange t) throws IOException {
|
||||
DoneAnalyzes analyzes = new DoneAnalyzes();
|
||||
|
||||
//Handlers
|
||||
this.setResponseHandlers(t);
|
||||
|
||||
//Response
|
||||
JsonObject resultJson = null;
|
||||
if (t.getRequestMethod().equals("OPTIONS")) {
|
||||
resultJson = new JsonObject();
|
||||
}
|
||||
|
||||
if (t.getRequestMethod().equals("POST")) {
|
||||
String s = t.getRequestHeaders().getFirst("Content-type");
|
||||
if (s.equals("application/json")) {
|
||||
InputStream inputStream = t.getRequestBody();
|
||||
BufferedInputStream bis = new BufferedInputStream(inputStream);
|
||||
ByteArrayOutputStream buf = new ByteArrayOutputStream();
|
||||
int result = bis.read();
|
||||
while (result != -1) {
|
||||
buf.write((byte) result);
|
||||
result = bis.read();
|
||||
}
|
||||
String json = buf.toString("UTF-8");
|
||||
|
||||
|
||||
try {
|
||||
JsonParser parser = new JsonParser();
|
||||
JsonObject jsonObject = (JsonObject) parser.parse(json);
|
||||
String search = jsonObject.get("Search").getAsString();
|
||||
String type = jsonObject.get("Type").getAsString();
|
||||
String filter = jsonObject.get("Filter").getAsString();
|
||||
Queries query = new Queries();
|
||||
if (type.equals("Document")) {
|
||||
if (search.equals("Years")) {
|
||||
if (filter.equals("None")) {
|
||||
FilterBuilderDocument doc = new FilterBuilderDocument();
|
||||
resultJson = query.countSortedByYearDocuments(doc);
|
||||
} else {
|
||||
FilterBuilderDocument doc = new FilterBuilderDocument().bySearchString(filter);
|
||||
resultJson = query.countSortedByYearDocuments(doc);
|
||||
}
|
||||
}
|
||||
|
||||
if (search.equals("YearsRelative")) {
|
||||
if (filter.equals("None")) {
|
||||
FilterBuilderDocument doc = new FilterBuilderDocument();
|
||||
resultJson = query.countSortedByYearRelativeDocuments(doc);
|
||||
} else {
|
||||
FilterBuilderDocument doc = new FilterBuilderDocument().bySearchString(filter);
|
||||
resultJson = query.countSortedByYearRelativeDocuments(doc);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (type.equals("Patent")) {
|
||||
if (search.equals("Years")) {
|
||||
if (filter.equals("None")) {
|
||||
FilterBuilderPatent pat = new FilterBuilderPatent();
|
||||
resultJson = query.countSortedByYearPatents(pat);
|
||||
} else {
|
||||
FilterBuilderPatent pat = new FilterBuilderPatent().bySearchString(filter);
|
||||
resultJson = query.countSortedByYearPatents(pat);
|
||||
}
|
||||
}
|
||||
|
||||
if (search.equals("YearsRelative")) {
|
||||
if (filter.equals("None")) {
|
||||
FilterBuilderPatent pat = new FilterBuilderPatent();
|
||||
resultJson = query.countSortedByYearRelativePatents(pat);
|
||||
} else {
|
||||
FilterBuilderPatent pat = new FilterBuilderPatent().bySearchString(filter);
|
||||
resultJson = query.countSortedByYearRelativePatents(pat);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
} catch (JsonException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
byte[] response = resultJson.toString().getBytes();
|
||||
t.sendResponseHeaders(200, response.length);
|
||||
OutputStream os = t.getResponseBody();
|
||||
os.write(response);
|
||||
os.flush();
|
||||
os.close();
|
||||
}
|
||||
|
||||
private void setResponseHandlers(HttpExchange t) {
|
||||
final Headers hds = t.getResponseHeaders();
|
||||
hds.set("Access-Control-Allow-Origin", "*");
|
||||
hds.set("Content-Type", "application/json");
|
||||
hds.set("Access-Control-Allow-Headers", "Access-Control-Allow-Methods, Content-Type, Access-Control-Allow-Origin");
|
||||
|
||||
hds.set("Access-Control-Allow-Methods", "POST");
|
||||
}
|
||||
}
|
||||
|
||||
static class SearchHandler implements HttpHandler {
|
||||
@Override
|
||||
|
||||
@@ -31,13 +31,13 @@ public enum Settings {
|
||||
//StartsDownload
|
||||
USPTSTARTDOWNLAOD("NO"),
|
||||
//Starts import
|
||||
USPTSTARTIMPORT("NO"),
|
||||
USPTSTARTIMPORT("YES"),
|
||||
//Automatically imports dowloaded Files while downlaoding
|
||||
AUTOMATEDIMPORT("NO"),
|
||||
//Deletes ZipFile after import
|
||||
DELETEZIPAFTERIMPORT("NO"),
|
||||
//Deletes TxtFile after import
|
||||
DELETEFILEAFTEIMPORT("NO"),
|
||||
DELETEFILEAFTEIMPORT("YES"),
|
||||
|
||||
|
||||
DBPATENT("Patent"),
|
||||
@@ -48,6 +48,10 @@ public enum Settings {
|
||||
COLLECTIONDONESEARCH("Done"),
|
||||
COLLECTONPENDINGSEARCH("Pending"),
|
||||
|
||||
DBANALYZES("Analyse"),
|
||||
COLLECTIONANALYZEPATENT("Patent"),
|
||||
COLLECTIONANALYZEDOCUMENT("Document"),
|
||||
|
||||
//Überspringt wait() --> Kann selbst fehler verursachen
|
||||
DEBUG("NO"),
|
||||
;
|
||||
|
||||
@@ -45,7 +45,12 @@ public class UnzipUtility {
|
||||
String filePath = destDirectory + File.separator + entry.getName();
|
||||
if (!entry.isDirectory()) {
|
||||
// if the entry is a file, extracts it
|
||||
extractFile(zipIn, filePath);
|
||||
if (filePath.contains(".sgm") || filePath.contains(".SGML")) {
|
||||
|
||||
} else {
|
||||
extractFile(zipIn, filePath);
|
||||
}
|
||||
|
||||
} else {
|
||||
// if the entry is a directory, make the directory
|
||||
File dir = new File(filePath);
|
||||
|
||||
@@ -0,0 +1,90 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8"/>
|
||||
<title>Analyse</title>
|
||||
<link href="commonStyles.css" rel="stylesheet">
|
||||
<link href="analyseStyles.css" rel="stylesheet">
|
||||
<script src="https://d3js.org/d3.v6.min.js"></script>
|
||||
<script src="https://d3js.org/d3-scale.v3.min.js"></script>
|
||||
<script defer src="yearsDocument.js"></script>
|
||||
<script defer src="yearsPatent.js"></script>
|
||||
<script defer src="yearsRelativeDocument.js"></script>
|
||||
<script defer src="yearsRelativePatent.js"></script>
|
||||
<script defer src="yearsRelativeComparison.js"></script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<script>
|
||||
console.log(window.sessionStorage.getItem("search"));
|
||||
|
||||
</script>
|
||||
<div class="container">
|
||||
<div class="nav-wrapper">
|
||||
<div class="left-side">
|
||||
<div class="nav-link-wrapper active-nav-link">
|
||||
<a href="index.html">Analyse</a>
|
||||
</div>
|
||||
|
||||
<div class="nav-link-wrapper">
|
||||
<a href="search.html">Suche</a>
|
||||
</div>
|
||||
|
||||
<div class="nav-link-wrapper">
|
||||
<a href="log.html">Logs</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<details id="documentDetails">
|
||||
<summary>Dokumente</summary>
|
||||
<details id="documentYearsDetails">
|
||||
<summary>Anzahl der Dokumente über die Jahre (Absolut)</summary>
|
||||
<div class="yearContainer" id="yearDocumentContainer">
|
||||
<div class="loader" id="yearsDocumentLoader"></div>
|
||||
<svg></svg>
|
||||
</div>
|
||||
</details>
|
||||
|
||||
<details id="documentYearsRelativeDetails">
|
||||
<summary>Anzahl der Dokumente über die Jahre (Relativ zum letztem Jahr)</summary>
|
||||
<div class="yearContainer" id="yearRelativeDocumentContainer">
|
||||
<div class="loader" id="yearsRelativeDocumentLoader"></div>
|
||||
<svg></svg>
|
||||
</div>
|
||||
</details>
|
||||
|
||||
</details>
|
||||
<details>
|
||||
<summary>Patente</summary>
|
||||
<details id="patentYearsDetails">
|
||||
<summary>Anzahl der Patente über die Jahre (Absolut)</summary>
|
||||
<div class="yearContainer" id="yearPatentContainer">
|
||||
<div class="loader" id="yearsPatentLoader"></div>
|
||||
<svg></svg>
|
||||
</div>
|
||||
</details>
|
||||
<details id="patentYearsRelativeDetails">
|
||||
<summary>Anzahl der Patente über die Jahre (Relativ zum letztem Jahr)</summary>
|
||||
<div class="yearContainer" id="yearRelativePatentContainer">
|
||||
<div class="loader" id="yearsRelativePatentLoader"></div>
|
||||
<svg></svg>
|
||||
</div>
|
||||
</details>
|
||||
</details>
|
||||
<details>
|
||||
<summary>Vergleich</summary>
|
||||
<details id=yearRelativeCompasionDetails>
|
||||
<summary>Vergleich der Anzahl basierend auf dem prozentualen Unterschied zum Vorjahr</summary>
|
||||
<div class="yearContainer" id="yearRelativeComparisonContainer">
|
||||
<div class="loader" id="yearsRelativeComparisonLoader"></div>
|
||||
<svg></svg>
|
||||
</div>
|
||||
</details>
|
||||
</details>
|
||||
|
||||
|
||||
</div>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
@@ -0,0 +1,6 @@
|
||||
.yearContainer {
|
||||
width: 100vw;
|
||||
height: 40vw;
|
||||
border-top: black 1px solid;
|
||||
border-bottom: black 1px solid;
|
||||
}
|
||||
@@ -49,4 +49,25 @@
|
||||
|
||||
.active-nav-link {
|
||||
border-bottom: 1px solid black;
|
||||
}
|
||||
}
|
||||
|
||||
details {
|
||||
padding: 15px;
|
||||
margin-bottom: 15px;
|
||||
}
|
||||
|
||||
.loader {
|
||||
border: 16px solid #f3f3f3; /* Light grey */
|
||||
border-top: 16px solid #3498db; /* Blue */
|
||||
border-radius: 50%;
|
||||
width: 120px;
|
||||
height: 120px;
|
||||
animation: spin 2s linear infinite;
|
||||
margin: auto;
|
||||
margin-top: 20%;
|
||||
}
|
||||
|
||||
@keyframes spin {
|
||||
0% { transform: rotate(0deg); }
|
||||
100% { transform: rotate(360deg); }
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
document.getElementById("submitAnalyse").onclick = function () { search() }
|
||||
|
||||
function search() {
|
||||
var searchString = document.getElementById("idSearchBar").value;
|
||||
if (searchString == "") {
|
||||
window.sessionStorage.setItem("search", "None");
|
||||
window.location.href = "analyse.html";
|
||||
}
|
||||
|
||||
var search = new String();
|
||||
|
||||
if (document.getElementById('checkBoxTopic').checked == true) {
|
||||
if (search.length > 0) {
|
||||
search = search + " OR ";
|
||||
}
|
||||
search = search + "TS=('" + searchString + "')"
|
||||
}
|
||||
|
||||
if (document.getElementById('checkBoxAK').checked == true) {
|
||||
if (search.length > 0) {
|
||||
search = search + " OR ";
|
||||
}
|
||||
search = search + "AK=('" + searchString + "')"
|
||||
}
|
||||
|
||||
if (document.getElementById('checkBoxKP').checked == true) {
|
||||
if (search.length > 0) {
|
||||
search = search + " OR ";
|
||||
}
|
||||
search = search + "KP=('" + searchString + "')"
|
||||
}
|
||||
|
||||
if (document.getElementById('checkBoxRA').checked == true) {
|
||||
if (search.length > 0) {
|
||||
search = search + " OR ";
|
||||
}
|
||||
search = search + "SU=('" + searchString + "')"
|
||||
}
|
||||
|
||||
if (document.getElementById('checkBoxWOSCategory').checked == true) {
|
||||
if (search.length > 0) {
|
||||
search = search + " OR ";
|
||||
}
|
||||
search = search + "WC=('" + searchString + "')"
|
||||
}
|
||||
|
||||
window.sessionStorage.setItem("search", search);
|
||||
|
||||
window.location.href = "analyse.html";
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -1,33 +1,31 @@
|
||||
xhrCurrent = new XMLHttpRequest();
|
||||
url ='http://localhost:8000/searches';
|
||||
xhrCurrent.open("POST",url,true);
|
||||
xhrCurrent.setRequestHeader('Access-Control-Allow-Methods','POST');
|
||||
xhrCurrent.setRequestHeader("Content-Type","application/json");
|
||||
xhrCurrent.onerror = function()
|
||||
{
|
||||
url = 'http://localhost:8000/searches';
|
||||
xhrCurrent.open("POST", url, true);
|
||||
xhrCurrent.setRequestHeader('Access-Control-Allow-Methods', 'POST');
|
||||
xhrCurrent.setRequestHeader("Content-Type", "application/json");
|
||||
xhrCurrent.onerror = function () {
|
||||
alert("Fehler");
|
||||
}
|
||||
xhrCurrent.onreadystatechange = function () {
|
||||
xhrCurrent.onreadystatechange = function () {
|
||||
if (xhrCurrent.readyState === 4 && xhrCurrent.status === 200) {
|
||||
var parent = document.getElementById("currentSearch");
|
||||
var child = parent.lastElementChild;
|
||||
while(child)
|
||||
{
|
||||
parent.removeChild(child);
|
||||
child = parent.lastElementChild;
|
||||
}
|
||||
var textField = document.createElement("p");
|
||||
var json = JSON.parse(xhrCurrent.response);
|
||||
var output = json.Search;
|
||||
textField.innerHTML = output;
|
||||
document.getElementById("currentSearch").appendChild(textField);
|
||||
}
|
||||
};
|
||||
var parent = document.getElementById("currentSearch");
|
||||
var child = parent.lastElementChild;
|
||||
while (child) {
|
||||
parent.removeChild(child);
|
||||
child = parent.lastElementChild;
|
||||
}
|
||||
var textField = document.createElement("p");
|
||||
var json = JSON.parse(xhrCurrent.response);
|
||||
var output = json.Search;
|
||||
textField.innerHTML = output;
|
||||
document.getElementById("currentSearch").appendChild(textField);
|
||||
}
|
||||
};
|
||||
|
||||
// Converting JSON data to string
|
||||
var data = JSON.stringify({ "Search" : "current"});
|
||||
var data = JSON.stringify({ "Search": "current" });
|
||||
|
||||
// Sending data with the request
|
||||
xhrCurrent.send(data);
|
||||
|
||||
xhrCurrent.send(data);
|
||||
|
||||
|
||||
|
||||
@@ -1,53 +1,49 @@
|
||||
xhrDone = new XMLHttpRequest();
|
||||
let url ='http://localhost:8000/searches';
|
||||
xhrDone.open("POST",url,true);
|
||||
xhrDone.setRequestHeader('Access-Control-Allow-Methods','POST');
|
||||
xhrDone.setRequestHeader("Content-Type","application/json");
|
||||
xhrDone.onerror = function()
|
||||
{
|
||||
let url = 'http://localhost:8000/searches';
|
||||
xhrDone.open("POST", url, true);
|
||||
xhrDone.setRequestHeader('Access-Control-Allow-Methods', 'POST');
|
||||
xhrDone.setRequestHeader("Content-Type", "application/json");
|
||||
xhrDone.onerror = function () {
|
||||
alert("Fehler");
|
||||
}
|
||||
xhrDone.onreadystatechange = function () {
|
||||
if (xhrDone.readyState === 4 && xhrDone.status === 200) {
|
||||
var parent = document.getElementById("doneSearches");
|
||||
var child = parent.lastElementChild;
|
||||
while(child)
|
||||
{
|
||||
parent.removeChild(child);
|
||||
child = parent.lastElementChild;
|
||||
}
|
||||
var resp = xhrDone.response;
|
||||
var json = JSON.parse(resp);
|
||||
var output = json.Search;
|
||||
var array = [];
|
||||
if(output == "")
|
||||
{
|
||||
return;
|
||||
}
|
||||
while(output.indexOf(';')!=-1)
|
||||
{
|
||||
var a = output.substring(0,output.indexOf(";")-1);
|
||||
output = output.substring(output.indexOf(";")+1);
|
||||
array.push(a.trim());
|
||||
}
|
||||
array.push(output.trim());
|
||||
for(var i = 0;i<array.length;i++)
|
||||
{
|
||||
var button = document.createElement("button");
|
||||
var text = array[i];
|
||||
button.innerText = text;
|
||||
document.getElementById("doneSearches").appendChild(button);
|
||||
button.addEventListener = function (text){
|
||||
//GOTO ANALYSIS
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
xhrDone.onreadystatechange = function () {
|
||||
if (xhrDone.readyState === 4 && xhrDone.status === 200) {
|
||||
var parent = document.getElementById("doneSearches");
|
||||
var child = parent.lastElementChild;
|
||||
while (child) {
|
||||
parent.removeChild(child);
|
||||
child = parent.lastElementChild;
|
||||
}
|
||||
var resp = xhrDone.response;
|
||||
var json = JSON.parse(resp);
|
||||
var output = json.Search;
|
||||
var array = [];
|
||||
if (output == "") {
|
||||
return;
|
||||
}
|
||||
while (output.indexOf(';') != -1) {
|
||||
var a = output.substring(0, output.indexOf(";") - 1);
|
||||
output = output.substring(output.indexOf(";") + 1);
|
||||
array.push(a.trim());
|
||||
}
|
||||
array.push(output.trim());
|
||||
for (var i = 0; i < array.length; i++) {
|
||||
var button = document.createElement("button");
|
||||
var text = array[i];
|
||||
button.innerText = text;
|
||||
document.getElementById("doneSearches").appendChild(button);
|
||||
button.onclick = function () {
|
||||
window.sessionStorage.setItem("search", button.textContent);
|
||||
location.href = "analyse.html";
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// Converting JSON data to string
|
||||
var data = JSON.stringify({ "Search" : "done"});
|
||||
var data = JSON.stringify({ "Search": "done" });
|
||||
|
||||
// Sending data with the request
|
||||
xhrDone.send(data);
|
||||
|
||||
xhrDone.send(data);
|
||||
|
||||
|
||||
|
||||
@@ -1,16 +1,21 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8"/>
|
||||
<title>Analyse</title>
|
||||
<title>Suche</title>
|
||||
<link href="commonStyles.css" rel="stylesheet">
|
||||
<link href="searchStyles.css" rel="stylesheet">
|
||||
<script defer src="currentSearch.js"></script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<div class="container">
|
||||
<div class="nav-wrapper">
|
||||
<div class="left-side">
|
||||
<div class="nav-link-wrapper active-nav-link">
|
||||
<a href="index.html">Analyse</a>
|
||||
<a href="analyse.html">Analyse</a>
|
||||
</div>
|
||||
|
||||
<div class="nav-link-wrapper">
|
||||
@@ -22,6 +27,52 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="search-wrapper">
|
||||
<div class="searchBar-wrapper">
|
||||
<div class="searchBar">
|
||||
<label>Suche: </label>
|
||||
<input id="idSearchBar" type="text">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="checkBoxes-wrapper">
|
||||
<div class="checkBoxes">
|
||||
<div class="checkBox">
|
||||
<label>Topic</label>
|
||||
<input id="checkBoxTopic" type="checkbox">
|
||||
</div>
|
||||
|
||||
<div class="checkBox">
|
||||
<label>Author Keywords</label>
|
||||
<input id="checkBoxAK" type="checkbox">
|
||||
</div>
|
||||
|
||||
<div class="checkBox">
|
||||
<label>Keywords Plus</label>
|
||||
<input id="checkBoxKP" type="checkbox">
|
||||
</div>
|
||||
|
||||
<div class="checkBox">
|
||||
<label>Research Area</label>
|
||||
<input id="checkBoxRA" type="checkbox">
|
||||
</div>
|
||||
|
||||
<div class="checkBox">
|
||||
<label>WoS Category</label>
|
||||
<input id="checkBoxWOSCategory" type="checkbox">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="submitSearch">
|
||||
<input id="submitAnalyse" type="submit" value="Starte Analyse">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
||||
@@ -1,10 +1,12 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8"/>
|
||||
<title>Analyse</title>
|
||||
<link href="commonStyles.css" rel="stylesheet">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="container">
|
||||
<div class="nav-wrapper">
|
||||
@@ -24,4 +26,5 @@
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
@@ -1,51 +1,46 @@
|
||||
xhrPending = new XMLHttpRequest();
|
||||
url ='http://localhost:8000/searches';
|
||||
xhrPending.open("POST",url,true);
|
||||
xhrPending.setRequestHeader('Access-Control-Allow-Methods','POST');
|
||||
xhrPending.setRequestHeader("Content-Type","application/json");
|
||||
xhrPending.onerror = function()
|
||||
{
|
||||
url = 'http://localhost:8000/searches';
|
||||
xhrPending.open("POST", url, true);
|
||||
xhrPending.setRequestHeader('Access-Control-Allow-Methods', 'POST');
|
||||
xhrPending.setRequestHeader("Content-Type", "application/json");
|
||||
xhrPending.onerror = function () {
|
||||
alert("Fehler");
|
||||
}
|
||||
xhrPending.onreadystatechange = function () {
|
||||
if (xhrPending.readyState === 4 && xhrPending.status === 200) {
|
||||
var parent = document.getElementById("pendingSearch");
|
||||
var child = parent.lastElementChild;
|
||||
while(child)
|
||||
{
|
||||
parent.removeChild(child);
|
||||
child = parent.lastElementChild;
|
||||
}
|
||||
var resp = xhrPending.response;
|
||||
var json = JSON.parse(resp);
|
||||
var output = json.Search;
|
||||
var array = [];
|
||||
if(output == "")
|
||||
{
|
||||
return;
|
||||
}
|
||||
while(output.indexOf(';')!=-1)
|
||||
{
|
||||
var a = output.substring(0,output.indexOf(";")-1);
|
||||
output = output.substring(output.indexOf(";")+1);
|
||||
array.push(a.trim());
|
||||
}
|
||||
array.push(output.trim());
|
||||
for(var i = 0;i<array.length;i++)
|
||||
{
|
||||
var textField = document.createElement("p");
|
||||
var text = array[i];
|
||||
textField.innerText = text;
|
||||
document.getElementById("pendingSearch").appendChild(textField);
|
||||
xhrPending.onreadystatechange = function () {
|
||||
if (xhrPending.readyState === 4 && xhrPending.status === 200) {
|
||||
var parent = document.getElementById("pendingSearch");
|
||||
var child = parent.lastElementChild;
|
||||
while (child) {
|
||||
parent.removeChild(child);
|
||||
child = parent.lastElementChild;
|
||||
}
|
||||
var resp = xhrPending.response;
|
||||
var json = JSON.parse(resp);
|
||||
var output = json.Search;
|
||||
var array = [];
|
||||
if (output == "") {
|
||||
return;
|
||||
}
|
||||
while (output.indexOf(';') != -1) {
|
||||
var a = output.substring(0, output.indexOf(";") - 1);
|
||||
output = output.substring(output.indexOf(";") + 1);
|
||||
array.push(a.trim());
|
||||
}
|
||||
array.push(output.trim());
|
||||
for (var i = 0; i < array.length; i++) {
|
||||
var textField = document.createElement("p");
|
||||
var text = array[i];
|
||||
textField.innerText = text;
|
||||
document.getElementById("pendingSearch").appendChild(textField);
|
||||
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// Converting JSON data to string
|
||||
var data = JSON.stringify({ "Search" : "pending"});
|
||||
var data = JSON.stringify({ "Search": "pending" });
|
||||
|
||||
// Sending data with the request
|
||||
xhrPending.send(data);
|
||||
|
||||
xhrPending.send(data);
|
||||
|
||||
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8"/>
|
||||
<title>Suche</title>
|
||||
<link href="commonStyles.css" rel="stylesheet">
|
||||
<link href="searchStyles.css" rel="stylesheet">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="container">
|
||||
<div class="nav-wrapper">
|
||||
@@ -73,26 +75,26 @@
|
||||
<div class="doneSearchWrapper">
|
||||
<label> Ausgeführte Suchen:</label>
|
||||
<div class="doneSearchr" id="doneSearches">
|
||||
<script src="doneSearchesScript.js"></script>
|
||||
<script defer src="doneSearchesScript.js"></script>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="currentSearchWrapper">
|
||||
<label> Jetzige Suche:</label>
|
||||
<div class="currentSearch" id="currentSearch">
|
||||
<script src="currentSearchScript.js"></script>
|
||||
<script defer src="currentSearchScript.js"></script>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="pendingSearchWrapper">
|
||||
<label> Pending Suche:</label>
|
||||
<div class="pendingSearch" id="pendingSearch">
|
||||
<script src="pendingSearchScript.js"></script>
|
||||
<script defer src="pendingSearchScript.js"></script>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
</html>
|
||||
@@ -1,81 +1,69 @@
|
||||
document.getElementById("submitSearch").onclick = function() {search()}
|
||||
document.getElementById("submitSearch").onclick = function () { search() }
|
||||
|
||||
function search() {
|
||||
var searchString = document.getElementById("idSearchBar").value;
|
||||
if(searchString == "")
|
||||
{
|
||||
if (searchString == "") {
|
||||
alert("Suche ist leer");
|
||||
return;
|
||||
}
|
||||
|
||||
var search = new String();
|
||||
|
||||
if(document.getElementById('checkBoxTopic').checked == true)
|
||||
{
|
||||
if(search.length>0)
|
||||
{
|
||||
search = search +" OR ";
|
||||
|
||||
if (document.getElementById('checkBoxTopic').checked == true) {
|
||||
if (search.length > 0) {
|
||||
search = search + " OR ";
|
||||
}
|
||||
search = search + "TS=('" + searchString + "')"
|
||||
}
|
||||
|
||||
if(document.getElementById('checkBoxAK').checked == true)
|
||||
{
|
||||
if(search.length>0)
|
||||
{
|
||||
search = search +" OR ";
|
||||
if (document.getElementById('checkBoxAK').checked == true) {
|
||||
if (search.length > 0) {
|
||||
search = search + " OR ";
|
||||
}
|
||||
search = search + "AK=('" + searchString + "')"
|
||||
}
|
||||
|
||||
if(document.getElementById('checkBoxKP').checked == true)
|
||||
{
|
||||
if(search.length>0)
|
||||
{
|
||||
search = search +" OR ";
|
||||
if (document.getElementById('checkBoxKP').checked == true) {
|
||||
if (search.length > 0) {
|
||||
search = search + " OR ";
|
||||
}
|
||||
search = search + "KP=('" + searchString + "')"
|
||||
}
|
||||
|
||||
if(document.getElementById('checkBoxRA').checked == true)
|
||||
{
|
||||
if(search.length>0)
|
||||
{
|
||||
search = search +" OR ";
|
||||
if (document.getElementById('checkBoxRA').checked == true) {
|
||||
if (search.length > 0) {
|
||||
search = search + " OR ";
|
||||
}
|
||||
search = search + "SU=('" + searchString + "')"
|
||||
}
|
||||
|
||||
if(document.getElementById('checkBoxWOSCategory').checked == true)
|
||||
{
|
||||
if(search.length>0)
|
||||
{
|
||||
search = search +" OR ";
|
||||
if (document.getElementById('checkBoxWOSCategory').checked == true) {
|
||||
if (search.length > 0) {
|
||||
search = search + " OR ";
|
||||
}
|
||||
search = search + "WC=('" + searchString + "')"
|
||||
}
|
||||
|
||||
let xhr = new XMLHttpRequest();
|
||||
let url ='http://localhost:8000/query';
|
||||
xhr.open("POST",url,true);
|
||||
xhr.setRequestHeader('Access-Control-Allow-Methods','POST');
|
||||
xhr.setRequestHeader("Content-Type","application/json");
|
||||
xhr.onerror = function()
|
||||
{
|
||||
let url = 'http://localhost:8000/query';
|
||||
xhr.open("POST", url, true);
|
||||
xhr.setRequestHeader('Access-Control-Allow-Methods', 'POST');
|
||||
xhr.setRequestHeader("Content-Type", "application/json");
|
||||
xhr.onerror = function () {
|
||||
alert("Fehler");
|
||||
}
|
||||
xhr.onreadystatechange = function () {
|
||||
if (xhr.readyState === 4 && xhr.status === 200) {
|
||||
|
||||
}
|
||||
};
|
||||
xhr.onreadystatechange = function () {
|
||||
if (xhr.readyState === 4 && xhr.status === 200) {
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
// Converting JSON data to string
|
||||
var data = JSON.stringify({ "Search" : search});
|
||||
var data = JSON.stringify({ "Search": search });
|
||||
|
||||
// Sending data with the request
|
||||
xhr.send(data);
|
||||
xhr.send(data);
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,110 @@
|
||||
xhrDocumentYears = new XMLHttpRequest();
|
||||
url = 'http://localhost:8000/analyze';
|
||||
xhrDocumentYears.open("POST", url, true);
|
||||
xhrDocumentYears.setRequestHeader('Access-Control-Allow-Methods', 'POST');
|
||||
xhrDocumentYears.setRequestHeader("Content-Type", "application/json");
|
||||
alreadyPlottetyearsDocument = false;
|
||||
var dataDocumentYears = [];
|
||||
xhrDocumentYears.onreadystatechange = function () {
|
||||
if (xhrDocumentYears.readyState === 4 && xhrDocumentYears.status === 200) {
|
||||
var resp = xhrDocumentYears.response;
|
||||
var json = JSON.parse(resp);
|
||||
for (var key in json) {
|
||||
dataDocumentYears.push({ date: key, value: +json[key] })
|
||||
}
|
||||
if (document.getElementById("documentYearsDetails").open) {
|
||||
if (!alreadyPlottetyearsDocument) {
|
||||
plotYearsDocument();
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
document.getElementById("documentYearsDetails")
|
||||
.addEventListener("toggle", c = function () {
|
||||
if (!alreadyPlottetyearsDocument)
|
||||
plotYearsDocument()
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
// Converting JSON data to string
|
||||
var dataJson = JSON.stringify({ "Search": "Years", "Type": "Document", "Filter": window.sessionStorage.getItem("search") });
|
||||
|
||||
// Sending data with the request
|
||||
xhrDocumentYears.send(dataJson);
|
||||
|
||||
|
||||
|
||||
function plotYearsDocument() {
|
||||
alreadyPlottetyearsDocument = true;
|
||||
margin = ({ top: 50, right: 50, bottom: 50, left: 50 })
|
||||
const element = document.getElementById("yearDocumentContainer");
|
||||
height = element.clientHeight;
|
||||
width = element.clientWidth;
|
||||
const list = element.childNodes;
|
||||
element.removeChild(list[1]);
|
||||
const svg = d3.select("#yearDocumentContainer")
|
||||
.select("svg")
|
||||
.attr("viewBox", [0, 0, width, height])
|
||||
.style("-webkit-tap-highlight-color", "transparent")
|
||||
.style("overflow", "visible");
|
||||
|
||||
x = d3.scaleBand()
|
||||
.domain(dataDocumentYears.map(d => d.date))
|
||||
.range([margin.left, width - margin.right])
|
||||
.padding(0.1)
|
||||
|
||||
y = d3.scaleLinear()
|
||||
.domain([0, d3.max(dataDocumentYears, d => d.value)]).nice()
|
||||
.range([height - margin.bottom, margin.top])
|
||||
|
||||
line = d3.line()
|
||||
.curve(d3.curveStep)
|
||||
.defined(d => !isNaN(d.value))
|
||||
.x(d => x(d.date))
|
||||
.y(d => y(d.value))
|
||||
|
||||
|
||||
xAxis = g => g
|
||||
.attr("transform", `translate(0,${height - margin.bottom})`)
|
||||
.call(d3.axisBottom(x).ticks(width / 80).tickSizeOuter(0))
|
||||
|
||||
yAxis = g => g
|
||||
.attr("transform", `translate(${margin.left},0)`)
|
||||
.call(d3.axisLeft(y))
|
||||
.call(g => g.select(".tick:last-of-type text").clone()
|
||||
.attr("x", 3)
|
||||
.attr("text-anchor", "start")
|
||||
.attr("font-weight", "bold")
|
||||
.text(dataDocumentYears.y))
|
||||
|
||||
svg.append("g")
|
||||
.attr("class", "xAxisYearsDocument")
|
||||
.call(xAxis);
|
||||
|
||||
svg.append("g")
|
||||
.attr("class", "yAxis")
|
||||
.call(yAxis);
|
||||
|
||||
svg.append("path")
|
||||
.datum(dataDocumentYears)
|
||||
.attr("fill", "none")
|
||||
.attr("stroke", "steelblue")
|
||||
.attr("stroke-width", 1.5)
|
||||
.attr("stroke-linejoin", "round")
|
||||
.attr("stroke-linecap", "round")
|
||||
.attr("d", line);
|
||||
|
||||
var ticks = d3.selectAll(".xAxisYearsDocument").selectAll(".tick text");
|
||||
|
||||
ticks.each(function (_, i) {
|
||||
if (i % 3 !== 0) d3.select(this).remove();
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,104 @@
|
||||
let xhrYearsPatent = new XMLHttpRequest();
|
||||
url = 'http://localhost:8000/analyze';
|
||||
xhrYearsPatent.open("POST", url, true);
|
||||
xhrYearsPatent.setRequestHeader('Access-Control-Allow-Methods', 'POST');
|
||||
xhrYearsPatent.setRequestHeader("Content-Type", "application/json");
|
||||
alreadyPlottetYearsPatent = false;
|
||||
var dataPatentYears = [];
|
||||
xhrYearsPatent.onreadystatechange = function () {
|
||||
if (xhrYearsPatent.readyState === 4 && xhrYearsPatent.status === 200) {
|
||||
var resp = xhrYearsPatent.response;
|
||||
var json = JSON.parse(resp);
|
||||
for (var key in json) {
|
||||
dataPatentYears.push({ date: key, value: +json[key] })
|
||||
}
|
||||
if (document.getElementById("patentYearsDetails").open) {
|
||||
if (!alreadyPlottetYearsPatent) {
|
||||
plotYearsPatent();
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
document.getElementById("patentYearsDetails")
|
||||
.addEventListener("toggle", b = function () {
|
||||
if (!alreadyPlottetYearsPatent)
|
||||
plotYearsPatent()
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
// Converting JSON data to string
|
||||
var dataJson = JSON.stringify({ "Search": "Years", "Type": "Patent", "Filter": "None" });//window.sessionStorage.getItem("patentSearch")});
|
||||
|
||||
// Sending data with the request
|
||||
xhrYearsPatent.send(dataJson);
|
||||
|
||||
|
||||
|
||||
function plotYearsPatent() {
|
||||
alreadyPlottetYearsPatent = true;
|
||||
margin = ({ top: 50, right: 50, bottom: 50, left: 50 })
|
||||
const element = document.getElementById("yearPatentContainer");
|
||||
height = element.clientHeight;
|
||||
width = element.clientWidth;
|
||||
const list = element.childNodes;
|
||||
element.removeChild(list[1]);
|
||||
const svg = d3.select("#yearPatentContainer")
|
||||
.select("svg")
|
||||
.attr("viewBox", [0, 0, width, height])
|
||||
.style("-webkit-tap-highlight-color", "transparent")
|
||||
.style("overflow", "visible");
|
||||
|
||||
x = d3.scaleBand()
|
||||
.domain(dataPatentYears.map(d => d.date))
|
||||
.range([margin.left, width - margin.right])
|
||||
.padding(0.1)
|
||||
|
||||
y = d3.scaleLinear()
|
||||
.domain([0, d3.max(dataPatentYears, d => d.value)]).nice()
|
||||
.range([height - margin.bottom, margin.top])
|
||||
|
||||
line = d3.line()
|
||||
.curve(d3.curveStep)
|
||||
.defined(d => !isNaN(d.value))
|
||||
.x(d => x(d.date))
|
||||
.y(d => y(d.value))
|
||||
|
||||
|
||||
xAxis = g => g
|
||||
.attr("transform", `translate(0,${height - margin.bottom})`)
|
||||
.call(d3.axisBottom(x).ticks(width / 80).tickSizeOuter(0))
|
||||
|
||||
yAxis = g => g
|
||||
.attr("transform", `translate(${margin.left},0)`)
|
||||
.call(d3.axisLeft(y))
|
||||
.call(g => g.select(".tick:last-of-type text").clone()
|
||||
.attr("x", 3)
|
||||
.attr("text-anchor", "start")
|
||||
.attr("font-weight", "bold")
|
||||
.text(dataPatentYears.y))
|
||||
|
||||
svg.append("g")
|
||||
.attr("class", "xAxisYearsPatent")
|
||||
.call(xAxis);
|
||||
|
||||
svg.append("g")
|
||||
.attr("class", "yAxis")
|
||||
.call(yAxis);
|
||||
|
||||
svg.append("path")
|
||||
.datum(dataPatentYears)
|
||||
.attr("fill", "none")
|
||||
.attr("stroke", "steelblue")
|
||||
.attr("stroke-width", 1.5)
|
||||
.attr("stroke-linejoin", "round")
|
||||
.attr("stroke-linecap", "round")
|
||||
.attr("d", line);
|
||||
|
||||
var ticks = d3.selectAll(".xAxisYearsPatent").selectAll(".tick text");
|
||||
ticks.each(function (_, i) {
|
||||
if (i % 3 !== 0) d3.select(this).remove();
|
||||
})
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
alreadyPlottedComparisonYearsRelative = false;
|
||||
|
||||
function plotYearsRelativeComparison() {
|
||||
alreadyPlottedComparisonYearsRelative = true;
|
||||
margin = ({ top: 50, right: 50, bottom: 50, left: 50 })
|
||||
const element = document.getElementById("yearRelativeComparisonContainer");
|
||||
height = element.clientHeight;
|
||||
width = element.clientWidth;
|
||||
const list = element.childNodes;
|
||||
element.removeChild(list[1]);
|
||||
const svg = d3.select("#yearRelativeComparisonContainer")
|
||||
.select("svg")
|
||||
.attr("viewBox", [0, 0, width, height])
|
||||
.style("-webkit-tap-highlight-color", "transparent")
|
||||
.style("overflow", "visible");
|
||||
|
||||
x = d3.scaleBand()
|
||||
.domain(dataDocumentYearsRelative.map(d => d.date))
|
||||
.range([margin.left, width - margin.right])
|
||||
.padding(0.1)
|
||||
|
||||
min1 = d3.min(dataDocumentYearsRelative, d => d.value);
|
||||
min2 = d3.min(dataPatentYearsRelative, d => d.value);
|
||||
min = Math.min(min1,min2);
|
||||
|
||||
max1 = d3.max(dataDocumentYearsRelative, d => d.value)
|
||||
max2 = d3.max(dataPatentYearsRelative, d => d.value)
|
||||
|
||||
max = Math.max(max1,max2);
|
||||
y = d3.scaleLinear()
|
||||
.domain([min, max]).nice()
|
||||
.range([height - margin.bottom, margin.top])
|
||||
|
||||
|
||||
|
||||
|
||||
xAxis = g => g
|
||||
.attr("transform", `translate(0,${height - margin.bottom})`)
|
||||
.call(d3.axisBottom(x).ticks(width / 80).tickSizeOuter(0))
|
||||
|
||||
yAxis = g => g
|
||||
.attr("transform", `translate(${margin.left},0)`)
|
||||
.call(d3.axisLeft(y))
|
||||
.call(g => g.select(".tick:last-of-type text").clone()
|
||||
.attr("x", 3)
|
||||
.attr("text-anchor", "start")
|
||||
.attr("font-weight", "bold")
|
||||
.text(dataDocumentYearsRelative.y))
|
||||
|
||||
svg.append("g")
|
||||
.attr("class", "xAxisYearsRelativeComparison")
|
||||
.call(xAxis);
|
||||
|
||||
svg.append("g")
|
||||
.attr("class", "yAxis")
|
||||
.call(yAxis);
|
||||
|
||||
line = d3.line()
|
||||
.curve(d3.curveStep)
|
||||
.defined(d => !isNaN(d.value))
|
||||
.x(d => x(d.date))
|
||||
.y(d => y(d.value))
|
||||
|
||||
svg.append("path")
|
||||
.datum(dataDocumentYearsRelative)
|
||||
.attr("fill", "none")
|
||||
.attr("stroke", "steelblue")
|
||||
.attr("stroke-width", 1.5)
|
||||
.attr("stroke-linejoin", "round")
|
||||
.attr("stroke-linecap", "round")
|
||||
.attr("d", line);
|
||||
|
||||
line = d3.line()
|
||||
.curve(d3.curveStep)
|
||||
.defined(d => !isNaN(d.value))
|
||||
.x(d => x(d.date))
|
||||
.y(d => y(d.value))
|
||||
|
||||
svg.append("path")
|
||||
.datum(dataPatentYearsRelative)
|
||||
.attr("fill", "none")
|
||||
.attr("stroke", "red")
|
||||
.attr("stroke-width", 1.5)
|
||||
.attr("stroke-linejoin", "round")
|
||||
.attr("stroke-linecap", "round")
|
||||
.attr("d", line);
|
||||
|
||||
|
||||
var ticks = d3.selectAll(".xAxisYearsRelativeComparison").selectAll(".tick text");
|
||||
|
||||
ticks.each(function (_, i) {
|
||||
if (i % 3 !== 0) d3.select(this).remove();
|
||||
})
|
||||
}
|
||||
@@ -0,0 +1,134 @@
|
||||
xhrDocumentYearsRelative = new XMLHttpRequest();
|
||||
url = 'http://localhost:8000/analyze';
|
||||
xhrDocumentYearsRelative.open("POST", url, true);
|
||||
xhrDocumentYearsRelative.setRequestHeader('Access-Control-Allow-Methods', 'POST');
|
||||
xhrDocumentYearsRelative.setRequestHeader("Content-Type", "application/json");
|
||||
alreadyPlottetDocumentYearsRelative = false;
|
||||
var dataDocumentYearsRelative = [];
|
||||
yearsRelativeDocumentBoolean = false;
|
||||
xhrDocumentYearsRelative.onreadystatechange = function () {
|
||||
if (xhrDocumentYearsRelative.readyState === 4 && xhrDocumentYearsRelative.status === 200) {
|
||||
var resp = xhrDocumentYearsRelative.response;
|
||||
var json = JSON.parse(resp);
|
||||
for (var key in json) {
|
||||
dataDocumentYearsRelative.push({ date: key, value: +json[key] })
|
||||
}
|
||||
if (document.getElementById("documentYearsRelativeDetails").open) {
|
||||
if (!alreadyPlottetDocumentYearsRelative) {
|
||||
plotYearsRelativeDocument();
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
document.getElementById("documentYearsRelativeDetails")
|
||||
.addEventListener("toggle", d = function () {
|
||||
if (!alreadyPlottetDocumentYearsRelative)
|
||||
plotYearsRelativeDocument()
|
||||
})
|
||||
}
|
||||
|
||||
//Comparison
|
||||
if(yearsRelativePatentBoolean == true)
|
||||
{
|
||||
if (document.getElementById("yearRelativeCompasionDetails").open) {
|
||||
if (!alreadyPlottedComparisonYearsRelative) {
|
||||
plotYearsRelativeComparison();
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
document.getElementById("yearRelativeCompasionDetails")
|
||||
.addEventListener("toggle", d = function () {
|
||||
if (!alreadyPlottedComparisonYearsRelative)
|
||||
plotYearsRelativeComparison()
|
||||
})
|
||||
}
|
||||
yearsRelativeDocumentBoolean = true;
|
||||
}
|
||||
else{
|
||||
yearsRelativeDocumentBoolean = true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
// Converting JSON data to string
|
||||
var dataJson = JSON.stringify({ "Search": "YearsRelative", "Type": "Document", "Filter": window.sessionStorage.getItem("search") });
|
||||
|
||||
// Sending data with the request
|
||||
xhrDocumentYearsRelative.send(dataJson);
|
||||
|
||||
|
||||
|
||||
function plotYearsRelativeDocument() {
|
||||
alreadyPlottetDocumentYearsRelative = true;
|
||||
margin = ({ top: 50, right: 50, bottom: 50, left: 50 })
|
||||
const element = document.getElementById("yearRelativeDocumentContainer");
|
||||
height = element.clientHeight;
|
||||
width = element.clientWidth;
|
||||
const list = element.childNodes;
|
||||
element.removeChild(list[1]);
|
||||
const svg = d3.select("#yearRelativeDocumentContainer")
|
||||
.select("svg")
|
||||
.attr("viewBox", [0, 0, width, height])
|
||||
.style("-webkit-tap-highlight-color", "transparent")
|
||||
.style("overflow", "visible");
|
||||
|
||||
x = d3.scaleBand()
|
||||
.domain(dataDocumentYearsRelativeA.map(d => d.date))
|
||||
.range([margin.left, width - margin.right])
|
||||
.padding(0.1)
|
||||
|
||||
y = d3.scaleLinear()
|
||||
.domain([d3.min(dataDocumentYearsRelative, d => d.value), d3.max(dataDocumentYearsRelative, d => d.value)]).nice()
|
||||
.range([height - margin.bottom, margin.top])
|
||||
|
||||
line = d3.line()
|
||||
.curve(d3.curveStep)
|
||||
.defined(d => !isNaN(d.value))
|
||||
.x(d => x(d.date))
|
||||
.y(d => y(d.value))
|
||||
|
||||
|
||||
xAxis = g => g
|
||||
.attr("transform", `translate(0,${height - margin.bottom})`)
|
||||
.call(d3.axisBottom(x).ticks(width / 80).tickSizeOuter(0))
|
||||
|
||||
yAxis = g => g
|
||||
.attr("transform", `translate(${margin.left},0)`)
|
||||
.call(d3.axisLeft(y))
|
||||
.call(g => g.select(".tick:last-of-type text").clone()
|
||||
.attr("x", 3)
|
||||
.attr("text-anchor", "start")
|
||||
.attr("font-weight", "bold")
|
||||
.text(dataDocumentYearsRelative.y))
|
||||
|
||||
svg.append("g")
|
||||
.attr("class", "xAxisYearsRelativeDocument")
|
||||
.call(xAxis);
|
||||
|
||||
svg.append("g")
|
||||
.attr("class", "yAxis")
|
||||
.call(yAxis);
|
||||
|
||||
svg.append("path")
|
||||
.datum(dataDocumentYearsRelative)
|
||||
.attr("fill", "none")
|
||||
.attr("stroke", "steelblue")
|
||||
.attr("stroke-width", 1.5)
|
||||
.attr("stroke-linejoin", "round")
|
||||
.attr("stroke-linecap", "round")
|
||||
.attr("d", line);
|
||||
|
||||
var ticks = d3.selectAll(".xAxisYearsRelativeDocument").selectAll(".tick text");
|
||||
|
||||
ticks.each(function (_, i) {
|
||||
if (i % 3 !== 0) d3.select(this).remove();
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,128 @@
|
||||
let xhrYearsRelativePatent = new XMLHttpRequest();
|
||||
url = 'http://localhost:8000/analyze';
|
||||
xhrYearsRelativePatent.open("POST", url, true);
|
||||
xhrYearsRelativePatent.setRequestHeader('Access-Control-Allow-Methods', 'POST');
|
||||
xhrYearsRelativePatent.setRequestHeader("Content-Type", "application/json");
|
||||
alreadyPlottetYearsRelativePatent = false;
|
||||
var dataPatentYearsRelative = [];
|
||||
yearsRelativePatentBoolean = false;
|
||||
xhrYearsRelativePatent.onreadystatechange = function () {
|
||||
if (xhrYearsRelativePatent.readyState === 4 && xhrYearsRelativePatent.status === 200) {
|
||||
var resp = xhrYearsRelativePatent.response;
|
||||
var json = JSON.parse(resp);
|
||||
for (var key in json) {
|
||||
dataPatentYearsRelative.push({ date: key, value: +json[key] })
|
||||
}
|
||||
if (document.getElementById("patentYearsRelativeDetails").open) {
|
||||
if (!alreadyPlottetYearsRelativePatent) {
|
||||
plotYearsRelativePatent();
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
document.getElementById("patentYearsRelativeDetails")
|
||||
.addEventListener("toggle", a = function () {
|
||||
if (!alreadyPlottetYearsRelativePatent)
|
||||
plotYearsRelativePatent()
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//Comparison
|
||||
if(yearsRelativeDocumentBoolean == true)
|
||||
{
|
||||
if (document.getElementById("yearRelativeCompasionDetails").open) {
|
||||
if (!alreadyPlottedComparisonYearsRelative) {
|
||||
plotYearsRelativeComparison();
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
document.getElementById("yearRelativeCompasionDetails")
|
||||
.addEventListener("toggle", d = function () {
|
||||
if (!alreadyPlottedComparisonYearsRelative)
|
||||
plotYearsRelativeComparison()
|
||||
})
|
||||
}
|
||||
yearsRelativePatentBoolean = true;
|
||||
}
|
||||
else{
|
||||
yearsRelativePatentBoolean = true;
|
||||
}
|
||||
};
|
||||
|
||||
// Converting JSON data to string
|
||||
var dataJson = JSON.stringify({ "Search": "YearsRelative", "Type": "Patent", "Filter": "None" });//window.sessionStorage.getItem("patentSearch")});
|
||||
|
||||
// Sending data with the request
|
||||
xhrYearsRelativePatent.send(dataJson);
|
||||
|
||||
|
||||
|
||||
function plotYearsRelativePatent() {
|
||||
alreadyPlottetYearsRelativePatent = true;
|
||||
|
||||
margin = ({ top: 50, right: 50, bottom: 50, left: 50 })
|
||||
const element = document.getElementById("yearRelativePatentContainer");
|
||||
height = element.clientHeight;
|
||||
width = element.clientWidth;
|
||||
const list = element.childNodes;
|
||||
element.removeChild(list[1]);
|
||||
const svg = d3.select("#yearRelativePatentContainer")
|
||||
.select("svg")
|
||||
.attr("viewBox", [0, 0, width, height])
|
||||
.style("-webkit-tap-highlight-color", "transparent")
|
||||
.style("overflow", "visible");
|
||||
|
||||
x = d3.scaleBand()
|
||||
.domain(dataPatentYearsRelative.map(d => d.date))
|
||||
.range([margin.left, width - margin.right])
|
||||
.padding(0.1)
|
||||
|
||||
y = d3.scaleLinear()
|
||||
.domain([d3.min(dataPatentYearsRelative, d => d.value), d3.max(dataPatentYearsRelative, d => d.value)]).nice()
|
||||
.range([height - margin.bottom, margin.top])
|
||||
|
||||
line = d3.line()
|
||||
.curve(d3.curveStep)
|
||||
.defined(d => !isNaN(d.value))
|
||||
.x(d => x(d.date))
|
||||
.y(d => y(d.value))
|
||||
|
||||
|
||||
xAxis = g => g
|
||||
.attr("transform", `translate(0,${height - margin.bottom})`)
|
||||
.call(d3.axisBottom(x).ticks(width / 80).tickSizeOuter(0))
|
||||
|
||||
yAxis = g => g
|
||||
.attr("transform", `translate(${margin.left},0)`)
|
||||
.call(d3.axisLeft(y))
|
||||
.call(g => g.select(".tick:last-of-type text").clone()
|
||||
.attr("x", 3)
|
||||
.attr("text-anchor", "start")
|
||||
.attr("font-weight", "bold")
|
||||
.text(dataPatentYearsRelative.y))
|
||||
|
||||
svg.append("g")
|
||||
.attr("class", "xAxisYearsRelativePatent")
|
||||
.call(xAxis);
|
||||
|
||||
svg.append("g")
|
||||
.attr("class", "yAxis")
|
||||
.call(yAxis);
|
||||
|
||||
svg.append("path")
|
||||
.datum(dataPatentYearsRelative)
|
||||
.attr("fill", "none")
|
||||
.attr("stroke", "steelblue")
|
||||
.attr("stroke-width", 1.5)
|
||||
.attr("stroke-linejoin", "round")
|
||||
.attr("stroke-linecap", "round")
|
||||
.attr("d", line);
|
||||
|
||||
var ticks = d3.selectAll(".xAxisYearsRelativePatent").selectAll(".tick text");
|
||||
ticks.each(function (_, i) {
|
||||
if (i % 3 !== 0) d3.select(this).remove();
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user