coral-media/ext-ir 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

coral-media/ext-ir

Composer 安装命令:

pie install coral-media/ext-ir

包简介

Information retrieval primitives for PHP

README 文档

README

Information retrieval primitives for PHP.

Build requirements:

  • System OpenBLAS is required.
  • Linux/macOS: install OpenBLAS development package (for example libopenblas-dev).
  • Windows: set OPENBLAS_ROOT to a prefix containing include and lib\\openblas.lib.
  • Snowball is vendored under lib/libstemmer and built as part of the extension.

Install with PIE:

# from repository root
cd ext-ir
pie install -j"$(nproc)"
# from packagist
pie install coral-media/ext-ir

If OpenBLAS is installed in a non-default location:

cd ext-ir
OPENBLAS_PREFIX=/custom/prefix pie install -j"$(nproc)"

Build from source (manual):

cd ext-ir
phpize
./configure --with-php-config="$(command -v php-config)"
make -j"$(nproc)"
make test
sudo make install

Enable extension:

extension=ir

Windows notes:

  • Ensure OpenBLAS is installed and OPENBLAS_ROOT points to the prefix.
  • Build with the same PHP toolchain version/arch/thread-safety as target PHP.
  • Prebuilt libraries availables under Releases section.

Current scaffold (0.1.0) includes:

  • ir_version()
  • CoralMedia\IR\LinearAlgebra::{dot,normL2}()
  • CoralMedia\IR\Text::{tokenize,stem}()
  • CoralMedia\IR\Vectorizer::{frequency,vocabulary,fit,transform,fitTransform,tfIdf,densify}()
  • CoralMedia\IR\Similarity::{pearson,cosine,euclidean}()
  • CoralMedia\IR\Ranking::{nearest,topK,bm25}()

Usage example:

<?php

$items = [
    "The quick brown fox jumps",
    "A quick fox is running",
    "Neural search with sparse vectors",
];

$tokenized = CoralMedia\IR\Text::tokenize(
    $items,
    pattern: '/\s+/u',
    lowercase: true,
    stripDiacritics: true,
    stem: true,
    language: 'english',
    stopwords: ['the', 'a', 'is', 'with']
);

$model = CoralMedia\IR\Vectorizer::fit($tokenized);
$matrix = CoralMedia\IR\Vectorizer::transform($tokenized, $model);

$query = $matrix[0];
$best = CoralMedia\IR\Ranking::nearest($query, $matrix, 'cosine');
$top2 = CoralMedia\IR\Ranking::topK($query, $matrix, 2, 'cosine');

Next planned steps:

  • add ranking helpers (for example bm25)
  • add packed-vector paths for dense workloads
  • expand test coverage for edge cases and large inputs

统计信息

  • 总下载量: 22
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: C

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-03-09

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固