1
Fork 0
mirror of https://github.com/pds-nest/nest.git synced 2024-11-26 15:04:18 +00:00
pds-2021-g2-nest/nest_frontend/routes/PageRepository.js

52 lines
1.8 KiB
JavaScript
Raw Normal View History

2021-05-15 16:05:13 +00:00
import React from "react"
import Style from "./PageRepository.module.css"
import classNames from "classnames"
2021-05-18 17:15:53 +00:00
import BoxRepositoryTweets from "../components/interactive/BoxRepositoryTweets"
import BoxWordcloud from "../components/interactive/BoxWordcloud"
2021-05-15 16:05:13 +00:00
export default function PageRepository({ className, ...props }) {
const tweets = [
{
"conditions": [],
"content": "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec posuere lacinia eleifend. Maecenas a neque augue. Nulla dapibus lobortis gravida. Quisque quis ultricies elit. Donec in tortor augue. Cras eget aliquam felis. Nunc tempor, ipsum in lobortis tristique, nunc ante velit.",
"insert_time": "2021-05-18T18:56Z",
"location": null,
"place": "Casa mia",
"poster": "USteffo",
"snowflake": "1394698342282809344",
},
]
let preprocessedWords = {}
for(const tweet of tweets) {
if(!tweet.content) {
continue
}
for(const word of tweet.content.toLowerCase().split(/\s+/)) {
if(!preprocessedWords.hasOwnProperty(word)) {
preprocessedWords[word] = 0
}
preprocessedWords[word] += 1
}
}
let processedWords = []
for(const word in preprocessedWords) {
if(!preprocessedWords.hasOwnProperty(word)) {
continue
}
processedWords.push({
text: word,
value: preprocessedWords[word]
})
}
2021-05-15 16:05:13 +00:00
return (
<div className={classNames(Style.PageRepository, className)} {...props}>
<BoxRepositoryTweets className={Style.Tweets} tweets={tweets}/>
<BoxWordcloud className={Style.Wordcloud} words={processedWords}/>
2021-05-15 16:05:13 +00:00
</div>
)
}