File size: 1,114 Bytes
f634188
 
 
 
 
 
 
 
2b5a496
f634188
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
---
language:
- id
tags:
- indobert
- indobenchmark
- indonlu
---
This is the first classification of sentiment analysis for police new task

### How to import
```python
import torch
from transformers import BertForSequenceClassification, BertTokenizer, BertConfig, pipeline

# Load the tokenizer and model
tokenizer = BertTokenizer.from_pretrained("nfhakim/police-sentiment-c1-v2")
config = BertConfig.from_pretrained("nfhakim/police-sentiment-c1-v2")
model = BertForSequenceClassification.from_pretrained("nfhakim/police-sentiment-c1-v2", config=config)
```

### How to use
```python
# Initialize the pipeline
nlp = pipeline("text-classification", model=model, tokenizer=tokenizer)

# Define a function to handle input text
def classify_text(text):
    # Tokenize the text and truncate to the first 512 tokens if necessary
    inputs = tokenizer(text, truncation=True, max_length=512, return_tensors="pt")

    # Use the model to classify the text
    results = nlp(inputs['input_ids'])
    return results

# Example usage
input_text = "Your input text here"
output = classify_text(input_text)
print(output)

```