User Tools

Site Tools


Action disabled: register
using_open_api_example

오픈 API

공공데이터의 제공 및 이용 활성화에 관한 법률

혹은 공공데이터법

  1. “공공기관”이란 국가기관, 지방자치단체 및 「국가정보화 기본법」 제3조제10호에 따른 공공기관을 말한다.
  2. “공공데이터”란 데이터베이스, 전자화된 파일 등 공공기관이 법령 등에서 정하는 목적을 위하여 생성 또는 취득하여 관리하고 있는 광(光) 또는 전자적 방식으로 처리된 자료 또는 정보를 말한다.
  3. “기계 판독이 가능한 형태”란 소프트웨어로 데이터의 개별내용 또는 내부구조를 확인하거나 수정, 변환, 추출 등 가공할 수 있는 상태를 말한다.
  4. “제공”이란 공공기관이 이용자로 하여금 기계 판독이 가능한 형태의 공공데이터에 접근할 수 있게 하거나 이를 다양한 방식으로 전달하는 것을 말한다.

Key 승인:

Sites and Services

Search, Portal

Film and movies

Public

Abroad


all_comb.xlsx

library(bitops)
library(RCurl)
library(rjson)
library(twitteR)
library(digest)
library(ROAuth)
library(KoNLP)
library(rJava)
library(tm)
library(wordcloud)
library(XLConnect)

setwd ("D:/Users/Hyo/Clouds/CS-DS/CS/MovieStudy")

rm(list=ls())
ani<- file.path("all_comb.xlsx")

anisheet <- readWorksheetFromFile(ani, sheet="imdb")
ani.text <- Corpus(VectorSource(anisheet$plotStory))
result.text <- ani.text


myCorpus <- Corpus(VectorSource(result.text))
myCorpus <- tm_map(myCorpus, removePunctuation)
myCorpus <- tm_map(myCorpus, removeNumbers)
myCorpus <- tm_map(myCorpus, tolower)
myStopwords <- c(stopwords('english'), "rt")
myCorpus <-tm_map(myCorpus, removeWords, myStopwords)

inspect(myCorpus[1:5])

myTdm <- TermDocumentMatrix(myCorpus, control=list(wordLengths=c(2,Inf)))
mat <- as.data.frame(as.matrix(myTdm))
write.table(mat, file="myTdm-ani.txt", col.names=FALSE, row.names=TRUE,sep="\t")

pal <- brewer.pal(12,"Paired")
 
# 폰트 세팅. 띄어쓰기나 대소문자에 민감하다는 점에 주의
# 맑은고딕 : windowsFonts(malgun=windowsFont("맑은 고딕"))
# 나눔고딕 : windowsFonts(malgun=windowsFont("나눔고딕"))
windowsFonts(malgun=windowsFont("서울남산체 B"))
 
m <- as.matrix(myTdm)
# calculate the frequency of words
v <- sort(rowSums(m), decreasing=TRUE)
myNames <- names(v)
k <- which(names(v)=="apple")
myNames[k] <- "apple"
d <- data.frame(word=myNames, freq=v)
#wordcloud(d$word, d$freq, scale=c(4,0.5), min.freq=3, random.order=F, rot.per=.1, family="malgun")
wordcloud(d$word, d$freq, scale=c(4,0.7), min.freq=2, random.order=F, rot.per=.1, colors=pal, family="malgun")

mytdm-ani.txt

<!DOCTYPE html>
<html><head>
<meta charset="UTF-8">
</head>
<body>

<?php

$txt='';
$myfile = fopen("daum.out.txt", "w");
$lines = file('movie.dat');
$key = "2de2b474cefdc3cf90ccba1e939e0174a3b3be3e";


for ($i=0;$i<sizeof($lines);$i++) {
	$q = $lines[$i];
	$url = "http://apis.daum.net/contents/movie?apikey=".$key."&output=xml&q=".urlencode($q);

	echo "$url";
	echo "<br />";
	$xml = simplexml_load_file($url);
	echo "hello";

	echo "<pre>";
	echo $xml->asXML();
	echo "</pre>";


	foreach ($xml->item as $oitemVal) {
		$text = " \"".$oitemVal->title->content."\"\t";
		$text .= " \"".$oitemVal->eng_title->content."\"\t";
		$text .= $oitemVal->year->content."\t";
		$text .= " \"".$oitemVal->director->content."\"\t";
		foreach ($oitemVal->actor->content as $oContentVal) {
			$text .= " \"$oContentVal\"";
			} $oContentVal="";
		$text .= "\t";
		$text .= $oitemVal->more_actor->link."\t";
		$text .= $oitemVal->nation->content."\t";
		foreach ($oitemVal->genre->content as $oContentVal) {
			$text .= " \"$oContentVal\"";
			} $oContentVal="";
		$text .= "\t";
		$text .= $oitemVal->open_info[0]->content."\t";

		$text .= "\n";
	echo "$text";
	fwrite($myfile, $text);
	}

	$text='';

}

fclose($myfile);

?>
</body></html>
using_open_api_example.txt · Last modified: 2020/06/09 13:42 by hkimscil

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki