Skip to content

Commit

Permalink
Merge branch 'release/3.5.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
hmu332233 committed May 5, 2018
2 parents 49b5c12 + 14d2764 commit 426e7ec
Show file tree
Hide file tree
Showing 9 changed files with 123 additions and 16 deletions.
6 changes: 4 additions & 2 deletions app/assets/javascripts/tester.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,14 @@ tester = function () {
'날씨',
'내일 날씨',
'주간 날씨',
'중도',
'알려줘 과사 소',
'알려줘 치킨몇마리 8명',
'편의점',
'버스 위치',
'버스 시간'
'버스 시간',
'중도 자리',
'중도 시간',
'중도'
]
}
};
Expand Down
16 changes: 14 additions & 2 deletions app/controllers/chat_controller.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require 'extractor'
require 'Extractor'
require 'JsonMaker'
require 'MessageFactory'
require 'Message_Manager'
Expand Down Expand Up @@ -427,8 +427,20 @@ def message
render json: jsonMaker.getMessageJson("교내 셔틀버스 정보를 제공하고 있습니다.\n\n 버스 위치 - 실시간 셔틀버스 위치\n 버스 시간 - 셔틀버스 시간")
return;
end
when "중도", "도서관"
case intent
when "자리", "좌석"
render json: jsonMaker.getMessageJson(messageFactory.makeMessage_library_empty_seat)
return;
when "시간"
render json: jsonMaker.getMessageJson(messageFactory.makeMessage_library_time)
return;
else
render json: jsonMaker.getMessageJson("도서관 정보를 제공하고 있습니다\n\중도 자리\n- 열람실 실시간 좌석수\n\n중도 시간\n- 자료실, 열람실, 편의점 이용시간")
return;
end
when "도움말"
render json: jsonMaker.getHelpMenuJson(messageFactory.makeMessage_help_basic)
render json: jsonMaker.getMessageJson(messageFactory.makeMessage_help_basic)
return;
#hit.help_hits += 1
end
Expand Down
4 changes: 2 additions & 2 deletions app/helpers/extractor.rb → app/helpers/Extractor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def extract(message)
notice_keyword = %w[학사공지 일반공지 교내공지 교내채용 특강 스터디 알바 판매구매 자취 분실물]
food_keyword = %w[진수 의대 학생회관 후생관 예지원 정담원 기존관 참빛 새빛 대동 평화 한빛 특성화]
convenience_store = %w[편의점 시유 씨유 cu CU]
etc_keyword = %w[치킨집 날씨 도움말 기숙사 긱사 생활관 버스]
etc_keyword = %w[치킨집 날씨 도움말 기숙사 긱사 생활관 버스 중도 도서관]

food_initial_keyword = %w[ㅈㅅ ㅇㄷ ㅎㅅㅎㄱ ㅎㅅㄱ ㅇㅈㅇ ㅈㄷㅇ ㄱㅈㄱ ㅊㅂ ㅅㅂ ㄷㄷ ㅍㅎ ㅎㅂ ㅌㅅㅎ]

Expand All @@ -25,7 +25,7 @@ def extract(message)
end

#intent 추출
intent_keyword = %w[학생식당 학식 언제 시간 위치 통금 온수]
intent_keyword = %w[학생식당 학식 언제 시간 위치 통금 온수 자리 좌석]

intent_list = intent_keyword

Expand Down
2 changes: 2 additions & 0 deletions app/helpers/MessageFactory.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
require 'message/M_Help'
require 'message/M_Time'
require 'message/M_Bus'
require 'message/M_Library'

class MessageFactory

Expand All @@ -11,5 +12,6 @@ class MessageFactory
include M_Help
include M_Time
include M_Bus
include M_Library

end
21 changes: 11 additions & 10 deletions app/helpers/message/M_Help.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,18 @@ def makeMessage_help_basic
help_message =
"알려줘전북대에서 제공하는 기능들입니다.
1. 학교 공지사항 확인
2. 건지커뮤니티 글 확인
3. 학식 메뉴 확인
4. 학과사무실 정보 확인
5. 날씨 확인
1. 학식 메뉴 기능
2. 각종 운영시간 확인
3. 편의점 시간
4. 중도 좌석 확인
5. 교내 셔틀버스
6. 날씨 확인
7. 학교 공지사항 확인
8. 학과사무실 정보검색
9. 기타
하단의 버튼으로
상세 키워드를 알려드립니다.
또는
아래 링크를 이용해 상세 키워드를 알아볼 수 있습니다.
자세한 사용법은
아래 링크를 통해 확인해주세요.
http://pf.kakao.com/_LffxoM/1738089
"

Expand Down
32 changes: 32 additions & 0 deletions app/helpers/message/M_Library.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
require 'parser/LibraryParser'

module M_Library

def makeMessage_library_empty_seat
parser = LibraryParser.new
data = parser.requestEmptySeatData[0..17]

text = "◆ 중도 자리 ◆\n\n"
data.each do |librarySeat|
text += "#{librarySeat.name}\n사용/총 좌석: #{librarySeat.total}\n\n"
end
return "#{text.strip}"
end

def makeMessage_library_time
message = "◆ 자료실
방학 평일: ~21:00
휴일: ~17:00
◆ 열람실
4열람실: 항시
나머지: ~24:00
◆ 편의점
학기: 08:30 ~ 21:00
방학: 09:00 ~ 20:00
주말: 10:00 ~ 19:00"

return message
end
end
37 changes: 37 additions & 0 deletions app/helpers/parser/LibraryParser.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
require 'util/HttpRequester'
require 'LibrarySeat'

class LibraryParser

def requestEmptySeatData
doc = HttpRequester.requestNokogiriHtml('http://113.198.32.69/mobile/PW/pw20.php')
data = parseData(doc)
return data
end

def parseData(doc)

librarySeats = []

trs = doc.css("table.default//tr")
trs.each_with_index do |tr|
unless tr.attribute('bgcolor').to_s == "#ffffff"
next
end

tds = tr.css("td")

if tds.length == 3
name = tds[0].inner_text.strip
total = tds[1].inner_text.strip
spare = tds[2].inner_text.strip

librarySeats << LibrarySeat.new(name, total, spare)
end

end

return librarySeats
end

end
11 changes: 11 additions & 0 deletions app/helpers/util/HttpRequester.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
require 'util/TimeHelper'

class HttpRequester
def self.requestNokogiriHtml(url)
uri = URI(URI.encode(url))
req = Net::HTTP::Get.new(uri)
res = Net::HTTP.start(uri.hostname, uri.port, :use_ssl => uri.scheme == 'https') { |http| http.request(req) }
doc = Nokogiri::HTML(res.body)
return doc
end
end
10 changes: 10 additions & 0 deletions app/models/LibrarySeat.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
class LibrarySeat

attr_reader :name, :total, :spare

def initialize(name, total, spare)
@name = name
@total = total
@spare = spare
end
end

0 comments on commit 426e7ec

Please sign in to comment.