main
reng 1 week ago
parent dc6d69f92a
commit d735aa6a64
  1. 2
      Assets/Qdrant/storage/collections/data-v1/0/newest_clocks.json
  2. 2
      Assets/Qdrant/storage/collections/data-v2/0/newest_clocks.json
  3. 2
      Assets/Qdrant/storage/collections/data-v3/0/newest_clocks.json
  4. 2
      Assets/Qdrant/storage/collections/keywords_v1/0/newest_clocks.json
  5. 2
      Assets/Qdrant/storage/collections/theme-v1/0/newest_clocks.json
  6. 45
      v2/app/src/components/graph.jsx
  7. 21
      v2/app/src/utils/group.js
  8. 7
      v2/app/src/utils/osc.js
  9. 12
      v2/scrapper/main.js

@ -1 +1 @@
{"clocks":[{"peer_id":2200039024721645,"clock_id":5,"current_tick":3,"token":16737324663161229622},{"peer_id":2200039024721645,"clock_id":1,"current_tick":19,"token":13530503213804333634},{"peer_id":2200039024721645,"clock_id":3,"current_tick":5,"token":12159487072447257415},{"peer_id":2200039024721645,"clock_id":2,"current_tick":13,"token":18171945371147883509},{"peer_id":2200039024721645,"clock_id":0,"current_tick":31,"token":14274923382223712766},{"peer_id":2200039024721645,"clock_id":6,"current_tick":1,"token":9225203475475803001},{"peer_id":2200039024721645,"clock_id":4,"current_tick":3,"token":3225682797052271524}]} {"clocks":[{"peer_id":2200039024721645,"clock_id":2,"current_tick":13,"token":18171945371147883509},{"peer_id":2200039024721645,"clock_id":6,"current_tick":1,"token":9225203475475803001},{"peer_id":2200039024721645,"clock_id":5,"current_tick":3,"token":16737324663161229622},{"peer_id":2200039024721645,"clock_id":3,"current_tick":5,"token":12159487072447257415},{"peer_id":2200039024721645,"clock_id":4,"current_tick":3,"token":3225682797052271524},{"peer_id":2200039024721645,"clock_id":0,"current_tick":31,"token":14274923382223712766},{"peer_id":2200039024721645,"clock_id":1,"current_tick":19,"token":13530503213804333634}]}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

@ -1 +1 @@
{"clocks":[{"peer_id":2200039024721645,"clock_id":0,"current_tick":30,"token":6192643460799201647},{"peer_id":2200039024721645,"clock_id":1,"current_tick":5,"token":7526224383505829444}]} {"clocks":[{"peer_id":2200039024721645,"clock_id":1,"current_tick":5,"token":7526224383505829444},{"peer_id":2200039024721645,"clock_id":0,"current_tick":30,"token":6192643460799201647}]}

@ -1 +1 @@
{"clocks":[{"peer_id":2200039024721645,"clock_id":1,"current_tick":1,"token":18111163424196140885},{"peer_id":2200039024721645,"clock_id":0,"current_tick":9,"token":9315707229535449938}]} {"clocks":[{"peer_id":2200039024721645,"clock_id":0,"current_tick":9,"token":9315707229535449938},{"peer_id":2200039024721645,"clock_id":1,"current_tick":1,"token":18111163424196140885}]}

@ -7,6 +7,7 @@ import Point, {PointContentType} from './point.jsx';
import { useControls, button } from "leva"; import { useControls, button } from "leva";
import { sendOsc } from '../utils/osc.js'; import { sendOsc } from '../utils/osc.js';
import { rgbToCss, getRgbFromIndex } from '../utils/color.js'; import { rgbToCss, getRgbFromIndex } from '../utils/color.js';
import { getRevolution } from '../utils/group.js';
export default function Graph({results}){ export default function Graph({results}){
@ -55,7 +56,7 @@ export default function Graph({results}){
const groupId = getGroupId(result); const groupId = getGroupId(result);
if(groupId != -1){ if(groupId != -1){
console.log("group id:", groupId); // console.log("group id:", groupId);
return getRgbFromIndex(groupId, 20); return getRgbFromIndex(groupId, 20);
} }
@ -77,7 +78,8 @@ export default function Graph({results}){
if(!points || points.length===0) return; if(!points || points.length===0) return;
const keywords=results.filter((point, index)=>point?.type==='keyword'); const keywords=results.filter((point)=>point?.type==='keyword');
let i=0; let i=0;
points.forEach((point, index)=>{ points.forEach((point, index)=>{
@ -94,26 +96,47 @@ export default function Graph({results}){
const keyword = keywords.find(kw=>kw.id===group?.id); const keyword = keywords.find(kw=>kw.id===group?.id);
const group_index = keyword ? keywords.indexOf(keyword) : -1; const group_index = keyword ? keywords.indexOf(keyword) : -1;
const point_index=results?.indexOf(keyword);
const keyword_point = point_index != -1 ? points[point_index] : [0,0,0];
const revolution=getRevolution(
keyword_point ,
point
);
sendOsc('/point',JSON.stringify({ sendOsc('/point',JSON.stringify({
index: i, index: i,
x: point[0], // x: point[0],
y: point[1], // y: point[1],
z: point[2], // z: point[2],
content: results?.[index]?.payload.teaser, content: results?.[index]?.payload.teaser,
dist: dist, // dist: dist,
color: getColorByGroup(results?.[index]), // color: getColorByGroup(results?.[index]),
group: group_index group: group_index,
radius: revolution.radius,
axis_x: revolution.axis[0],
axis_y: revolution.axis[1],
axis_z: revolution.axis[2],
center_x: revolution.center[0],
center_y: revolution.center[1],
center_z: revolution.center[2],
})); }));
i++; i++;
}); });
keywords.forEach((point, index)=>{ keywords.forEach((point, index)=>{
// console.log(`send osc Keyword Point ${index}: (${point[0].toFixed(2)}, ${point[1].toFixed(2)}, ${point[2].toFixed(2)})`); // console.log(`send osc Keyword Point ${index}: (${point[0].toFixed(2)}, ${point[1].toFixed(2)}, ${point[2].toFixed(2)})`);
const point_index=results?.indexOf(point);
const keyword_point = point_index != -1 ? points[point_index] : [0,0,0];
sendOsc('/keyword',JSON.stringify({ sendOsc('/keyword',JSON.stringify({
index: index, index: index,
x: point[0], x: keyword_point[0],
y: point[1], y: keyword_point[1],
z: point[2], z: keyword_point[2],
content: JSON.parse(results?.[index]?.payload.text||'{}').title || 'Keyword', content: JSON.parse(results?.[index]?.payload.text||'{}').title || 'Keyword',
color: getColorByGroup(results?.[index]), color: getColorByGroup(results?.[index]),
group: index, group: index,

@ -15,3 +15,24 @@ function euclideanDistance(vec1, vec2) {
} }
return Math.sqrt(vec1.reduce((sum, val, i) => sum + Math.pow(val - vec2[i], 2), 0)); return Math.sqrt(vec1.reduce((sum, val, i) => sum + Math.pow(val - vec2[i], 2), 0));
} }
export function getRevolution(keyword_point, text_point){
// const radius=Math.max(50, base_distance*0.5);
const axis=[0,1,0]; // default Y axis
const center=[
0,
text_point[1] - keyword_point[1],
0
];
const radius=euclideanDistance(center, text_point);
console.log("Revolution radius:", radius);
return {
radius: radius,
axis: axis,
center:center,
}
}

@ -4,5 +4,10 @@ const TD_OSC_PORT=7000;
export function sendOsc(key, message){ export function sendOsc(key, message){
console.log("Sending OSC:", key, message); console.log("Sending OSC:", key, message);
invoke('send_osc_message', {key: `${key}`, message: message, host:'0.0.0.0:0', target:`127.0.0.1:${TD_OSC_PORT}`}) invoke('send_osc_message', {
key: `${key}`,
message: message,
host:'0.0.0.0:0',
target:`127.0.0.1:${TD_OSC_PORT}`
});
} }

@ -52,9 +52,9 @@ const Keywords=[
] ]
const Version="v3"; const Version="v5";
const DEBUG_MODE=false; const DEBUG_MODE=false;
const SCRAP_TYPE='KEYWORD'; // 'KEYWORD' or 'TAG' const SCRAP_TYPE='TAG'; // 'KEYWORD' or 'TAG'
const CLEAR=true; const CLEAR=true;
const COLLECTION_NAME='data-v4'; const COLLECTION_NAME='data-v4';
@ -84,12 +84,12 @@ async function step1(){
const fileName=url.split("/post/")[1].split("/")[0]; const fileName=url.split("/post/")[1].split("/")[0];
// check if directory exists // check if directory exists
const dir = `scrapped/${keyword}`; const dir = `scrapped${Version}/${keyword}`;
if (!existsSync(dir)){ if (!existsSync(dir)){
mkdirSync(dir, { recursive: true }); mkdirSync(dir, { recursive: true });
} }
writeFileSync(`scrapped/${keyword}/${fileName}.json`, JSON.stringify(threadItems, null, 2) ); writeFileSync(`scrapped${Version}/${keyword}/${fileName}.json`, JSON.stringify(threadItems, null, 2) );
} catch(err){ } catch(err){
console.error("Error processing", url, ":", err); console.error("Error processing", url, ":", err);
} }
@ -196,12 +196,12 @@ async function step3(){
async function main(){ async function main(){
// await step1(); await step1();
// await getThread('https://www.threads.com/@pytteliten_/post/DJpeh8BoO3a', cookies); // await getThread('https://www.threads.com/@pytteliten_/post/DJpeh8BoO3a', cookies);
// await step2(); // await step2();
// await parseTest('./processed_v3/00後整頓職場/DBEB0ACzF4j.json'); // await parseTest('./processed_v3/00後整頓職場/DBEB0ACzF4j.json');
await step3(); // await step3();
} }

Loading…
Cancel
Save