Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

97 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TexIV Logo


A machine learning–based package for transforming text into instrumental variables (IV).

PythonMin StataMin PyPI version PyPI Downloads License: AGPL v3 Issue release Wiki Ask DeepWiki


🌰 Example

Visit Stata Example File and Python Example File.

There is a step-by-step example.

✨ Feature

  • Support multiple Chinese word segmentation and embedding methods
  • Customizable stopwords
  • Support keyword relevance filtering and two-stage filtering
  • Output includes frequency, total count, and ratio statistics

📦 Requirements

  • Python 3.11+
  • Recommended to use virtual environment (e.g., venv or conda)

🚀 Quickly Start

Install

pip install texiv

Usage

from typing import List

from texiv import TexIV

texiv = TexIV()
content: str = "This is a test text..."
keywords: List[str] = ["keyword1", "keyword2", "keyword3"]
texiv.texiv_it(content, keywords)

Async usage:

import asyncio
from typing import List

from texiv import AsyncTexIV, set_parallel_count

# Set the default concurrency for new AsyncTexIV instances.
set_parallel_count(10)

texiv = AsyncTexIV()
content: str = "This is a test text..."
keywords: List[str] = ["keyword1", "keyword2", "keyword3"]
result = asyncio.run(texiv.texiv_it(content, keywords))

For DataFrame processing, call the async API from an event loop:

import asyncio
import pandas as pd

from texiv import AsyncTexIV, set_parallel_count

async def main():
    set_parallel_count(10)
    texiv = AsyncTexIV()
    df = pd.DataFrame({"text": ["First document", "Second document"]})
    return await texiv.texiv_df(df, "text", ["document"])

result_df = asyncio.run(main())

set_parallel_count() only affects TexIV or AsyncTexIV instances created after it is called. You can also pass max_concurrency= directly to an instance when you need per-instance control.

Output example:

{'freq': 7, 'count': 34, 'rate': 0.20588235294117646}

🖥️ Command Line Tool

The project also provides a command-line interface that can be used directly after installation:

texiv --help

🛠️ Configuration

All models and parameters can be adjusted through configuration files in ~/.texiv/config.toml.

📄 License

This project is licensed under the GNU Affero General Public License v3.0. See LICENSE for details.

Note: Commercial use requires compliance with AGPL-3.0 terms, including source code disclosure for network services.

About

A machine learning–based package for transforming text into instrumental variables (IV).

Topics

Resources

Stars

6 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages