Skip to content

Commit

Permalink
Merge branch 'develop' of github.com:shortintern2020-A-labyrinth/Team…
Browse files Browse the repository at this point in the history
…A into develop

* 'develop' of github.com:shortintern2020-A-labyrinth/TeamA:
  add comments
  append author comment, corrected sensitive words, append previous implementation on crawling method
  author/nakamura_part
  author/nakamura_part
  append author comments
  • Loading branch information
Highmt committed Aug 28, 2020
2 parents 2841e3a + 472588f commit 1521bbe
Show file tree
Hide file tree
Showing 7 changed files with 94 additions and 6 deletions.
4 changes: 3 additions & 1 deletion docker/pg/1-createTable.sql
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ create table requestfriend (
create_at timestamp
);


/* BEGIN:nakamura */
insert into users(name, mail, filterlevel) values
('ichigo.chocomint', '[email protected]', 1),
('banana.chocomint', '[email protected]', 2),
Expand Down Expand Up @@ -98,3 +98,5 @@ insert into users(name, mail, filterlevel) values
('pinapple.chocomint', '[email protected]', 3)
;

/* END:nakamura */

58 changes: 57 additions & 1 deletion src/main/java/com/example/demo/controller/HtmlController.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,24 +14,35 @@
import java.util.ArrayList;
import java.util.List;


/**
* @author Naoto Nishida
*/
@Controller
@RequestMapping(path = "/")
public class HtmlController {

@Autowired
EmologService emologService;

/**
* @author Naoto Nishida
*/
@RequestMapping(path = "/", method = RequestMethod.GET)
public String index() {
return "friendlist";
}

/**
* @author Naoto Nishida
*/
@RequestMapping(path = "/emologlist", method = RequestMethod.GET)
public String emologlist() {
return "emologlist";
}

/**
* @author Naoto Nishida
*/
//この処理いる?バッチ処理できたらいらなそうな気がする。
@RequestMapping(path = "/enter", method = RequestMethod.GET)
public String crawling(
Expand All @@ -40,6 +51,51 @@ public String crawling(

emologService.createEmolog();

//previous実装.バッチ処理したからいらなくなった。
/**
* List<String> keyword_tweets = new ArrayList<String>();
* List<String> keyword_images = new ArrayList<String>();
*
* keyword_tweets = ViewController.get_NLU_keywords("CNN", 100000);
* keyword_images = ViewController.get_image_keywords("CNN", 100000);
*
* List<String> emojiList = new ArrayList<String>();
*
* // TODO: ここでDBアクセスかなんかlook upする??。->つかささんのやつくっつける。
*
* // 文字列整形の方(テキトーに::をつける方)
* for( String keyword : keyword_tweets){
* try{
* String tmp = EmojiParser.parseToHtmlDecimal(":" + keyword + ":");
* emojiList.add(tmp);
* }
* catch (NullPointerException ignored){}
* }
*
* for( String keyword : keyword_images){
* try{
* String tmp = EmojiParser.parseToHtmlDecimal(":" + keyword + ":");
* emojiList.add(tmp);
* }
* catch (NullPointerException ignored){}
* }
*
* // で、:hoge:みたいなんが得られたらEmologにパースして、それをaddAttributeする.->データがdbに入っていないとThymeleaf側で取り出せん模様。
* // modelMap.addAttribute("emologs", emojiList);
*
*
* // emojiList : ["&#128515", "&#128515", "&#128515"] みたいな感じ。
* // emojiListから一つの文字列に直す。
* String emolog = String.join("", emojiList);
*
*
* //TODO: ここで得られたemologをdbに登録する処理…
* // emolog(userid, friendid, create_at, contents)
* // userid = 1, friendid = 2, create_at = TIMESTAMP??, contents = emolog
*
* return "friendlist";
*/

return "friendlist";
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//BEGIN:nakamura
package com.example.demo.controller;

import java.io.FileNotFoundException;
Expand Down Expand Up @@ -54,4 +55,5 @@ public String test(
return c.getXClass();

}
}
}
//END:nakamura
11 changes: 10 additions & 1 deletion src/main/java/com/example/demo/controller/TwitterController.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,18 @@

import java.io.IOException;

/**
* @author Naoto Nishida
*/
@RestController
@RequestMapping(path = "/twitter")
public class TwitterController {

/**
* @author Naoto Nishida
*/
@GetMapping("/search_keyword")
public QueryResult search_keyowrd(@RequestParam(name = "searchword", defaultValue = "チンチン") String searchword) throws TwitterException {
public QueryResult search_keyowrd(@RequestParam(name = "searchword", defaultValue = "judo") String searchword) throws TwitterException {
// 初期化
Twitter twitter = new TwitterFactory().getInstance();
Query query = new Query(searchword);
Expand All @@ -27,6 +33,9 @@ public QueryResult search_keyowrd(@RequestParam(name = "searchword", defaultValu
return result;
}

/**
* @author Naoto Nishida
*/
@RequestMapping(path = "/search_user", method = RequestMethod.GET)
public QueryResult search_user(@RequestParam(name = "username", defaultValue = "CNN") String username,
@RequestParam(name = "tweet_id", defaultValue = "1000000") long tweet_id
Expand Down
18 changes: 17 additions & 1 deletion src/main/java/com/example/demo/controller/ViewController.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ public String read(@PathVariable("id") String id) {
return list.toString();
}

/**
* @author Naoto Nishida
*/
//TODO: Controllerのままか、返り値の型の調整どうするか考える(フロントとの兼ね合い。)
@RequestMapping(path = "/twitter_NLU_keyword", method = RequestMethod.GET)
public List<String> collect_NLU_keywords_from_tweets(
Expand All @@ -72,7 +75,9 @@ public List<String> collect_NLU_keywords_from_tweets(
//TODO: 整形する必要あるかも?
}


/**
* @author Naoto Nishida
*/
@RequestMapping(path = "/twitter_image_keyword", method = RequestMethod.GET)
public List<String> collect_image_keywords_from_tweets(
@RequestParam(name = "username", defaultValue = "CNN") String username,
Expand All @@ -98,6 +103,9 @@ public List<String> collect_image_keywords_from_tweets(

}

/**
* @author Naoto Nishida
*/
// コントローラは関数として呼び出すのはキツイっぽいのでとりま関数として取り出してる。。
//TODO: TwitterControllerやNLUControllerから共通部分を分離して別クラスとして保持。
private static QueryResult search_user(String username, long tweet_id) throws TwitterException {
Expand Down Expand Up @@ -167,6 +175,7 @@ private static String ImageProcessing(String url) throws FileNotFoundException {

}

//BEGIN:nakamura
//emoji-javaを使ってキーワードから絵文字に変換
@RequestMapping(path = "/convert/{keyword}", method = RequestMethod.GET)
public String convert(
Expand Down Expand Up @@ -196,7 +205,11 @@ public List<Emolog> insertEmolog(
// return emologService.insert(user, friend, emoji);
return emologService.insert(123, 456, "U+1F600");
}
//END:nakamura

/**
* @author Naoto Nishida
*/
//関数もおいちゃえ
public static List<String> get_NLU_keywords(String username, long tweet_id) throws TwitterException {
QueryResult result = search_user(username, tweet_id);
Expand All @@ -215,6 +228,9 @@ public static List<String> get_NLU_keywords(String username, long tweet_id) thro
}


/**
* @author Naoto Nishida
*/
public static List<String> get_image_keywords(String username, long tweet_id) throws Exception {
QueryResult result = search_user(username, tweet_id);
ArrayList<String> imageprocessing_results = new ArrayList<>();
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/com/example/demo/service/EmologService.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public List<Emolog> selectAll(int user, int friend){
return emologRepository.selectAll(user, friend);
}

//BEGIN:nakamura
public List<Emolog> insert(int user, int friend, String contents) throws ParseException {
Emolog e = new Emolog();
e.setId((int)Calendar.getInstance().getTimeInMillis());
Expand All @@ -53,6 +54,7 @@ public List<Emolog> insert(int user, int friend, String contents) throws ParseEx
emologRepository.insert(e);
return emologRepository.selectAll(user, friend);
}
//END:nakamura

public void createEmolog() throws Exception {
List<Friend> friends = friendRepository.selectAllRecord();
Expand All @@ -62,7 +64,7 @@ public void createEmolog() throws Exception {
LocalDateTime created_at = LocalDateTime.now();
int count = 0;
for (Friend friend : friends) {
//////////
//
//TODO: 「取得した最新のtweet_idを保存して次のバッチ処理ではそのtweet_id以降を取得」って処理がまだ出来てない。
try {
QueryResult result = emologOutput.querySearch(friend.getName(), friend.getLasttweetid());
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/templates/emologlist.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<!--西田担当分。Thymeleaf記述あたりのサポート-->
<!DOCTYPE html>
<html lang="jp" dir="ltr" xmlns:th="http://www.thymeleaf.org">
<head>
Expand Down

0 comments on commit 1521bbe

Please sign in to comment.